Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: panic: aws session init failed -- AWS Credentials expired #1

Closed
sagarrakshe opened this issue Mar 7, 2023 · 10 comments · Fixed by #4
Closed

Error: panic: aws session init failed -- AWS Credentials expired #1

sagarrakshe opened this issue Mar 7, 2023 · 10 comments · Fixed by #4
Assignees
Labels
bug Something isn't working

Comments

@sagarrakshe
Copy link

sagarrakshe commented Mar 7, 2023

I installed the tool and launched it,

$ brew install one2nc/cloudlens/cloudlens
$ cloudlens

I didn't have a default profile set in ~/.aws/credentials so I got message

Profile 'default' not found, using profile 'personal'...

I used --profile arg and I got this error

Credentials have expired
panic: aws session init failed -- AWS Credentials expired

goroutine 1 [running]:
github.com/one2nc/cloudlens/cmd.run(0x1020e1d00?, {0x10163a704?, 0x0?, 0x0?})
        github.com/one2nc/cloudlens/cmd/root.go:73 +0x4c8
github.com/spf13/cobra.(*Command).execute(0x1020e1d00, {0x14000190200, 0x0, 0x0})
        github.com/spf13/cobra@v1.6.1/command.go:920 +0x5b0
github.com/spf13/cobra.(*Command).ExecuteC(0x1020e1d00)
        github.com/spf13/cobra@v1.6.1/command.go:1044 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.6.1/command.go:968
github.com/one2nc/cloudlens/cmd.Execute()
        github.com/one2nc/cloudlens/cmd/root.go:42 +0x28
main.main()
        github.com/one2nc/cloudlens/main.go:8 +0x1c

Same error when I copied my AWS credentials to default in ~/.aws/credentials.

Machine Info

MaC OSX M1 Ventura 13.0

@chinmay185
Copy link
Contributor

Thanks for the details @sagarrakshe. We recently changed this behaviour, but on second thoughts, I think we should launch the app, even if the credentials are expired/invalid/not found (instead of panicing).

In the app, we can show a flash message indicating to fix the credentials. We'll fix this soon.

@sagarrakshe
Copy link
Author

@chinmay185
Oh! I forgot to mention. My credentials have not expired, I use them daily. Yet I am getting this error.

@dirien
Copy link

dirien commented Mar 7, 2023

Same for me: I use aws with sso and get all the time this error message. I do a aws sso login before starting cloudlens

cloudlens
Profile 'default' not found, using profile 'private'... Credentials have expired
panic: aws session init failed -- AWS Credentials expired

goroutine 1 [running]:
github.com/one2nc/cloudlens/cmd.run(0x10140dd00?, {0x100966704?, 0x0?, 0x0?})
	github.com/one2nc/cloudlens/cmd/root.go:73 +0x4c8
github.com/spf13/cobra.(*Command).execute(0x10140dd00, {0x14000118200, 0x0, 0x0})
	github.com/spf13/cobra@v1.6.1/command.go:920 +0x5b0
github.com/spf13/cobra.(*Command).ExecuteC(0x10140dd00)
	github.com/spf13/cobra@v1.6.1/command.go:1044 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.6.1/command.go:968
github.com/one2nc/cloudlens/cmd.Execute()
	github.com/one2nc/cloudlens/cmd/root.go:42 +0x28
main.main()
	github.com/one2nc/cloudlens/main.go:8 +0x1c

@seh
Copy link

seh commented Mar 7, 2023

Like @dirien's report in #1 (comment), I use aws-vault as my credential process, with profiles using SSO.

@WMRamadan
Copy link

I use MFA with my AWS login and before I login with MFA I would get the following error:

Credentials have expired
panic: aws session init failed -- AWS Credentials expired

After I login with MFA I get the following error:

failed to load AWS SDK config: assume role with MFA enabled, but AssumeRoleTokenProvider session option not set.

@ahuffman
Copy link

ahuffman commented Mar 7, 2023

similar, but I'm using aws access key is and aws secret access key. AWS CLI works fine, but I get this from cloudlens:

cloudlens
Credentials have expired
panic: aws session init failed -- AWS Credentials expired

goroutine 1 [running]:
github.com/one2nc/cloudlens/cmd.run(0x22f2d20?, {0x1a272af?, 0x0?, 0x0?})
	github.com/one2nc/cloudlens/cmd/root.go:73 +0x4ce
github.com/spf13/cobra.(*Command).execute(0x22f2d20, {0xc00010a200, 0x0, 0x0})
	github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x22f2d20)
	github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.6.1/command.go:968
github.com/one2nc/cloudlens/cmd.Execute()
	github.com/one2nc/cloudlens/cmd/root.go:42 +0x25
main.main()
	github.com/one2nc/cloudlens/main.go:8 +0x17

@chinmay185 chinmay185 added the bug Something isn't working label Mar 8, 2023
@arjunmahishi
Copy link

arjunmahishi commented Mar 8, 2023

I think this is the problem:

isExp := sess.Config.Credentials.IsExpired()
if err != nil {
fmt.Println("Error creating session:", err)
return nil, err
}
if isExp {
fmt.Println("Credentials have expired")
return nil, errors.New("AWS Credentials expired")
}

IsExpired might not be relevant for all types of authentications. I am using access_token + secret_token, and commenting out this check worked for me.

If you ask me, this check can probably be skipped altogether. Unless the tool is refreshing the token on expiry or taking some other action. If it's expired, just let the operations fail with whatever error the AWS SDK throws.

RamanaReddy0M added a commit that referenced this issue Mar 8, 2023
- Move session logic to aws/config.go
@RamanaReddy0M RamanaReddy0M linked a pull request Mar 8, 2023 that will close this issue
@RamanaReddy0M RamanaReddy0M self-assigned this Mar 8, 2023
@golgotow
Copy link

golgotow commented Mar 8, 2023

Hi,

installed on Linux mint and getting error like below

cloudlens 
Credentials have expired
panic: aws session init failed -- AWS Credentials expired

goroutine 1 [running]:
github.com/one2nc/cloudlens/cmd.run(0x16ede00?, {0xe25ef7?, 0x0?, 0x0?})
	github.com/one2nc/cloudlens/cmd/root.go:73 +0x4ce
github.com/spf13/cobra.(*Command).execute(0x16ede00, {0xc000034240, 0x0, 0x0})
	github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x16ede00)
	github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.6.1/command.go:968
github.com/one2nc/cloudlens/cmd.Execute()
	github.com/one2nc/cloudlens/cmd/root.go:42 +0x25
main.main()
	github.com/one2nc/cloudlens/main.go:8 +0x17

aws command normally work fine for me

Br,

@marcusschiesser
Copy link

I run into the same issue using aws-mfa with --assume-role to authenticate with AWS. I tested with v0.1.0.

Here's the output:

Credentials have expired
panic: aws session init failed -- AWS Credentials expired

goroutine 1 [running]:
github.com/one2nc/cloudlens/cmd.run(0x123dda0?, {0x970b5a?, 0x0?, 0x0?})
        github.com/one2nc/cloudlens/cmd/root.go:73 +0x4d0
github.com/spf13/cobra.(*Command).execute(0x123dda0, {0x400009e220, 0x0, 0x0})
        github.com/spf13/cobra@v1.6.1/command.go:920 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x123dda0)
        github.com/spf13/cobra@v1.6.1/command.go:1044 +0x368
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.6.1/command.go:968
github.com/one2nc/cloudlens/cmd.Execute()
        github.com/one2nc/cloudlens/cmd/root.go:42 +0x28
main.main()
        github.com/one2nc/cloudlens/main.go:8 +0x1c

chinmay185 added a commit that referenced this issue Mar 9, 2023
@chinmay185
Copy link
Contributor

#4 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants