class GeoEngineer::SubResource
SubResources are included in resources with their own rules
For example, ingress
in aws_security_group
is a subresource.
A SubResource
can have arbitrary attributes
Attributes
type[R]
Public Class Methods
new(resource, type, &block)
click to toggle source
# File lib/geoengineer/sub_resource.rb, line 14 def initialize(resource, type, &block) @resource = resource @type = type.to_s instance_exec(self, &block) if block_given? end
Public Instance Methods
_terraform_id()
click to toggle source
# File lib/geoengineer/sub_resource.rb, line 20 def _terraform_id @resource._terraform_id end
to_terraform()
click to toggle source
Terraform methods
# File lib/geoengineer/sub_resource.rb, line 25 def to_terraform sb = [" #{@type} { "] sb.concat terraform_attributes.map { |k, v| " #{k.to_s.inspect} = #{v.inspect}" } sb.concat subresources.map(&:to_terraform) sb << " }" sb.join("\n") end
to_terraform_json()
click to toggle source
# File lib/geoengineer/sub_resource.rb, line 37 def to_terraform_json json = terraform_attributes subresources.map(&:to_terraform_json).each do |k, v| json[k] ||= [] json[k] << v end [@type, json] end