Class: Kybus::AWS::Resource
- Inherits:
-
Object
- Object
- Kybus::AWS::Resource
- Defined in:
- lib/kybus/aws/resource.rb
Instance Attribute Summary collapse
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
- #account_id ⇒ Object
-
#initialize(config) ⇒ Resource
constructor
A new instance of Resource.
- #with_retries(exception, max_retries = 5) ⇒ Object
Constructor Details
#initialize(config) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 |
# File 'lib/kybus/aws/resource.rb', line 8 def initialize(config) @config = config @region = @config['region'] || 'us-east-1' end |
Instance Attribute Details
#region ⇒ Object (readonly)
Returns the value of attribute region.
6 7 8 |
# File 'lib/kybus/aws/resource.rb', line 6 def region @region end |
Instance Method Details
#account_id ⇒ Object
13 14 15 |
# File 'lib/kybus/aws/resource.rb', line 13 def account_id @config['account_id'] end |
#with_retries(exception, max_retries = 5) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kybus/aws/resource.rb', line 17 def with_retries(exception, max_retries = 5) retry_count = 0 begin yield rescue exception retry_count += 1 unless retry_count <= max_retries raise "Failed to apply #{self.class} after #{max_retries} attempts due to ongoing updates." end sleep_time = 2**retry_count puts "Update in progress, retrying in #{sleep_time} seconds..." sleep(sleep_time) retry end end |