Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

pahud/ecs-exec-cdk-demo

Repository files navigation

Amazon ECS Exec with AWS CDK

Amazon ECS exec was released with CloudFormation day 1 support. Before we have AWS CDK L2 support, we can simply addPropertyOverride to enable this feature for our cluster and service.

This repository demonstrates how it works in action.

Howto

$ cdk deploy -c use_default_vpc

Write a little helper script(i.e. helper.sh)

# ecs_exec_service CLUSTER SERVICE CONTAINER
function ecs_exec_service() {
  CLUSTER=$1
  SERVICE=$2
  CONTAINER=$3
  TASK=$(aws ecs list-tasks --service-name $SERVICE --cluster $CLUSTER --query 'taskArns[0]' --output text)
  ecs_exec_task $CLUSTER $TASK $CONTAINER
}

# ecs_exec_task CLUSTER TASK CONTAINER
function ecs_exec_task() {
  aws ecs execute-command  \
      --cluster $1 \
      --task $2 \
      --container $3 \
      --command "/bin/bash" \
      --interactive
}

Test it

source helper.sh

ecs_exec_service CLUSTER SERVICE CONTAINER

In Action

See the tweets(1, and 2)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published