class Convection::Model::Template::Resource::Route53RecordSet

AWS::EC2::Instance

Constants

TF_ACTUAL_RESOURCE_NAME
TF_ASSUMED_RESOURCE_NAME

Public Instance Methods

alias_target(tgt = nil, &block) click to toggle source
# File lib/convection/model/template/resource/aws_route53_recordset.rb, line 32
def alias_target(tgt = nil, &block)
  if tgt
    # Maintain backwards compatability
    alias_tgt tgt
  else
    # Add new resource_property functionality
    a = ResourceProperty::Route53AliasTarget.new(self)
    a.instance_exec(&block) if block
    properties['AliasTarget'].set(a)
  end
end
geo_location(geo = nil, &block) click to toggle source
# File lib/convection/model/template/resource/aws_route53_recordset.rb, line 44
def geo_location(geo = nil, &block)
  if geo
    # Maintain backwards compatability
    geo_loc geo
  else
    # Add new resource_property functionality
    g = ResourceProperty::Route53GeoLocation.new(self)
    g.instance_exec(&block) if block
    properties['GeoLocation'].set(g)
  end
end
terraform_import_commands(module_path: 'root') click to toggle source
# File lib/convection/model/template/resource/aws_route53_recordset.rb, line 56
def terraform_import_commands(module_path: 'root')
  commands = []
  commands << '# Import the Route53 record:'
  tf_set_id = "_#{set_identifier}" if set_identifier
  prefix = "#{module_path}." unless module_path == 'root'
  tf_record_name = record_name.sub(/\.$/, '')
  commands << "terraform import #{prefix}aws_route53_record.#{name.underscore} #{hosted_zone_id}_#{tf_record_name}_#{record_type}#{tf_set_id}"

  commands.map { |cmd| cmd.gsub(stack.region, stack._original_region).gsub(stack.cloud, stack._original_cloud) }
end
to_hcl_json(*) click to toggle source
# File lib/convection/model/template/resource/aws_route53_recordset.rb, line 67
def to_hcl_json(*)
  tf_record_attrs = {
    zone_id: hosted_zone_id,
    name: record_name,
    type: record_type,
    ttl: ttl,
    records: tf_records,
    set_identifier: set_identifier
  }
  tf_record_attrs.reject! { |_k, v| v.nil? }

  tf_record = {
    aws_route53_record: {
      name.underscore => tf_record_attrs
    }
  }

  { resource: [tf_record] }.to_json
end

Private Instance Methods

tf_records() click to toggle source
# File lib/convection/model/template/resource/aws_route53_recordset.rb, line 89
def tf_records
  record.map { |r| r.gsub(TF_ASSUMED_RESOURCE_NAME, TF_ACTUAL_RESOURCE_NAME) }
end