Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1040 - 1/3 Create ALB version of the API #2303

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(infra): 1/3 add DB access to new ALB fargate service
Ref. metriport/metriport-internal#1040

Signed-off-by: Rafael Leite <[email protected]>
  • Loading branch information
leite08 committed Jun 19, 2024
commit cfe3969ca4ab32a8bf444a139af02158cc69ef5a
3 changes: 3 additions & 0 deletions packages/infra/lib/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export class APIStack extends Stack {
service: apiService,
loadBalancerAddress: apiLoadBalancerAddress,
serverAddress: apiServerUrl,
apiServiceAdditional,
} = createAPIService({
stack: this,
props,
Expand Down Expand Up @@ -456,6 +457,8 @@ export class APIStack extends Stack {

// Access grant for Aurora DB
dbCluster.connections.allowDefaultPortFrom(apiService.service);
// TODO remove this on 3/3
dbCluster.connections.allowDefaultPortFrom(apiServiceAdditional);

// setup a private link so the API can talk to the NLB
const link = new apig.VpcLink(this, "link", {
Expand Down
3 changes: 3 additions & 0 deletions packages/infra/lib/api-stack/api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import { Repository } from "aws-cdk-lib/aws-ecr";
import * as ecs from "aws-cdk-lib/aws-ecs";
import { FargateService } from "aws-cdk-lib/aws-ecs";
import * as ecs_patterns from "aws-cdk-lib/aws-ecs-patterns";
import {
ApplicationProtocol,
Expand Down Expand Up @@ -98,6 +99,7 @@ export function createAPIService({
service: ecs_patterns.NetworkLoadBalancedFargateService;
serverAddress: string;
loadBalancerAddress: string;
apiServiceAdditional: FargateService;
} {
// Create a new Amazon Elastic Container Service (ECS) cluster
const cluster = new ecs.Cluster(stack, "APICluster", { vpc, containerInsights: true });
Expand Down Expand Up @@ -561,5 +563,6 @@ export function createAPIService({
service: fargateService,
serverAddress: apiUrl,
loadBalancerAddress: serverAddress,
apiServiceAdditional: fargateServiceAlb.service,
};
}