FargateTask

Description

Builds a general containerized application for ECS Fargate and registers it in ECR (Elastic Container Registry). This pattern is the same as FargateServiceTask with only differences in the container application logic.

Resources

Container definition, permissions, and logging

AWS::ECS::TaskDefinition

Container definition. There must be a circuit panel with the same name as the user id of this resource which defines the logic of containerized application.

AWS::IAM::Role x 2

Task execution role: a general role that grants permissions to start the container defined in a task definition. Task role: a role that grants permissions to the actual application once the container is started.

AWS::IAM::Policy

AWS::Logs::LogGroup

CloudWatch log group for Fargate task

Building and registering the container image

AWS::S3::Bucket

Bucket for storing Codepipeline build artifacts.

AWS::S3::BucketPolicy

Bucket policy for Codepipeline artifact bucket.

AWS::CodeBuild::Project

CodeBuild configurations for building the container image.

AWS::CodePipeline::Pipeline

CodePipeline configurations for deploying the container image to ECR.

AWS::IAM::Role x 2

CodeBuild and CodePipeline execution roles.

AWS::CloudFormation::WaitCondition

For coordinating Fargate task definition resource creation with the CodePipeline deployment phase complete status (which is external to the stack creation).

AWS::CloudFormation::WaitConditionHandle

A presigned-URL to send Codepipeline complete signal to CloudFormation.

These resources are re-created every time the logic of containerized application changes (i.e. to trigger CodeBuild/CodePipeline to build and register new version of container image).

Emptying CodePipleline build artifacts bucket

AWS::CloudFormation::CustomResource`

Custom resource associated with the custom provisioning logic that CloudFormation will run during stack operations (Create, Update, and Delete).

AWS::Lambda::Function

Python lambda function that empty specified S3 bucket when receiving stack deletion request.

AWS::IAM::Role

Lambda function execution role.

Input

containerName

The name of the container. Must be a valid Cloudformation syntax that resolves to a string.

Output

FargateTaskDefinition

Logical ID of Fargate task definition resource AWS::ECS::TaskDefinition created by this pattern.

FargateTaskRole

Logical ID of Fargate task role resource AWS::IAM::Role created by this pattern.

FargateTaskExecutionRole

Logical ID of Fargate task execution role resource AWS::IAM::Role created by this pattern.