Code Monkey home page Code Monkey logo

ecs-exec's Introduction

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.

ecs-exec's People

Contributors

puzzledvacuum avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.