Here's my code:
const vpc = new awsx.ec2.Vpc("vpc", {
numberOfAvailabilityZones: 3,
})
const sgLoadBalancer = new awsx.ec2.SecurityGroup("load-balancer", {
vpc: vpc,
egress: [{
protocol: "all",
fromPort: 0,
toPort: 65535,
cidrBlocks: ["0.0.0.0/0"],
}],
ingress: [{
protocol: "tcp",
fromPort: 443,
toPort: 443,
cidrBlocks: ["0.0.0.0/0"],
ipv6CidrBlocks: ["::/0"],
}],
})
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer("web", {
accessLogs: {
bucket: s3AccessLogsBucketName,
enabled: true,
prefix: "load-balancer",
},
enableDeletionProtection: true,
external: true,
securityGroups: [sgLoadBalancer],
subnets: vpc.publicSubnetIds,
vpc: vpc,
})
const webTargetGroup = alb.createTargetGroup("web", {
port: 8001,
protocol: "HTTP",
healthCheck: {
path: "/health",
},
})
const listener = alb.createListener("web-listener", {
protocol: "HTTPS",
sslPolicy: "ELBSecurityPolicy-TLS-1-2-2017-01",
certificateArn: acm.acmSSLCert.arn,
defaultActions: [{
type: "forward",
targetGroupArn: webTargetGroup.targetGroup.arn,
}]
})