Module: SparkleFormation::SparkleAttribute::Terraform
- Defined in:
- lib/sparkle_formation/sparkle_attribute/terraform.rb
Overview
Terraform specific helper implementations
Constant Summary collapse
- TERRAFORM_INTRINSIC_FUNCTIONS =
[ 'base64decode', 'base64encode', 'base64sha256', 'cidrhost', 'cidrnetmask', 'cidrsubnet', 'coalesce', 'compact', 'concat', 'distinct', 'element', 'file', 'format', 'formatlist', 'index', 'join', 'jsonencode', 'length', 'list', 'lower', 'map', 'md5', 'merge', 'uuid', 'replace', 'sha1', 'sha256', 'signum', 'sort', 'split', 'trimspace', 'upper' ]
Class Method Summary collapse
-
.included(klass) ⇒ Object
Set customized struct behavior.
Instance Method Summary collapse
- #__resource_lookup(name) ⇒ Object
-
#_depends_on(*args) ⇒ Array<String>
(also: #depends_on!)
Resource dependency generator.
-
#_fn_format(*args) ⇒ SparkleFormation::FunctionStruct
Generate a builtin terraform function.
- #_module(m_name) ⇒ Object (also: #module!)
- #_path(p_name) ⇒ Object (also: #path!)
-
#_resource(r_name) ⇒ Object
(also: #resource!)
TODO: Add resource checking before returning structure.
-
#_stack_output(stack_name, output_name) ⇒ Hash
(also: #stack_output!)
Reference output value from nested stack.
- #_terraform_lookup(*args) ⇒ Object (also: #lookup!)
- #_terraform_self(s_name) ⇒ Object (also: #self!)
- #_var(v_name) ⇒ Object (also: #var!, #parameter!)
Class Method Details
.included(klass) ⇒ Object
Set customized struct behavior
12 13 14 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 12 def self.included(klass) klass.const_set(:CAMEL_KEYS, false) end |
Instance Method Details
#__resource_lookup(name) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 115 def __resource_lookup(name) resource = root!.resources[name] if(resource.nil?) name else "#{resource.type}.#{name}" end end |
#_depends_on(resource_name) ⇒ Array<String> #_depends_on(resource_names) ⇒ Array<String> #_depends_on(*resource_names) ⇒ Array<String> Also known as: depends_on!
Note:
this will directly modify the struct at its current context to inject depends on structure
Resource dependency generator
133 134 135 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 133 def _depends_on(*args) _set('depends_on', [args].flatten.compact.map{|s| __attribute_key(s) }) end |
#_fn_format(*args) ⇒ SparkleFormation::FunctionStruct
Generate a builtin terraform function
95 96 97 98 99 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 95 def _fn_format(*args) src = ::Kernel.__callee__.to_s src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/, ''), false) ::SparkleFormation::TerraformStruct.new(src, *args) end |
#_module(m_name) ⇒ Object Also known as: module!
29 30 31 32 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 29 def _module(m_name) __t_stringish(m_name) ::SparkleFormation::TerraformStruct.new('module').set!(__attribute_key(m_name)) end |
#_path(p_name) ⇒ Object Also known as: path!
23 24 25 26 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 23 def _path(p_name) __t_stringish(p_name) ::SparkleFormation::TerraformStruct.new('path').set!(__attribute_key(p_name)) end |
#_resource(r_name) ⇒ Object Also known as: resource!
TODO: Add resource checking before returning structure
47 48 49 50 51 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 47 def _resource(r_name) __t_stringish(r_name) r_name = __resource_lookup(r_name) ::SparkleFormation::TerraformStruct.new(r_name) end |
#_stack_output(stack_name, output_name) ⇒ Hash Also known as: stack_output!
Reference output value from nested stack
143 144 145 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 143 def _stack_output(stack_name, output_name) _module(stack_name)._set(output_name) end |
#_terraform_lookup(*args) ⇒ Object Also known as: lookup!
41 42 43 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 41 def _terraform_lookup(*args) ::SparkleFormation::TerraformStruct.new('lookup', *args) end |
#_terraform_self(s_name) ⇒ Object Also known as: self!
35 36 37 38 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 35 def _terraform_self(s_name) __t_stringish(s_name) ::SparkleFormation::TerraformStruct.new('self').set!(__attribute_key(s_name)) end |
#_var(v_name) ⇒ Object Also known as: var!, parameter!
16 17 18 19 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 16 def _var(v_name) __t_stringish(v_name) res = ::SparkleFormation::TerraformStruct.new('var').set!(__attribute_key(v_name)) end |