Skip to content

Instantly share code, notes, and snippets.

@moerv9
Created December 15, 2023 18:13
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/8d74e6958077b9892fa55a0ffed33fa7 to your computer and use it in GitHub Desktop.
Save moerv9/8d74e6958077b9892fa55a0ffed33fa7 to your computer and use it in GitHub Desktop.
Task definition for relayer service
export class RelayerTaskDefinition extends Stack {
public readonly taskDefinition: ecs.TaskDefinition;
constructor(scope: Construct, id: string, props: MyStackProps) {
super(scope, id, props);
const relayerLogGroup = new logs.LogGroup(this, "RelayerLogGroup", {
removalPolicy: RemovalPolicy.RETAIN,
retention: logs.RetentionDays.ONE_WEEK,
});
const taskDefinition = new ecs.TaskDefinition(this, "DemoTaskDefinition", {
compatibility: ecs.Compatibility.FARGATE,
cpu: "1024",
memoryMiB: "2048",
networkMode: ecs.NetworkMode.AWS_VPC,
// taskRole: ecsTaskRole,
runtimePlatform: {
operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
cpuArchitecture: ecs.CpuArchitecture.X86_64,
},
});
const relayerEcr = ecr.Repository.fromRepositoryArn(
this,
"RelayerEcr",
"arn:aws:ecr:eu-central-1:[accnumber]:repository/pipelinestack-relayerrepod428e6bc-qo9grqldrt1s"
);
const container = taskDefinition.addContainer("RelayerServiceContainer", {
image: ecs.ContainerImage.fromEcrRepository(relayerEcr, "latest"),
cpu: 512,
memoryLimitMiB: 2048,
logging: ecs.LogDriver.awsLogs({
streamPrefix: "relayer",
logGroup: relayerLogGroup,
}),
portMappings: [
{
containerPort: 80,
hostPort: 80,
protocol: ecs.Protocol.TCP,
},
],
healthCheck: {
command: [
"CMD-SHELL",
"--interval=30s --timeout=10s ",
"curl -f http://localhost:80/health || exit 1",
],
},
});
this.taskDefinition = taskDefinition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment