tedsmitt / ecsgo

Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.
Apache License 2.0
81 stars 13 forks source link

Migrate to AWS CLI #11

Closed castrapel closed 2 years ago

castrapel commented 2 years ago

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.
#
tedsmitt commented 2 years ago

Hi @castrapel thanks for bringing this to my attention! I was able to reproduce this exact error in my own setup earlier today.

I was curious myself as to why the encrypted sessions weren't working, I did some digging into the AWS CLI to see if it was doing anything magical but it didn't appear to be, this tool pretty much mirrors what the CLI does under the hood.

I realised the version of the AWS SDK used in the project was fairly old so I updated that, and it appears to have fixed the issue ( I attempted to pinpoint when exactly this was fixed by searching through previous SDK releases but couldn't find anything conclusive!)

I've rolled this out in version 0.3.0.

Thanks again for raising this, please let me know if the latest version fixes this for you!

tedsmitt commented 2 years ago

Closing as this has been addressed in 0.3.0