Class: Terraforming::Resource::Route53Zone

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/terraforming/resource/route53_zone.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#apply_template, #name_from_tag, #normalize_module_name, #prettify_policy, #template_path

Constructor Details

#initialize(client) ⇒ Route53Zone

Returns a new instance of Route53Zone.



14
15
16
# File 'lib/terraforming/resource/route53_zone.rb', line 14

def initialize(client)
  @client = client
end

Class Method Details

.tf(client: Aws::Route53::Client.new) ⇒ Object



6
7
8
# 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) ⇒ Object



10
11
12
# File 'lib/terraforming/resource/route53_zone.rb', line 10

def self.tfstate(client: Aws::Route53::Client.new)
  self.new(client).tfstate
end

Instance Method Details

#tfObject



18
19
20
# File 'lib/terraforming/resource/route53_zone.rb', line 18

def tf
  apply_template(@client, "tf/route53_zone")
end

#tfstateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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