Class: Terraforming::Resource::ElastiCacheSubnetGroup

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

Returns a new instance of ElastiCacheSubnetGroup.



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

def initialize(client)
  @client = client
end

Class Method Details

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



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

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

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



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

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

Instance Method Details

#tfObject



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

def tf
  apply_template(@client, "tf/elasti_cache_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/elasti_cache_subnet_group.rb', line 22

def tfstate
  cache_subnet_groups.inject({}) do |resources, cache_subnet_group|
    attributes = {
      "description" => cache_subnet_group.cache_subnet_group_description,
      "name" => cache_subnet_group.cache_subnet_group_name,
      "subnet_ids.#" => subnet_ids_of(cache_subnet_group).length.to_s,
    }
    resources["aws_elasticache_subnet_group.#{module_name_of(cache_subnet_group)}"] = {
      "type" => "aws_elasticache_subnet_group",
      "primary" => {
        "id" => cache_subnet_group.cache_subnet_group_name,
        "attributes" => attributes
      }
    }

    resources
  end
end