Skip to main content

Connect to fargate container

ยท 2 min read
Vitaliy Syveniuk
Fullstack Engineer

Let's say you've deployed to AWS Fargate and everything is working bright and shiny. But at some point you have an unfortunate error with the env variables, for example, and you want to verify what's actually inside the container.

So, you think "I'm gonna plug into the container and see what's going on". Not so fast...

๐Ÿ™€ You'll get an error:

An error occurred (InvalidParameterException) when calling the ExecuteCommand operation: The execute command failed because execute command was not enabled when the task was run or the execute command agent isnโ€™t running.
Wait and try again or run a new task with execute command enabled and try again.

Apparently you need to enable execute-command in the task definition, and this option is not available in the aws console interface. So you need to enable it with aws cli:

aws ecs update-service --cluster <cluster-name> --service <service-name> --enable-execute-command --force-new-deployment

warning

Don't forget the --force-new-deployment flag, without starting a new deployment you still won't be able to connect

And now you're in! Enjoy your debugging ๐Ÿ˜บ

Hope you found this article helpful. Stay tuned for more articles on AWS services. ๐Ÿ“†