Skip to content

Service

Source: src/AWS/ECS/Service.ts

An ECS Fargate service for running long-lived tasks.

Service turns a bundled AWS.ECS.Task into a continuously running Fargate deployment with awsvpc networking. Phase 1 focuses on the public HTTP path, so the resource can optionally provision an Application Load Balancer, target group, and listener when public: true.

Public HTTP Service

const service = yield* Service("ApiService", {
cluster,
task: apiTask,
vpcId: vpc.vpcId,
subnets: [publicSubnet1.subnetId, publicSubnet2.subnetId],
securityGroups: [serviceSecurityGroup.groupId],
public: true,
});

Internal Service

const service = yield* Service("WorkerService", {
cluster,
task: workerTask,
vpcId: vpc.vpcId,
subnets: [privateSubnet1.subnetId, privateSubnet2.subnetId],
securityGroups: [workerSecurityGroup.groupId],
desiredCount: 2,
});
const service = yield* Service("SecureApiService", {
cluster,
task: apiTask,
vpcId: vpc.vpcId,
subnets: [publicSubnet1.subnetId, publicSubnet2.subnetId],
securityGroups: [serviceSecurityGroup.groupId],
public: true,
certificateArn,
healthCheckPath: "/health",
});
const service = yield* Service("ApiService", {
cluster,
task: apiTask,
vpcId: vpc.vpcId,
subnets: [publicSubnet1.subnetId, publicSubnet2.subnetId],
securityGroups: [serviceSecurityGroup.groupId],
public: true,
desiredCount: 3,
deploymentConfiguration: {
minimumHealthyPercent: 100,
maximumPercent: 200,
},
healthCheckGracePeriodSeconds: 30,
});