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

SDK fails to use SSO credentials configured via aws configure sso #2894

Closed
guss77 opened this issue Aug 9, 2023 · 2 comments · Fixed by #2895
Closed

SDK fails to use SSO credentials configured via aws configure sso #2894

guss77 opened this issue Aug 9, 2023 · 2 comments · Fixed by #2895
Assignees
Labels
bug This issue is a bug.

Comments

@guss77
Copy link

guss77 commented Aug 9, 2023

Describe the bug

After configuring a profile using aws configure sso --profile PROFILENAME, the aws CLI tool can use the configured profile using aws --profile PROFILENAME without trouble (all commands that I've tried work), but the AWS SDK for Ruby fails with an error, when trying to configure it with that profile.

Expected Behavior

Setting the named profile through the Aws.config options should work for SSO profile as well as it does for static profiles:

$ irb -r aws-sdk-ec2
irb(main):001:0> Aws::EC2::Client.new({profile: 'PROFILENAME'})
=> #<Aws::EC2::Client>

Current Behavior

Trying to initialize an AWS client with an SSO profile, we get an error: sso-session My Profile must be defined in the config file. Referenced by profile PROFILENAME (ArgumentError)

$ irb -r aws-sdk-ec2
irb(main):001:0> Aws::EC2::Client.new({profile: 'PROFILENAME'})
/home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/shared_config.rb:364:in `sso_credentials_from_profile': sso-session My Profile must be defined in the config file. Referenced by profile PROFILENAME (ArgumentError)                                                             
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/shared_config.rb:153:in `sso_credentials_from_config'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/credential_provider_chain.rb:64:in `static_profile_sso_credentials'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/credential_provider_chain.rb:13:in `block in resolve'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/credential_provider_chain.rb:12:in `each'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/credential_provider_chain.rb:12:in `resolve'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/aws-sdk-core/plugins/credentials_configuration.rb:72:in `block in <class:CredentialsConfiguration>'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:72:in `call'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:215:in `block in resolve_defaults'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:59:in `each'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:59:in `each'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:214:in `resolve_defaults'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:207:in `value_at'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:191:in `block in resolve'
        from /usr/lib/ruby/3.1.0/set.rb:511:in `each_key'
        from /usr/lib/ruby/3.1.0/set.rb:511:in `each'
        from /home/odeda/.local/share/gem/ruby/3.1.0/gems/aws-sdk-core-3.180.0/lib/seahorse/client/configuration.rb:191:in `resolve'
        ... 10 levels...

Reproduction Steps

$ irb -r aws-sdk-ec2
irb(main):001:0> Aws::EC2::Client.new({profile: 'PROFILENAME'})

Possible Solution

I have yet to find a fix for this. From reviewing the lib/aws-sdk-core/shared_config.rb file, I don't understand how SSO credentials are properly initialized, but it seems to be only when trying to "assume a role" (which I'm not sure when is that workflow triggered).

Additional Information/Context

No response

Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version

aws-sdk-core

Environment details (Version of Ruby, OS environment)

Ruby 3.1.0 on Ubuntu Lunar

@guss77 guss77 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 9, 2023
@alextwoods alextwoods self-assigned this Aug 9, 2023
@alextwoods alextwoods added investigating Issue is being investigated and removed needs-triage This issue or PR still needs to be triaged. labels Aug 9, 2023
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@guss77
Copy link
Author

guss77 commented Aug 9, 2023

Thank you - that indeed solves the issue I'm having

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants