Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
Created October 6, 2021 18:15
Show Gist options
  • Save kevinhooke/51c028c7e7f464bb678f77b62bb93768 to your computer and use it in GitHub Desktop.
Save kevinhooke/51c028c7e7f464bb678f77b62bb93768 to your computer and use it in GitHub Desktop.
AWS CloudFormation example for ECS TaskDef
{
"Description": "Example ECS TaskDef",
"Parameters": {
"Param1": {
"Description": "Example param 1",
"Type": "String"
}
},
"Resources": {
"ECSTaskExampleExecutionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"Policies": [
{
"PolicyName": "ECSTaskExampleExecutionPolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:us-west-1:*:log-group:*"
}
]
}
}
]
}
},
"ECSTaskExampleLogGroup": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "ecs-example-loggroup",
"RetentionInDays": 30
}
},
"ECSExampleTaskDef": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"Family": "example-family",
"executionRoleArn": {
"Ref": "ECSTaskExampleExecutionRole"
},
"NetworkMode": "awsvpc",
"ContainerDefinitions": [
{
"name": "CONTAINER_NAME-HERE",
"image": "IMAGE-NAME-HERE",
"essential": true,
"entryPoint": [
"/entry-point-here"
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "ecs-example-loggroup",
"awslogs-region": "us-west-1",
"awslogs-stream-prefix": "ecs-example"
}
},
"Command": [
"--example-param1",
{
"Ref": "Param1"
}
]
}
],
"RequiresCompatibilities": [
"FARGATE"
],
"Cpu": "256",
"Memory": "512"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment