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

Cannot use port-forward when authenticating to AWS using SSO #38

Closed Mallear closed 10 months ago

Mallear commented 11 months ago

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 ?

tedsmitt commented 10 months ago

Thanks for finding this bug! Can confirm I can reproduce when using the vanilla aws sso login command.

Thank you also for the associated PR - I'm going to open a new branch/PR and push a fix along with a small refactor.