Class: Aws::AssumeRoleWebIdentityCredentials
- Inherits:
-
Object
- Object
- Aws::AssumeRoleWebIdentityCredentials
- Includes:
- CredentialProvider, RefreshingCredentials
- Defined in:
- lib/aws-sdk-core/assume_role_web_identity_credentials.rb
Overview
An auto-refreshing credential provider that assumes a role via STS::Client#assume_role_with_web_identity.
role_credentials = Aws::AssumeRoleWebIdentityCredentials.new(
client: Aws::STS::Client.new(...),
role_arn: "linked::account::arn",
web_identity_token_file: "/path/to/token/file",
role_session_name: "session-name"
...
)
ec2 = Aws::EC2::Client.new(credentials: role_credentials)
If you omit ‘:client` option, a new STS::Client object will be constructed with additional options that were provided.
Constant Summary
Constants included from RefreshingCredentials
RefreshingCredentials::ASYNC_EXPIRATION_LENGTH, RefreshingCredentials::CLIENT_EXCLUDE_OPTIONS, RefreshingCredentials::SYNC_EXPIRATION_LENGTH
Instance Attribute Summary collapse
- #client ⇒ STS::Client readonly
Attributes included from CredentialProvider
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ AssumeRoleWebIdentityCredentials
constructor
A new instance of AssumeRoleWebIdentityCredentials.
Methods included from RefreshingCredentials
Methods included from CredentialProvider
Constructor Details
#initialize(options = {}) ⇒ AssumeRoleWebIdentityCredentials
Returns a new instance of AssumeRoleWebIdentityCredentials.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aws-sdk-core/assume_role_web_identity_credentials.rb', line 46 def initialize( = {}) client_opts = {} @assume_role_web_identity_params = {} @token_file = .delete(:web_identity_token_file) @async_refresh = true .each_pair do |key, value| if self.class..include?(key) @assume_role_web_identity_params[key] = value elsif !CLIENT_EXCLUDE_OPTIONS.include?(key) client_opts[key] = value end end unless @assume_role_web_identity_params[:role_session_name] # not provided, generate encoded UUID as session name @assume_role_web_identity_params[:role_session_name] = _session_name end @client = client_opts[:client] || STS::Client.new(client_opts.merge(credentials: nil)) super end |
Instance Attribute Details
#client ⇒ STS::Client (readonly)
68 69 70 |
# File 'lib/aws-sdk-core/assume_role_web_identity_credentials.rb', line 68 def client @client end |
Class Method Details
.assume_role_web_identity_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
106 107 108 109 110 111 |
# File 'lib/aws-sdk-core/assume_role_web_identity_credentials.rb', line 106 def @arwio ||= begin input = Aws::STS::Client.api.operation(:assume_role_with_web_identity).input Set.new(input.shape.member_names) end end |