class Terraforming::Resource::Route53Zone
Public Class Methods
new(client)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 14 def initialize(client) @client = client end
tf(client: Aws::Route53::Client.new)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 6 def self.tf(client: Aws::Route53::Client.new) self.new(client).tf end
tfstate(client: Aws::Route53::Client.new)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 10 def self.tfstate(client: Aws::Route53::Client.new) self.new(client).tfstate end
Public Instance Methods
tf()
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 18 def tf apply_template(@client, "tf/route53_zone") end
tfstate()
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 22 def tfstate hosted_zones.inject({}) do |resources, hosted_zone| zone_id = zone_id_of(hosted_zone) vpc = vpc_of(hosted_zone) attributes = { "comment" => comment_of(hosted_zone), "id" => zone_id, "name" => name_of(hosted_zone), "name_servers.#" => name_servers_of(hosted_zone).length.to_s, "tags.#" => tags_of(hosted_zone).length.to_s, "vpc_id" => vpc ? vpc.vpc_id : "", "vpc_region" => vpc ? vpc.vpc_region : "", "zone_id" => zone_id, } resources["aws_route53_zone.#{module_name_of(hosted_zone)}"] = { "type" => "aws_route53_zone", "primary" => { "id" => zone_id, "attributes" => attributes, } } resources end end
Private Instance Methods
comment_of(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 59 def comment_of(hosted_zone) hosted_zone.hosted_zone.config.comment end
hosted_zones()
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 51 def hosted_zones @client.list_hosted_zones.map(&:hosted_zones).flatten.map { |hosted_zone| @client.get_hosted_zone(id: hosted_zone.id) } end
module_name_of(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 72 def module_name_of(hosted_zone) normalize_module_name(name_of(hosted_zone)) << "-#{private_hosted_zone?(hosted_zone) ? 'private' : 'public'}" end
name_of(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 63 def name_of(hosted_zone) hosted_zone.hosted_zone.name.gsub(/\.\z/, "") end
name_servers_of(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 67 def name_servers_of(hosted_zone) delegation_set = hosted_zone.delegation_set delegation_set ? delegation_set.name_servers : [] end
private_hosted_zone?(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 76 def private_hosted_zone?(hosted_zone) hosted_zone.hosted_zone.config.private_zone end
vpc_of(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 80 def vpc_of(hosted_zone) hosted_zone.vp_cs[0] end
zone_id_of(hosted_zone)
click to toggle source
# File lib/terraforming/resource/route53_zone.rb, line 84 def zone_id_of(hosted_zone) hosted_zone.hosted_zone.id.gsub(%r{\A/hostedzone/}, "") end