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

284 Views Asked by At

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?

If I need to set some configurations on codedeploy, how to set?

Asked to chat GPT

In a Blue/Green deployment in AWS CodeDeploy, the deployment process revolves around creating a new set of resources (the green environment) and gradually shifting traffic to the new environment. This approach doesn't natively support executing commands directly on instances because CodeDeploy is focused on the deployment and traffic shift process.
1

There are 1 best solutions below

2
On

The error is because of --force-new-deployment.

--force-new-deployment will do a ROLLING deployment which is not allowed in your setup since you set the deployment type to CODE_DEPLOY.

To enable-execute-command:

aws ecs update-service \
    --cluster clusterName \
    --service serviceName \
    --enable-execute-command \
    --region region

Verify:

▶ aws ecs describe-services \
    --cluster clusterName \
    --service serviceName \
    --region region \
| jq -r '.[] | .[].enableExecuteCommand'

▶ true

Then do a CODE_DEPLOY deployment since:

You can't turn on ECS Exec for existing tasks. It can only be turned on for new tasks. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html#ecs-exec-considerations