Class: Humidifier::Reservoir::Stack
- Inherits:
-
Object
- Object
- Humidifier::Reservoir::Stack
- Defined in:
- lib/humidifier/reservoir/stack.rb
Overview
Represents a CloudFormation stack. This contains all of the logic for interfacing with humidifier to deploy stacks, validate them, and display them.
Defined Under Namespace
Classes: Export
Instance Attribute Summary collapse
-
#exports ⇒ Object
readonly
Returns the value of attribute exports.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #create_change_set ⇒ Object
- #deploy(wait = false) ⇒ Object
-
#initialize(name, pattern: nil, prefix: nil) ⇒ Stack
constructor
A new instance of Stack.
- #resources ⇒ Object
- #stack_name ⇒ Object
- #to_cf ⇒ Object
- #upload ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(name, pattern: nil, prefix: nil) ⇒ Stack
Returns a new instance of Stack
22 23 24 25 26 27 |
# File 'lib/humidifier/reservoir/stack.rb', line 22 def initialize(name, pattern: nil, prefix: nil) @name = name @pattern = pattern @prefix = prefix @exports = [] end |
Instance Attribute Details
#exports ⇒ Object (readonly)
Returns the value of attribute exports
20 21 22 |
# File 'lib/humidifier/reservoir/stack.rb', line 20 def exports @exports end |
#name ⇒ Object (readonly)
Returns the value of attribute name
20 21 22 |
# File 'lib/humidifier/reservoir/stack.rb', line 20 def name @name end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern
20 21 22 |
# File 'lib/humidifier/reservoir/stack.rb', line 20 def pattern @pattern end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix
20 21 22 |
# File 'lib/humidifier/reservoir/stack.rb', line 20 def prefix @prefix end |
Instance Method Details
#create_change_set ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/humidifier/reservoir/stack.rb', line 29 def create_change_set return unless ensure_resources valid? opts = { capabilities: %w[CAPABILITY_IAM CAPABILITY_NAMED_IAM] } humidifier_stack.create_change_set(opts) end |
#deploy(wait = false) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/humidifier/reservoir/stack.rb', line 37 def deploy(wait = false) return unless ensure_resources valid? opts = { capabilities: %w[CAPABILITY_IAM CAPABILITY_NAMED_IAM] } humidifier_stack.public_send(wait ? :deploy_and_wait : :deploy, opts) end |
#resources ⇒ Object
45 46 47 48 49 |
# File 'lib/humidifier/reservoir/stack.rb', line 45 def resources Reservoir.files_for(name).each_with_object({}) do |filepath, resources| resources.merge!(parse(filepath, File.basename(filepath, '.yml'))) end end |
#stack_name ⇒ Object
51 52 53 |
# File 'lib/humidifier/reservoir/stack.rb', line 51 def stack_name @stack_name ||= "#{prefix || Reservoir.stack_prefix}#{name}" end |
#to_cf ⇒ Object
55 56 57 |
# File 'lib/humidifier/reservoir/stack.rb', line 55 def to_cf humidifier_stack.to_cf end |
#upload ⇒ Object
59 60 61 |
# File 'lib/humidifier/reservoir/stack.rb', line 59 def upload humidifier_stack.upload end |
#valid? ⇒ Boolean
63 64 65 66 67 68 69 70 71 |
# File 'lib/humidifier/reservoir/stack.rb', line 63 def valid? humidifier_stack.valid? rescue Aws::CloudFormation::Errors::AccessDenied raise Error, <<~MSG The authenticated AWS profile does not have the requisite permissions to run this command. Ensure the profile has cloudformation:ValidateTemplate. MSG end |