Module: AwsCftTools::Template::Properties
- Included in:
- AwsCftTools::Template
- Defined in:
- lib/aws_cft_tools/template/properties.rb
Overview
Simple properties of templates.
Instance Method Summary collapse
-
#allowed_environments ⇒ Array<String>
Returns the list of environments allowed for the
Environment
parameter. -
#allowed_regions ⇒ Array<String>
Returns the list of regions in which the template is allowed.
-
#default_parameters ⇒ Object
Returns the parameter defaults for the template.
- #environment?(value) ⇒ Boolean
-
#inputs ⇒ Array<String>
lists the imports expected by the template.
-
#outputs ⇒ Array<String>
lists the exported values from the template.
- #region?(region) ⇒ Boolean
-
#role ⇒ String
Returns the role of the template as specified in the template metadata.
- #role?(value) ⇒ Boolean
-
#template_dependencies ⇒ Object
Returns any templates on which this template has an explicit dependency.
Instance Method Details
#allowed_environments ⇒ Array<String>
Returns the list of environments allowed for the Environment
parameter.
14 15 16 |
# File 'lib/aws_cft_tools/template/properties.rb', line 14 def allowed_environments template.dig('Parameters', 'Environment', 'AllowedValues') || [] end |
#allowed_regions ⇒ Array<String>
The region in which a template is deployed is available as the AWS::Region
pseudo-parameter.
Returns the list of regions in which the template is allowed.
51 52 53 |
# File 'lib/aws_cft_tools/template/properties.rb', line 51 def allowed_regions template.dig('Metadata', 'Region') || [] end |
#default_parameters ⇒ Object
Returns the parameter defaults for the template.
25 26 27 28 29 |
# File 'lib/aws_cft_tools/template/properties.rb', line 25 def default_parameters (template['Parameters'] || []).each_with_object({}) do |param, hash| hash[param.first] = param.last['Default'] end end |
#environment?(value) ⇒ Boolean
18 19 20 |
# File 'lib/aws_cft_tools/template/properties.rb', line 18 def environment?(value) allowed_environments.include?(value) end |
#inputs ⇒ Array<String>
lists the imports expected by the template
Note that this does substitutions of any references to template parameters.
88 89 90 91 92 93 94 |
# File 'lib/aws_cft_tools/template/properties.rb', line 88 def inputs (template['Resources'] || {}) .values .flat_map { |resource| pull_imports(resource['Properties'] || {}) } .uniq .map(&method(:with_substitutions)) end |
#outputs ⇒ Array<String>
lists the exported values from the template
Note that this does substitutions of any references to template parameters.
75 76 77 78 79 |
# File 'lib/aws_cft_tools/template/properties.rb', line 75 def outputs (template['Outputs'] || []).map do |_, output| with_substitutions(output_name(output.dig('Export', 'Name'))) end end |
#region?(region) ⇒ Boolean
55 56 57 |
# File 'lib/aws_cft_tools/template/properties.rb', line 55 def region?(region) !region || allowed_regions.empty? || allowed_regions.include?(region) end |
#role ⇒ String
Returns the role of the template as specified in the template metadata.
36 37 38 |
# File 'lib/aws_cft_tools/template/properties.rb', line 36 def role template.dig('Metadata', 'Role') end |
#role?(value) ⇒ Boolean
40 41 42 |
# File 'lib/aws_cft_tools/template/properties.rb', line 40 def role?(value) !value || role == value end |
#template_dependencies ⇒ Object
Returns any templates on which this template has an explicit dependency.
These explicit dependencies are combined with any dependencies implied by imported values.
64 65 66 |
# File 'lib/aws_cft_tools/template/properties.rb', line 64 def template_dependencies template.dig('Metadata', 'DependsOn', 'Templates') || [] end |