Class: Terraforming::Resource::DBSubnetGroup

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

Returns a new instance of DBSubnetGroup.



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

def initialize(client)
  @client = client
end

Class Method Details

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



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

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

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



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

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

Instance Method Details

#tfObject



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

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

#tfstateObject



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

def tfstate
  db_subnet_groups.inject({}) do |resources, subnet_group|
    attributes = {
      "description" => subnet_group.db_subnet_group_description,
      "name" => subnet_group.db_subnet_group_name,
      "subnet_ids.#" => subnet_group.subnets.length.to_s
    }
    resources["aws_db_subnet_group.#{module_name_of(subnet_group)}"] = {
      "type" => "aws_db_subnet_group",
      "primary" => {
        "id" => subnet_group.db_subnet_group_name,
        "attributes" => attributes
      }
    }

    resources
  end
end