Skip to content

Instantly share code, notes, and snippets.

@moerv9
Created December 15, 2023 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moerv9/e09e2ebc39124205f8d4c09b3e0409cf to your computer and use it in GitHub Desktop.
Save moerv9/e09e2ebc39124205f8d4c09b3e0409cf to your computer and use it in GitHub Desktop.
Relayer service
// export class RelayerServiceStack etc etc...
// and importing vpc and cluster above
const listener = props.relayerLoadBalancer.addListener("RelayerListener", {
port: 80,
protocol: elbv2.ApplicationProtocol.HTTP,
open: true,
});
listener.connections.allowFromAnyIpv4(ec2.Port.allTraffic());
const sg_service = new ec2.SecurityGroup(this, "RelayerSG", {
vpc: vpc,
allowAllOutbound: true,
description: "Security group for Relayer tasks",
});
sg_service.addIngressRule(
ec2.Peer.ipv4("0.0.0.0/0"),
ec2.Port.allTraffic()
);
// Create a Fargate service
const relayerService = new ecs.FargateService(this, "RelayerServiceM", {
cluster: cluster,
taskDefinition: props.taskDefinition,
enableExecuteCommand: true,
securityGroups: [sg_service],
assignPublicIp: false,
healthCheckGracePeriod: Duration.seconds(3600),
});
listener.addTargets("RelayerTarget", {
port: 80,
targets: [relayerService],
healthCheck: {
path: "/health",
healthyHttpCodes: "200-499",
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment