AWSTemplateFormatVersion: '2010-09-09' Description: This template creates an ECS service, which creates a static web-page with the words 'BLUE-SERVICE' on it. Parameters: DesiredCount: Type: Number Default: 1 TargetGroup: Type: String Cluster: Type: String Resources: Repository: Type: AWS::ECR::Repository # DeletionPolicy: Retain ECSServiceRole: Type: AWS::IAM::Role Properties: Path: / AssumeRolePolicyDocument: Statement: - Effect: Allow Principal: Service: [ecs.amazonaws.com] Action: ['sts:AssumeRole'] ManagedPolicyArns: - arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceRole Service: Type: AWS::ECS::Service DependsOn: - ECSServiceRole - TaskDefinition Properties: Cluster: !Ref Cluster Role: !Ref ECSServiceRole DesiredCount: !Ref DesiredCount TaskDefinition: !Ref TaskDefinition LoadBalancers: - ContainerName: blue-app ContainerPort: 80 TargetGroupArn: !Ref TargetGroup TaskDefinition: Type: AWS::ECS::TaskDefinition Properties: Family: !Sub ${AWS::StackName}-canary-app ContainerDefinitions: - Name: blue-app Cpu: 100 Memory: 128 Essential: true Image: amazon/amazon-ecs-sample EntryPoint: - /usr/sbin/apache2 - -D - FOREGROUND MountPoints: - SourceVolume: my-vol ContainerPath: /var/www/my-vol PortMappings: - ContainerPort: 80 HostPort: 0 - Name: busybox Image: busybox EntryPoint: - sh - -c Essential: false Cpu: 100 Memory: 128 VolumesFrom: - SourceContainer: blue-app Command: - /bin/sh -c "echo BLUE-SERVICE > /var/www/my-vol/date" Volumes: - Name: my-vol