How to set enable execute command on ecs fargate, blue/green deployment with code deploy?

1

I made ecs fargate and blue/green deployment on "old aws UI".

And tried to Enable Command Execution on vscode with aws toolkit.

But "[ERROR]: aws.ecs.enableEcsExec: InvalidParameterException: Cannot force a new deployment on services with a CODE_DEPLOY deployment controller. Use AWS CodeDeploy to trigger a new deployment. (statusCode: 400..)" error raised.

So I run this command on terminal.

aws ecs update-service \
    --region ap-northeast-2 \
    --cluster {} \
    --task-definition {} \
    --enable-execute-command \
    --service {} \
    --desired-count 1 \
    --force-new-deployment

But An error occurred (InvalidParameterException) when calling the UpdateService operation: Unable to update task definition on services with a CODE_DEPLOY deployment controller. Use AWS CodeDeploy to trigger a new deployment. error raised.

I think Enable Command Execution on vscode works well with out blue/green deployment.

How to keep blue/green deployment and make to use open fargate terminal?

bts
已提问 6 个月前677 查看次数
1 回答
1

Hello.

As stated in the documentation below, if your ECS is managed by AWS CodeDeploy, you must use "CreateDeployment" to update it.
https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html

For services using the blue/green (CODE_DEPLOY) deployment controller, only the desired count, deployment configuration, health check grace period, task placement constraints and strategies, enable ECS managed tags option, and propagate tags can be updated using this API. If the network configuration, platform version, task definition, or load balancer need to be updated, create a new AWS CodeDeploy deployment. For more information, see CreateDeployment in the AWS CodeDeploy API Reference.

profile picture
专家
已回答 6 个月前
profile picture
专家
已审核 2 个月前
  • Hello. Do you mean "aws code deploy -> applications -> deployments -> create deployment" ?

    There is "Use AppSpec editor" and I can not find EnableCommandExecution.

    Should I set Enable Command Execution by using appspec editor?

  • As an example, if you want to update using a command, I think it would be a good idea to do the following. https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/create-deployment.html

    aws deploy create-deployment \
      --application-name AppECS-test-cluster-test-codedeploy \
      --deployment-group-name DgpECS-test-cluster-test-codedeploy \
      --revision '{"revisionType": "AppSpecContent", "appSpecContent": {"content": "{\"version\": 1, \"Resources\": [{\"TargetService\": {\"Type\": \"AWS::ECS::Service\", \"Properties\": {\"EnableExecuteCommand\": \"True\", \"TaskDefinition\": \"<TaskDefinitionARN>\", \"LoadBalancerInfo\": {\"ContainerName\": \"nginx\", \"ContainerPort\": 80}}}}]}"}}'
    
  • I tried the command and deployment was created. But Error raised.

    The deployment failed because the AppSpec file that specifies the deployment configuration is missing or has an invalid configuration. An unrecognized property "EnableExecuteCommand" was found in the AppSpec file.
    
  • Sorry, I was looking at the wrong document. It seems that EnableExecuteCommand cannot be enabled in AppSpec. https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-resources.html#reference-appspec-file-structure-resources-ecs

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则