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 Answer
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
EXPERT
answered 6 months ago
profile picture
EXPERT
reviewed a month 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. 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

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