Class: Awssume::Configuration
- Inherits:
-
Object
- Object
- Awssume::Configuration
- Defined in:
- lib/awssume/configuration.rb
Overview
A class for managing the properties needed for assuming a role
Class Method Summary collapse
- .attrs ⇒ Object
- .default_session_name ⇒ Object
-
.defaults ⇒ Object
Defaults must have a value: a value passed in or a hardcoded default The utility will exit with an error if a value is missing for a default.
-
.options ⇒ Object
Options are not required to have a value The utility will function without issue if an optional value is missing.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
33 34 35 36 37 38 |
# File 'lib/awssume/configuration.rb', line 33 def initialize(opts = {}) attrs.each do |k, _| attr_val = validate_attrs(attrs.merge(opts), k) instance_variable_set("@#{k}", attr_val) end end |
Class Method Details
.attrs ⇒ Object
27 28 29 |
# File 'lib/awssume/configuration.rb', line 27 def self.attrs self.defaults.merge(self.) end |
.default_session_name ⇒ Object
4 5 6 |
# File 'lib/awssume/configuration.rb', line 4 def self.default_session_name "AwssumedSession#{Time.new.to_i}" end |
.defaults ⇒ Object
Defaults must have a value: a value passed in or a hardcoded default The utility will exit with an error if a value is missing for a default
10 11 12 13 14 15 16 |
# File 'lib/awssume/configuration.rb', line 10 def self.defaults { region: ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION'], role_arn: ENV['AWS_ROLE_ARN'], role_session_name: ENV['AWS_ROLE_SESSION_NAME'] || default_session_name, } end |
.options ⇒ Object
Options are not required to have a value The utility will function without issue if an optional value is missing
20 21 22 23 24 25 |
# File 'lib/awssume/configuration.rb', line 20 def self. { external_id: ENV['AWS_ROLE_EXTERNAL_ID'], duration_seconds: ENV['AWS_ROLE_DURATION_SECONDS'].to_i } end |