Class: AwsAssumeRole::Credentials::Factories::AssumeRole
- Inherits:
-
AbstractFactory
- Object
- AbstractFactory
- AwsAssumeRole::Credentials::Factories::AssumeRole
- Includes:
- AwsAssumeRole::Credentials::Factories
- Defined in:
- lib/aws_assume_role/credentials/factories/assume_role.rb
Constant Summary
Constants included from AwsAssumeRole::Credentials::Factories
Constants included from AwsAssumeRole
AwsAssumeRole::Config, DefaultProvider, VERSION
Instance Attribute Summary
Attributes inherited from AbstractFactory
#credentials, #profile, #region, #role_arn
Instance Method Summary collapse
- #assume_role_with_profile(prof, region) ⇒ Object
-
#initialize(options) ⇒ AssumeRole
constructor
A new instance of AssumeRole.
- #try_with_profile(options) ⇒ Object
Methods included from Logging
Methods included from AwsAssumeRole
Methods inherited from AbstractFactory
priority, register_if_complete, type
Constructor Details
#initialize(options) ⇒ AssumeRole
Returns a new instance of AssumeRole.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/aws_assume_role/credentials/factories/assume_role.rb', line 10 def initialize() if [:profile] try_with_profile() else if [:use_mfa] [:credentials] = AwsAssumeRole::Credentials::Providers::MfaSessionCredentials.new().credentials end @credentials = AwsAssumeRole::Credentials::Providers::AssumeRoleCredentials.new() end end |
Instance Method Details
#assume_role_with_profile(prof, region) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/aws_assume_role/credentials/factories/assume_role.rb', line 32 def assume_role_with_profile(prof, region) AwsAssumeRole.shared_config.assume_role_credentials_from_config( profile: prof, region: region, ) end |
#try_with_profile(options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aws_assume_role/credentials/factories/assume_role.rb', line 21 def try_with_profile() if AwsAssumeRole.shared_config.config_enabled? @profile = [:profile] @region = [:region] @credentials = assume_role_with_profile([:profle], [:region]) end @credentials = assume_role_with_profile(@profile, @region) @region ||= AwsAssumeRole.shared_config.profile_region(@profiles) @role_arn ||= AwsAssumeRole.shared_config.profile_role(@profile) end |