Skip to main content

Simple script to allow one to execute commands on AWS ECS Fargate once ECS exec has been correctly configured.

Project description

ecs-exec

pip installable bin to allow user to exec commands inside containers running on AWS ECS Fargate that relies on terraformed infrastructure.

Motivation

  • Run commands inside containers defined by terraform on AWS ECS Fargate.

Installation

$ pip install ecs-exec

Usage

At minimum a terraform module which will output the following:

output "cluster_id" {
  value = "${var.cluster_id}"
}

output "main_task_arn" {
  value = "${var.main_task_arn}"
}

cluster_id is used to identify the ECS cluster, and main_task_arn is used to identify the main task in the ECS cluster. This also assumes that you have configured the following to allow ECS exec:

  • ECS cluster
  • ECS task
  • AWS user

Once you have applied the terraform configuration, pull the output into json:

$ terraform output -json custom_ecs_service > custom_ecs_service.json

Now you can run your command inside a specific container

AWS_PROFILE=staging ecs-exec --file custom_ecs_service.json --container php-fpm --command bash

If you do not know the container name upfront then not supplying the container will print out valid container names.

Output

Output will look something like:

AWS_PROFILE=staging ecs-exec --file custom_ecs_service.json --container php-fpm --command "date +%F"

The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.


Starting session with SessionId: ecs-execute-command-qNq9bIy0uTrZlriS
This session is encrypted using AWS KMS.
2021-06-25


Exiting session with sessionId: ecs-execute-command-qNq9bIy0uTrZlriS.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecs-exec-0.0.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

ecs_exec-0.0.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file ecs-exec-0.0.4.tar.gz.

File metadata

  • Download URL: ecs-exec-0.0.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for ecs-exec-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b8bb9faa57981cb5b6e62633ff75fde1da02684447334fa66add5815ac7c74c4
MD5 0bef78deb19cf794e0ffcdd7e053c7eb
BLAKE2b-256 232af5dbe8234cc5a549d5a89d543d3fdf636609120e8299147a022864253c05

See more details on using hashes here.

File details

Details for the file ecs_exec-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ecs_exec-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for ecs_exec-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9d31c5c494763493da858371b46636a704332a3efaf32d712d982105fda05853
MD5 8d213713473e36941cb60c742dee65c4
BLAKE2b-256 111f86431661c6c6a961cfc521eec49c0dee707bc6e149f6f572386e0ecee9c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page