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?

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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인