AWSTemplateFormatVersion: '2010-09-09' Description: This template creates an ECS service, which creates a static web-page with the words 'GREEN-SERVICE' on it. Parameters: DesiredCount: Type: Number Default: 1 TargetGroup: Type: String Description: The LB Target Group ARN Cluster: Type: String Resources: 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 # PlacementStrategies: # - Type: spread # - Field: host # attribute:ecs.availability-zone LoadBalancers: - ContainerName: green-app ContainerPort: 80 TargetGroupArn: !Ref TargetGroup TaskDefinition: Type: AWS::ECS::TaskDefinition Properties: Volumes: - Name: my-vol Family: !Sub ${AWS::StackName}-canary-app ContainerDefinitions: - Name: green-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 Essential: false Cpu: 100 Memory: 128 Image: busybox VolumesFrom: - SourceContainer: green-app EntryPoint: - sh - -c Command: - /bin/sh -c "echo GREEN-SERVICE > /var/www/my-vol/date"