Giter Club home page Giter Club logo

ecsgo's Introduction

Hi there, I'm Ed! ๐Ÿ‘‹

I'm a cloud engineer working primarily on AWS but with Azure and (some) GCP experience.

๐Ÿ˜ I'm in my happy place when I'm

  • โš™๏ธ Scripting and automating stuff
  • ๐Ÿง‘โ€๐Ÿ’ป Improving developer experience
  • ๐Ÿ— Building and engineering cloud infrastructure
  • ๐Ÿ›  Writing code and creating tools to help make life easier
  • ๐ŸŽ“ Learning!

๐ŸŒ Manchester, UK

๐Ÿ“ซ [email protected]

ecsgo's People

Contributors

keisukeyamashita avatar mallear avatar tedsmitt avatar woodjme avatar yerfinojul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ecsgo's Issues

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! โค๏ธ

Broken goreleaser ldflags after moving vars to main package

After moving the ldflag variables from the internal package to main, goreleaser reports the version, commit, builtBy etc. as unset. This is because goreleaser is still configured to set the variables as if they were still in internal.

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 ๐Ÿ˜‰

Homebrew dependency on Go?

Hi,

I noticed when I updated to the latest version that homerbrew downloaded Go as a dependency. I was wondering if that was strictly necessary, since the binary is already pre-compiled for the mac platform?

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!

Default behaviour tries to start /bin/sh in Windows Containers

With the addition of https://aws.amazon.com/about-aws/whats-new/2022/04/amazon-commands-windows-container-aws-fargate/

When attempting to start a session on a Windows Container you'll get the following error

>> ~/.../github/ecsgo (main) [edintheclouds-dev] $ ecsgo
? Select a task: 
Cluster: bluegreen | Service: * | Task: 78619b12e30f4652a20c1ce840f2bf60
Connecting to container windows_container
Starting session with SessionId: ecs-execute-command-057be7bbf24366b94
/bin/sh : The term '/bin/sh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ /bin/sh
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/bin/sh:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

This can be worked around by specifying the command powershell.exe when using the tool

e.g. ecsgo -c powershell.exe

Will look at adding a check to see what the OS family is, and then decide the default command based on that information.

There also seems to be an empty space that gets printed to stdout so need to look into that as well if possible. (This happens when using the AWS CLI as well)

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.

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

Cannot use port-forward when authenticating to AWS using SSO

Hey,

I am using your tool to connect to my ECS tasks and use port forward for local development for months now and everything worked fine until I switched to authentication to AWS using SSO.
Now, I still can connect to ECS task but port forwarding is failing with this error:

$ ecsgo -f
? Enter the local port to be used for forwarding
 8080

NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors

I can still select my cluster, service and task but when launching the port forwarding session, it fails.

To simplify the AWS SSO authentication mecanism and configuration, I am using aws-sso cli

Here is an example of my profile configuration:

[profile MyProfile]
credential_process = /opt/homebrew/bin/aws-sso -u open -S "Default" process --arn MyRoleArn
region = eu-west-1

And my ecsgo version:

$ ecsgo -v
ecsgo version Version: 0.4.5, Commit: 8ceb1d0d755696abb9fabaa88f5707de29604639, Built date: 2023-02-20T09:49:12Z, Built by: goreleaser

By replacing this configuration with temporary keys given by AWS for this profile, the port forwarding is working.
I guess something is wrong in the way ecsgo get credentials when using SSO ?

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.

Support KMS encrypted sessions

As per #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:```

Error when Cluster has no services

Inside of getService we return an error if the length of services is 0

	if len(list.ServiceArns) > 0 {
		var serviceNames []string
		for _, c := range list.ServiceArns {
			arnSplit := strings.Split(*c, "/")
			name := arnSplit[len(arnSplit)-1]
			serviceNames = append(serviceNames, name)
		}
		selection, err := selectService(serviceNames)
		if err != nil {
			e.err <- err
			return
		}
		if selection == backOpt {
			e.cmd <- "getCluster"
			return
		}
		e.service = selection
		e.cmd <- "getTask"
		return
	} else {
		e.err <- err
		return
	}

We should allow for scenarios where the cluster has no services, and has tasks run ad-hoc via external orchestrators (such as Jenkins) or scheduled tasks.

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:

ecsgo/internal/exec.go

Lines 124 to 125 in 95178ae

list, err := e.client.ListServices(&ecs.ListServicesInput{
Cluster: aws.String(e.cluster),

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 ๐Ÿ™ˆ

Option to ignore "fluff" when using the `--cmd` flag

It would be very nice to have the opportunity to ignore printing the additional information when using the --cmd flag in order to make piping easier.

As of now if i run: ecsgo -n xxxxxxxxxx -t xxxxxxx -u xxxxx -c 'echo "hello"' > testsson.txt

testsson.txt will contain all of this.

Cluster: xxxxxx | Service:  | Task: xxxxxxxxxxxx | Cmd: echo "hello"
Connecting to container xxxxxxxxxxxxx

Starting session with SessionId: ecs-execute-command-xxxxxxxxxxxxxx
hello


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

It would be very convenient not to have to strip the excess info manually.

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.