Skip to content

AWS::CodeDeploy::BlueGreen don't work when ContainerDefinitions have DependsOn #680

Open
@vbarba

Description

@vbarba

1. Title

AWS::CodeDeploy::BlueGreen

2. Scope of request

When trying to deploy on ECS/Fargate using Cloudformation AWS::CodeDeploy::BlueGreen Hook I get this error:

'CodeDeployBlueGreenHook' of type AWS::CodeDeploy::BlueGreen failed with message: Condition layout is incorrect FIELD_NAME at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: aws.cfn.Template["Resources"]->java.util.LinkedHashMap["BlueTaskDefinition"]->aws.cfn.ecs.TaskDefinition["Properties"]->aws.cfn.ecs.TaskDefinitionProperties["ContainerDefinitions"]->java.util.LinkedHashSet[0]->aws.cfn.ecs.taskdefinition.ContainerDefinition["DependsOn"]->java.util.LinkedHashSet[0])

This only happens when in the ContainerDefinitions there are DependsOn properties between containers.

TaskDefinition Sample:

        Type: AWS::ECS::TaskDefinition
        Properties:
            Family: appserver
            NetworkMode: awsvpc
            RequiresCompatibilities:
                - FARGATE
            TaskRoleArn: !Ref ECSTaskIamRole
            ExecutionRoleArn: !GetAtt ECSTaskExecutionRole.Arn
            Cpu: '256'
            Memory: '512'
            ProxyConfiguration:
                Type: APPMESH
                ContainerName: envoy
                ProxyConfigurationProperties:
                    - Name: IgnoredUID
                      Value: '1337'
                    - Name: ProxyIngressPort
                      Value: '15000'
                    - Name: ProxyEgressPort
                      Value: '15001'
                    - Name: AppPorts
                      Value: '5000'
                    - Name: EgressIgnoredIPs
                      Value: '169.254.170.2,169.254.169.254'
            ContainerDefinitions:
                - Name: appserver
                  Essential: true
                  PortMappings:
                    - ContainerPort: 5000
                      Protocol: http
                  Image: !Ref Image
                  LogConfiguration:
                    LogDriver: awslogs
                    Options:
                        awslogs-group: !Ref AWS::StackName
                        awslogs-region: !Ref AWS::Region
                        awslogs-stream-prefix: ppserver
                  DependsOn:
                      - ContainerName: envoy
                        Condition: HEALTHY
                - Name: xray
                  Image: amazon/aws-xray-daemon
                  Essential: true
                  User: '1337'
                  PortMappings:
                    - ContainerPort: 2000
                      HostPort: 2000
                      Protocol: udp
                  LogConfiguration:
                      LogDriver: awslogs
                      Options:
                          awslogs-group: !Ref AWS::StackName
                          awslogs-region: !Ref AWS::Region
                          awslogs-stream-prefix: appserver
                - Name: envoy
                  Image: '840364872350.dkr.ecr.eu-west-1.amazonaws.com/aws-appmesh-envoy:v1.15.1.0-prod'
                  Essential: true
                  User: '1337'
                  DependsOn:
                      - ContainerName: xray
                        Condition: START
                  Ulimits:
                      - Name: nofile
                        HardLimit: 15000
                        SoftLimit: 15000
                  HealthCheck:
                      Command:
                         - CMD-SHELL
                         - curl -s http://localhost:9901/server_info | grep state | grep -q LIVE
                      Interval: 5
                      Timeout: 10
                      Retries: 10
                  LogConfiguration:
                      LogDriver: awslogs
                      Options:
                          awslogs-group: !Ref AWS::StackName
                          awslogs-region: !Ref AWS::Region
                          awslogs-stream-prefix: appserver
                  Environment:
                      - Name: ENVOY_LOG_LEVEL
                        Value: debug
                      - Name: ENABLE_ENVOY_XRAY_TRACING
                        Value: '1'
                      - Name: ENABLE_ENVOY_STATS_TAGS
                        Value: '1'
                      - Name: APPMESH_RESOURCE_ARN
                        Value: !Ref AppVirtualNode

3. Category

Developer Tools:
CodeDeploy
Compute:
ECS, Fargate, EFS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions