binbashar / leverage

Binbash Leverage CLI intended to orchestrate Leverage Reference Architecture for AWS (www.binbash.co/leverage)
https://pypi.org/project/leverage/
Apache License 2.0
17 stars 2 forks source link

No valid credential sources for S3 Backend found. #238

Open diego-ojeda-binbash opened 7 months ago

diego-ojeda-binbash commented 7 months ago

Describe the Bug

While running Terraform commands via Leverage I get the following:

│ Error: error configuring S3 Backend: no valid credential sources for S3 Backend found.
│ 
│ Please see https://www.terraform.io/docs/language/settings/backends/s3.html
│ for more information about providing credentials.
│ 
│ Error: NoCredentialProviders: no valid providers in chain. Deprecated.
│   For verbose messaging see aws.Config.CredentialsChainVerboseErrors

The CLI seems to have valid credentials though. I got the Ref Arch and the CLI properly configured. No other errors are displayed prior to that.

Expected Behavior

I should be able to run Terraform commands via the CLI.

Steps to Reproduce

N/A

Screenshots

N/A

Environment (please complete the following information):

Additional Context

N/A

diego-ojeda-binbash commented 7 months ago

The error could be happening due to an expired session in the AWS console. Such session might expire at some point, which should invalidate the token used by the CLI, which in turn causes the temporary credentials to expire as well. The CLI stores the expiration of the temporary credentials in the AWS config file, which might trick the CLI to believe that the credentials are still valid which is not the case. A possible workaround for this is to remove the expiration in the affected profile. Here's an example of such profile:

[profile vp-management-oaar]
expiration = 1706055798000

Just remove the expiration entry or the entire profile if the expiration is the only entry it has. Then run the Terraform command you need to run and see if that helps solve the issue. If that didn't work, try running a session logout via the CLI, then also log out from your session in the AWS console, and now log in again both via the AWS console and then via the Leverage CLI.