aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.46k stars 403 forks source link

ECS: enable execute command with CodeDeploy blue/green deployment #4017

Open copyNdpaste opened 10 months ago

copyNdpaste commented 10 months ago

System details (run the AWS: About Toolkit command)

Question

Hello

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.

justinmk3 commented 8 months ago

For reference, this AWS Toolkit code enables ECS exec: https://github.com/aws/aws-toolkit-vscode/blob/428653acd9b3eaa2568242ff2f05105ae4c37c24/src/ecs/model.ts#L123-L126

And just like the aws ecs update-service --enable-execute-command ... command you tried, ECS disallows updating the service using that API.

This post explains that aws deploy create-deployment must be used instead of aws ecs update-service. But apparently EnableExecuteCommand is not supported in the parameters.

Edit: based on discussion w/ ECS team, the CloudFormation properties listed here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-service.html should all be valid (as aws deploy create-deployment --revision {...} content), unless CodeDeploy is removing certain properties such as EnableExecuteCommand.

Next steps