Class: Terraforming::Resource::RouteTableAssociation

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/terraforming/resource/route_table_association.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) ⇒ RouteTableAssociation

Returns a new instance of RouteTableAssociation.



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

def initialize(client)
  @client = client
end

Class Method Details

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



6
7
8
# File 'lib/terraforming/resource/route_table_association.rb', line 6

def self.tf(client: Aws::EC2::Client.new)
  self.new(client).tf
end

.tfstate(client: Aws::EC2::Client.new) ⇒ Object



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

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

Instance Method Details

#tfObject



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

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

#tfstateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/terraforming/resource/route_table_association.rb', line 22

def tfstate
  resources = {}
  route_tables.each do |route_table|
    associations_of(route_table).each do |assoc|
      attributes = {
        "id" => assoc.route_table_association_id,
        "route_table_id" => assoc.route_table_id,
        "subnet_id" => assoc.subnet_id,
      }

      resources["aws_route_table_association.#{module_name_of(route_table, assoc)}"] = {
        "type" => "aws_route_table_association",
        "primary" => {
          "id" => assoc.route_table_association_id,
          "attributes" => attributes
        }
      }
    end
  end
  resources
end