21

I've encountered following error when I'm trying to create Deployment Group for ECS Cluster in Code Deploy. I've created IAM that based on CodeDeploy ECS and its policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeServices",
                "ecs:CreateTaskSet",
                "ecs:UpdateServicePrimaryTaskSet",
                "ecs:DeleteTaskSet",
                "elasticloadbalancing:DescribeTargetGroups",
                "elasticloadbalancing:DescribeListeners",
                "elasticloadbalancing:ModifyListener",
                "elasticloadbalancing:DescribeRules",
                "elasticloadbalancing:ModifyRule",
                "lambda:InvokeFunction",
                "cloudwatch:DescribeAlarms",
                "sns:Publish",
                "s3:GetObject",
                "s3:GetObjectMetadata",
                "s3:GetObjectVersion"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "iam:PassRole"
            ],
            "Effect": "Allow",
            "Resource": "*",
            "Condition": {
                "StringLike": {
                    "iam:PassedToService": [
                        "ecs-tasks.amazonaws.com"
                    ]
                }
            }
        }
    ]
}

Please let me know when I made mistake?

enter image description here

PPShein
  • 13,309
  • 42
  • 142
  • 227

2 Answers2

20

If you are using CodeDeploy, your ECS service has to be defined so that it uses Blue/Green code deployments rather than Rolling Updates:

snapshot of AWS Management Console > ECS > Create Service

HTH!

Community
  • 1
  • 1
diginoise
  • 7,352
  • 2
  • 31
  • 39
  • 5
    I have created my ecs service using cloudformation template. There is no property in cloudformation to specify to use Blue/Green Deployment model. I am following a thread https://stackoverflow.com/questions/54304700/required-cloudformation-script-for-blue-green-deployment-on-ecs which says support for this hasn't been added in cloudformation yet. – kk. Jun 21 '19 at 10:16
10

Also if you are using terraform you can simply fix it by add this to aws_ecs_service:

  deployment_controller {
      type = "CODE_DEPLOY"
  }
Roman
  • 359
  • 4
  • 7