Class: Kitchen::Driver::Aws::StackGenerator
- Inherits:
-
Object
- Object
- Kitchen::Driver::Aws::StackGenerator
- Includes:
- Logging
- Defined in:
- lib/kitchen/driver/aws/stack_generator.rb
Overview
A class for encapsulating the stack payload logic
Instance Attribute Summary collapse
-
#cf ⇒ Object
readonly
Returns the value of attribute cf.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#cf_stack_data ⇒ Object
Transform the provided config into the hash to send to AWS.
-
#initialize(config, cf) ⇒ StackGenerator
constructor
A new instance of StackGenerator.
Constructor Details
#initialize(config, cf) ⇒ StackGenerator
Returns a new instance of StackGenerator.
28 29 30 31 |
# File 'lib/kitchen/driver/aws/stack_generator.rb', line 28 def initialize(config, cf) @config = config @cf = cf end |
Instance Attribute Details
#cf ⇒ Object (readonly)
Returns the value of attribute cf.
26 27 28 |
# File 'lib/kitchen/driver/aws/stack_generator.rb', line 26 def cf @cf end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
26 27 28 |
# File 'lib/kitchen/driver/aws/stack_generator.rb', line 26 def config @config end |
Instance Method Details
#cf_stack_data ⇒ Object
Transform the provided config into the hash to send to AWS. Some fields can be passed in null, others need to be ommitted if they are null
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kitchen/driver/aws/stack_generator.rb', line 35 def cf_stack_data s = { stack_name: config[:stack_name] } s[:template_url] = config[:template_url] if config[:template_file].nil? if config[:template_file] s[:template_body] = File.open(config[:template_file], 'rb') { |file| file.read } end s[:capabilities] = config[:capabilities] if !config[:capabilities].nil? && (config[:capabilities].is_a? Array) && !config[:capabilities].empty? s[:timeout_in_minutes] = config[:timeout_in_minutes] if !config[:timeout_in_minutes].nil? && config[:timeout_in_minutes] > 0 s[:disable_rollback] = config[:disable_rollback] if !config[:disable_rollback].nil? && config[:disable_rollback] == true || config[:disable_rollback] == false s[:parameters] = [] config[:parameters].each do |k, v| s[:parameters].push(parameter_key: k.to_s, parameter_value: v.to_s) end s[:notification_arns] = config[:notification_arns] if !config[:notification_arns].nil? && (config[:notification_arns].is_a? Array) && !config[:notification_arns].empty? s[:resource_types] = config[:resource_types] if !config[:resource_types].nil? && (config[:resource_types].is_a? Array) && !config[:resource_types].empty? s[:role_arn] = config[:role_arn] unless config[:role_arn].nil? s[:on_failure] = config[:on_failure] unless config[:on_failure].nil? # accepts DO_NOTHING, ROLLBACK, DELETE s[:stack_policy_body] = config[:stack_policy_body] unless config[:stack_policy_body].nil? s[:stack_policy_url] = config[:stack_policy_url] unless config[:stack_policy_url].nil? s[:tags] = [] config[:tags].each do |k, v| s[:tags].push(key: k.to_s, value: v.to_s) end s end |