Task Definition
Manages an ECS Task Definition.
Sample code
exports.createResources = () => [
{
type: "TaskDefinition",
group: "ECS",
properties: ({ config }) => ({
containerDefinitions: [
{
command: [],
cpu: 0,
dnsSearchDomains: [],
dnsServers: [],
dockerLabels: {},
dockerSecurityOptions: [],
entryPoint: [],
environment: [],
environmentFiles: [],
essential: true,
extraHosts: [],
image: "amazon/amazon-ecs-sample",
links: [],
logConfiguration: {
logDriver: "awslogs",
options: {
"awslogs-group":
"ECSServiceStack-amazonecssampleTaskDefwebLogGroup910AB31A-Aka75VsMnKfI",
"awslogs-region": `${config.region}`,
"awslogs-stream-prefix": "ECSServiceStack",
},
secretOptions: [],
},
mountPoints: [],
name: "web",
portMappings: [
{
containerPort: 80,
hostPort: 80,
protocol: "tcp",
},
],
secrets: [],
systemControls: [],
ulimits: [],
volumesFrom: [],
},
],
cpu: "512",
family: "ECSServiceStackamazonecssampleTaskDef499685C5",
memory: "1024",
networkMode: "awsvpc",
requiresCompatibilities: ["FARGATE"],
}),
dependencies: ({}) => ({
taskRole:
"ECSServiceStack-amazonecssampleTaskDefTaskRole527D-1JLMLL2357T0V",
executionRole:
"ECSServiceStack-amazonecssampleTaskDefExecutionRol-1391KZSJLULK2",
}),
},
];
Properties
Dependencies
Used By
Full Examples
[aws-cdk-examples/application-load-balancer-fargate-service]((https://github.com/grucloud/grucloud/tree/main/examples/aws/aws-cdk-examples/application-load-balancer-fargate-service)
[serverless-patterns/apigw-fargate-cdk]((https://github.com/grucloud/grucloud/tree/main/examples/aws/serverless-patterns/apigw-fargate-cdk)
[serverless-patterns/apigw-vpclink-pvt-alb]((https://github.com/grucloud/grucloud/tree/main/examples/aws/serverless-patterns/apigw-vpclink-pvt-alb)
[serverless-patterns/fargate-aurora-serverless-cdk]((https://github.com/grucloud/grucloud/tree/main/examples/aws/serverless-patterns/fargate-aurora-serverless-cdk)
[serverless-patterns/fargate-eventbridge]((https://github.com/grucloud/grucloud/tree/main/examples/aws/serverless-patterns/fargate-eventbridge)
List
The ECS services can be filtered with the TaskDefinition type:
gc l -t TaskDefinition
Listing resources on 1 provider: aws
✓ aws
✓ Initialising
✓ Listing 3/3
┌───────────────────────────────────────────────────────────────────────────────┐
│ 1 ECS::TaskDefinition from aws │
├───────────────────────────────────────────────────────────────────────────────┤
│ name: nginx │
│ managedByUs: Yes │
│ live: │
│ taskDefinitionArn: arn:aws:ecs:eu-west-2:840541460064:task-definition/ngin… │
│ containerDefinitions: │
│ - name: nginx │
│ image: nginx │
│ cpu: 0 │
│ memory: 512 │
│ portMappings: │
│ - containerPort: 80 │
│ hostPort: 80 │
│ protocol: tcp │
│ essential: true │
│ environment: [] │
│ mountPoints: [] │
│ volumesFrom: [] │
│ family: nginx │
│ revision: 47 │
│ volumes: [] │
│ status: ACTIVE │
│ placementConstraints: [] │
│ compatibilities: │
│ - "EXTERNAL" │
│ - "EC2" │
│ requiresCompatibilities: │
│ - "EC2" │
│ registeredAt: 2021-09-03T13:40:50.297Z │
│ registeredBy: arn:aws:iam::840541460064:root │
│ tags: │
│ - key: gc-created-by-provider │
│ value: aws │
│ - key: gc-managed-by │
│ value: grucloud │
│ - key: gc-project-name │
│ value: example-grucloud-ecs-simple │
│ - key: gc-stage │
│ value: dev │
│ - key: Name │
│ value: nginx │
│ │
└───────────────────────────────────────────────────────────────────────────────┘
List Summary:
Provider: aws
┌──────────────────────────────────────────────────────────────────────────┐
│ aws │
├────────────────────────────────┬─────────────────────────────────────────┤
│ ECS::TaskDefinition │ nginx │
└────────────────────────────────┴─────────────────────────────────────────┘
1 resource, 1 type, 1 provider
Command "gc l -t TaskDefinition" executed in 6s