Module: SparkleFormation::SparkleAttribute::Terraform
- Included in:
- SparkleFormation::SparkleStruct::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
121 122 123 124 125 126 127 128 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 121 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
139 140 141 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 139 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
101 102 103 104 105 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 101 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!
31 32 33 34 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 31 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!
24 25 26 27 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 24 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
52 53 54 55 56 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 52 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
150 151 152 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 150 def _stack_output(stack_name, output_name) _module(stack_name)._set(output_name) end |
#_terraform_lookup(*args) ⇒ Object Also known as: lookup!
45 46 47 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 45 def _terraform_lookup(*args) ::SparkleFormation::TerraformStruct.new('lookup', *args) end |
#_terraform_self(s_name) ⇒ Object Also known as: self!
38 39 40 41 |
# File 'lib/sparkle_formation/sparkle_attribute/terraform.rb', line 38 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 |