Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.

Overview

ecsgo

Heavily inspired by incredibly useful gossm, this tool makes use of the new ECS ExecuteCommand API to connect to running ECS tasks. It provides an interactive prompt to select your cluster, task and container (if only one container in the task it will default to this), and opens a connection to it.

That's it! Nothing fancy.

⚠️ The ExecuteCommand API is quite new at time of creation and existing Services and Tasks may need to be updated/created with the --enable-execute-command flag via the CLI. Terraform support for this option is now available)

Prereqs

You'll need to follow the prerequisites for ECS Exec as outlined in the blog post. You can also view some additional documentation on using ECS Exec here

Installation

MacOS/Homebrew

brew tap tedsmitt/ecsgo
brew install ecsgo

Linux

wget https://github.com/tedsmitt/ecsgo/releases/download/0.1.3/ecsgo_Linux_x86_64.tar.gz
tar xzf ecsgo_*.tar.gz

Move the ecsgo binary into your $PATH

Usage

The tool uses your AWS Config/Environment Variables to run. If you aren't familiar with working on AWS via the CLI, you can read more about how to configure your environment here

Flag Description Default Value
-p Specify the profile to load the credentials default
-c Specify the command to be run on the container, defaults to /bin/sh
-r Specify the AWS region to run in N/A

In future releases there will be more flags that will allow you to narrow down the results so you can find your desired task/container quicker.

The tool makes use of the wonderful survey package which allows us to filter down our results by typing at the prompt.

See below for some examples:

Connect to a task with multiple containers

multicontainer

Tasks that are not part of a service can be viewed by selecting *

listall

Issuing a specific command to a container

command

Comments
  • Panic in `internal.(*ExecCommand).Start` when `-c` flag is not specified

    Panic in `internal.(*ExecCommand).Start` when `-c` flag is not specified

    Hi!

    I've been testing this tool but ran into an issue. When I run the tool I can navigate to a task that has ECS exec enabled, but when I select the container to exec into the program panics like this:

    ? Select a task: panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1553488]
    
    goroutine 6 [running]:
    github.com/tedsmitt/ecsgo/internal.(*ExecCommand).executeInput(0xc00031caa0)
            github.com/tedsmitt/ecsgo/internal/exec.go:264 +0x88
    github.com/tedsmitt/ecsgo/internal.(*ExecCommand).Start.func1()
            github.com/tedsmitt/ecsgo/internal/exec.go:72 +0x1e5
    created by github.com/tedsmitt/ecsgo/internal.(*ExecCommand).Start
            github.com/tedsmitt/ecsgo/internal/exec.go:58 +0xee
    

    I'm able to work around this by manually specifying the shell to run like ecsgo -c /bin/sh, which according to the README should be the default command.

    bug 
    opened by j-boivie 6
  • Issue Tapping with Homebrew

    Issue Tapping with Homebrew

    When trying to tap this. I get the following error

    $ brew tap tedsmitt/ecsgo
    ==> Tapping tedsmitt/ecsgo
    Cloning into '/opt/homebrew/Library/Taps/tedsmitt/homebrew-ecsgo'...
    remote: Enumerating objects: 21, done.
    remote: Counting objects: 100% (21/21), done.
    remote: Compressing objects: 100% (14/14), done.
    remote: Total 21 (delta 6), reused 3 (delta 0), pack-reused 0
    Receiving objects: 100% (21/21), done.
    Resolving deltas: 100% (6/6), done.
    Error: Invalid formula: /opt/homebrew/Library/Taps/tedsmitt/homebrew-ecsgo/ecsgo.rb
    ecsgo: Calling bottle :unneeded is disabled! There is no replacement.
    Please report this issue to the tedsmitt/ecsgo tap (not Homebrew/brew or Homebrew/core):
      /opt/homebrew/Library/Taps/tedsmitt/homebrew-ecsgo/ecsgo.rb:10
    
    Error: Cannot tap tedsmitt/ecsgo: invalid syntax in tap!
    
    bug 
    opened by codezninja 6
  • Handle simple items better

    Handle simple items better

    Add defaults to each select option

    Where there is only 1 cluster, task, container then automatically pick that one

    This is a starting PR to get comfortable with the code before doing the other SSM changes.

    opened by andymac4182 5
  • Containers logging us into the incorrect container no matter which container is selected

    Containers logging us into the incorrect container no matter which container is selected

    Hello there!

    We are having a weird issue using ecsgo. Every time we run the tool and we select a particular container, it logs us into a different one, never to the main container. (In the example below it logs me into the logger container) Per the instructions in your README, I checked the the ssm plugin and the permissions setup for each task. Everything looks good.

    I even a run a tool to validate if the ecs exec command and I got the results below.

    Screen Shot 2022-10-12 at 4 58 36 PM bug 
    opened by marianafalcho 3
  • detect hanging sessions

    detect hanging sessions

    When i'm in a session and the container get's removed due to new deplyoment/scaling/..., the session hangs forever and the only way is to kill the ecsgo PID.

    Is there a possibility to keep track of the websocket state somehow and exit with a message after a certain timeout?

    P.S.: Great project anyways, thank you! :heart:

    question 
    opened by morph027 3
  • Migrate to AWS CLI

    Migrate to AWS CLI

    Great utility!

    ecsgo doesn't appear to support KMS encrypted sessions, so I changed the command to use aws cli instead.

    Before:

    ✗ ecsgo
    ? Select a task:
    Cluster: redacted | Service: api | Task: 12345308b064a4a911c205c63e0bbbf
    Connecting to container redactedi
    Starting session with SessionId: ecs-execute-command-12345
    
    
    SessionId: ecs-execute-command-12345 :
    ----------ERROR-------
    Encountered error while initiating handshake. Fetching data key failed: Unable to retrieve data key, Error when decrypting data key InvalidCiphertextException:
    

    After:

     Select a task:
    Cluster: redacted | Service: api | Task: 12345308b064a4a911c205c63e0bbbf
    Connecting to container redacted
    
    The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.
    
    
    Starting session with SessionId: ecs-execute-command-12345
    This session is encrypted using AWS KMS.
    #
    
    opened by castrapel 2
  • Use simple comparision instead of Contains / fix #20

    Use simple comparision instead of Contains / fix #20

    When using strings.Contains our flow breaks when selecting the container - see issue https://github.com/tedsmitt/ecsgo/issues/20 The problem is we have 2 containers that are named like this

    • sample-ui-logger
    • sample-ui

    I pick up the first sample-ui, but it ends up ssh into sample-ui-logger, because .Contains function will match both in that case.

    Please check it out, not sure there is a specific reason for using .Contains

    opened by yerfinojul 1
  • Support KMS encrypted sessions

    Support KMS encrypted sessions

    As per https://github.com/tedsmitt/ecsgo/pull/11:

    ecsgo doesn't appear to support KMS encrypted sessions, so I changed the command to use aws cli instead.

    ✗ ecsgo
    ? Select a task:
    Cluster: redacted | Service: api | Task: 12345308b064a4a911c205c63e0bbbf
    Connecting to container redactedi
    Starting session with SessionId: ecs-execute-command-12345
    
    
    SessionId: ecs-execute-command-12345 :
    ----------ERROR-------
    Encountered error while initiating handshake. Fetching data key failed: Unable to retrieve data key, Error when decrypting data key InvalidCiphertextException:```
    bug 
    opened by tedsmitt 1
  • Add version output

    Add version output

    What

    Add version that will be shown when --version or -v is passed

    $ ecsgo --version
    ecsgo version Version: v1.0.0, Commit: xxxxxx, Built date: 2021-03-10 18:10:30, Built by: goreleaser
    

    Why

    To know which release am I using.

    opened by KeisukeYamashita 1
  • DRAFT: Fix/#21 platform family nil ref

    DRAFT: Fix/#21 platform family nil ref

    Adds a check to the PlatformFamily value (only available on Fargate tasks) and if it is not available, then we get the container instance OS and add our own "PlatformFamily" value. This prevents the nil pointer issue we were seeing on EC2 launch-type tasks.

    opened by tedsmitt 0
  • Default command for Windows or Linux

    Default command for Windows or Linux

    Fixes #16

    • Add conditional to check the OS family and determine a sensible default command for Windows or Linux
    • Rename "cmd" channel to "input" to avoid confusion with the arg "cmd"
    opened by tedsmitt 0
  • Non-interactive task selection

    Non-interactive task selection

    Just an idea. Would it be possible to supply cluster, service and taskid via commandline to directly connect to the container without the interactive menu?

    e.g.:

    ecsgo --profile <profile> --cmd bash --cluster <cluster> --service <service> --task <task>
    

    Merry christmas 😉

    opened by morph027 0
  • Add Port-Forwarding Feature

    Add Port-Forwarding Feature

    It appears that you can port forward to ECS tasks using the AWS-StartPortForwardingSession document via SSM. This purely uses the SSM Client package as far as I can tell, and then you can pass the relevant parameters to the session-manager-plugin.

    Will look at getting this implemented asap as I think it'll be very useful.

    enhancement 
    opened by tedsmitt 0
  • List services operation not paginated

    List services operation not paginated

    👋

    As mentioned in #21 I noticed that the output when fetching all services on a cluster isn't paginated here: https://github.com/tedsmitt/ecsgo/blob/95178ae50b5d102c5ffea4eb3f5723c6fad40353/internal/exec.go#L124-L125 This causes missing services in the output if you run more than 10 services on a single cluster.

    I also looked a bit further in the code and noticed that the same seems to be true when fetching tasks, although if I read the documentation right the ListTasks call seems to return 100 tasks in a single page, so that might not be as much of an issue.

    I'd be willing to submit a patch for this, but I can't really say when I'll have the time to do it right now 🙈

    opened by j-boivie 0
Releases(0.4.4)
Owner
Ed Smith
Ed Smith
Open Source runtime scanner for Linux containers (LXD), It performs security audit checks based on CIS Linux containers Benchmark specification

lxd-probe Scan your Linux container runtime !! Lxd-Probe is an open source audit scanner who perform audit check on a linux container manager and outp

Chen Keinan 16 Dec 26, 2022
Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go.

Go Bullet Train (GBT) Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go. It's inspired by the Oh My ZSH Bullet Train theme

Jiri Tyr 520 Dec 17, 2022
Aceptadora provides the boilerplate to orchestrate the containers for an acceptance test.

aceptadora Aceptadora provides the boilerplate to orchestrate the containers for an acceptance test. Aceptadora is a replacement for docker-compose in

Cabify 57 Nov 16, 2022
A tool to build, deploy, and release any environment using System Containers.

Bravetools Bravetools is an end-to-end System Container management utility. Bravetools makes it easy to configure, build, and deploy reproducible envi

null 125 Dec 14, 2022
This repository is where I'm learning to write a CLI using Go, while learning Go, and experimenting with Docker containers and APIs.

CLI Project This repository contains a CLI project that I've been working on for a while. It's a simple project that I've been utilizing to learn Go,

Tamir Arnesty 0 Dec 12, 2021
Ydb-go-yc-metadata - Helpers to connect to YDB inside yandex-cloud using metadata service

ydb-go-yc-metadata helpers to connect to YDB inside yandex-cloud using metadata

YDB Platform 3 Nov 28, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

null 114 Dec 13, 2022
A tool to automate some of my tasks in ECS/ECR.

severinoctl A tool to automate some tasks in ECS/ECR. Work in progress... Prerequisites awscli working aws credentials environment AWS_REGION exported

Edson C. 7 Feb 19, 2022
Prometheus exporter for Amazon Elastic Container Service (ECS)

ecs_exporter ?? ?? ?? This repo is still work in progress and is subject to change. This repo contains a Prometheus exporter for Amazon Elastic Contai

Prometheus Monitoring Community 50 Nov 27, 2022
Build a retractable ECS load balance network through aliyun openapi.

ECSEquilizer 通过阿里云OpenAPI建立一个可伸缩的负载均衡网络调度器。 简介 为确保代理集群网络和计算能力可以通过ECS云服务动态伸缩,所以制定实现以下策略。 节点分为static和dynamic两种,static节点是通过配置文件(config.yaml)实现预设的,固定不变。 d

B23r0 17 Jul 2, 2022
🥝 Mini ECS CLI Command 🥝

miniecs ?? miniecs is a CLI tool for AWS ECS. ?? Requirement go 1.17.x or later �Installation go install github.com/jedipunkz/[email protected] Usage $ m

Tomokazu HIRAI 2 Oct 26, 2022
Amazon ECS Container Agent: a component of Amazon Elastic Container Service

Amazon ECS Container Agent The Amazon ECS Container Agent is a component of Amazon Elastic Container Service (Amazon ECS) and is responsible for manag

null 0 Dec 28, 2021
S3 Reverse Proxy with GET, PUT and DELETE methods and authentication (OpenID Connect and Basic Auth)

Menu Why ? Features Configuration Templates Open Policy Agent (OPA) API GET PUT DELETE AWS IAM Policy Grafana Dashboard Prometheus metrics Deployment

Havrileck Alexandre 154 Jan 2, 2023
Learning about containers and how they work by creating them the hard way

Containers the hard way: Gocker: A mini Docker written in Go It is a set of Linux's operating system primitives that provide the illusion of a contain

Shuveb Hussain 1.5k Jan 7, 2023
Vulnerability Static Analysis for Containers

Clair Note: The main branch may be in an unstable or even broken state during development. Please use releases instead of the main branch in order to

QUAY 9.3k Jan 4, 2023
Binary program to restart unhealthy Docker containers

DeUnhealth Restart your unhealthy containers safely Features Restart unhealthy containers marked with deunhealth.restart.on.unhealthy=true label Recei

Quentin McGaw 59 Dec 22, 2022
The OCI Service Operator for Kubernetes (OSOK) makes it easy to connect and manage OCI services from a cloud native application running in a Kubernetes environment.

OCI Service Operator for Kubernetes Introduction The OCI Service Operator for Kubernetes (OSOK) makes it easy to create, manage, and connect to Oracle

Oracle 24 Sep 27, 2022
Simple docker tui to list, start and stop your containers

docker-tui Simple docker tui that lets you list, start and stop your containers. Current status Rough, initial prototype. Build with This tool relies

Olek 7 Dec 2, 2022
Quickly connect to your Kubernetes Cluster with Tailscale

tsk tsk is a quick and magical way to connect your Kubernetes cluster to your Tailscale Tailnet. Installation tsk requires you have Pulumi installed.

Adam Engebretson 45 Dec 17, 2022