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
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 NLB pointing to ALB
Ref. metriport/metriport-internal#1040

Signed-off-by: Rafael Leite <[email protected]>
  • Loading branch information
leite08 committed Jun 19, 2024
commit 3f316aaaddad51a5beb88e2ea113bc21500df8d1
10 changes: 3 additions & 7 deletions packages/infra/lib/api-stack/api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
NetworkTargetGroup,
Protocol,
} from "aws-cdk-lib/aws-elasticloadbalancingv2";
import { AlbTarget } from "aws-cdk-lib/aws-elasticloadbalancingv2-targets";
import * as iam from "aws-cdk-lib/aws-iam";
import { IFunction as ILambda } from "aws-cdk-lib/aws-lambda";
import * as rds from "aws-cdk-lib/aws-rds";
Expand Down Expand Up @@ -360,6 +361,7 @@ export function createAPIService({
),
});

const alb = fargateServiceAlb.loadBalancer;
const nlb = new NetworkLoadBalancer(stack, `ApiNetworkLoadBalancer`, {
vpc,
internetFacing: false,
Expand All @@ -372,17 +374,11 @@ export function createAPIService({
port: listenerPort,
protocol: Protocol.TCP,
vpc,
targets: [new AlbTarget(alb, listenerPort)],
});
nlbTargetGroup.addTarget(fargateServiceAlb.service);
nlbListener.addTargetGroups("ApiNetworkLoadBalancerTargetGroup", nlbTargetGroup);

// Health checks
// This speeds up deployments so the tasks are swapped quicker.
// See for details: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#deregistration-delay
fargateServiceAlb.targetGroup.setAttribute("deregistration_delay.timeout_seconds", "17");
nlbTargetGroup.setAttribute("deregistration_delay.timeout_seconds", "20");
// This also speeds up deployments so the health checks have a faster turnaround.
// See for details: https://docs.aws.amazon.com/elasticloadbalancing/latest/network/target-group-health-checks.html
const healthcheck = {
healthyThresholdCount: 2,
unhealthyThresholdCount: 2,
Expand Down
Loading