Skip to main content

Access ECS tasks with ECS Exec

ECS Exec is a way of using the AWS CLI to launch programs within ECS tasks, including interactive programs like shells.

Prerequsites

You’ll need both the AWS CLI, plus the Session Manager plugin.

The Session Manager plugin can be downloaded from AWS or installed using package managers like Homebrew.

Examples

This is a general template to launch an interactive shell within a specific task and container:

gds aws ACCOUNT -- aws ecs execute-command --region REGION --cluster CLUSTER --task TASK --container CONTAINER --interactive --command "/bin/sh"

For example, getting a shell within a frontend task in staging would look like:

gds aws govwifi-staging -- aws ecs execute-command --region=eu-west-2 --cluster frontend-fargate --task 180f3f7138704925bcfcecda1996f5b4 --container frontend-radius --interactive --command "/bin/sh"

The specific cluster names, task IDs and container names can be found through the AWS website.

This page was last reviewed on 30 August 2022. It needs to be reviewed again on 30 November 2022 by the page owner #govwifi .
This page was set to be reviewed before 30 November 2022 by the page owner #govwifi. This might mean the content is out of date.