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


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 \

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 Answer


As stated in the documentation below, if your ECS is managed by AWS CodeDeploy, you must use "CreateDeployment" to update it.

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
answered 7 months ago
profile picture
reviewed 2 months ago
  • 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.

    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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions