class Terraforming::Resource::ElastiCacheSubnetGroup

Public Class Methods

new(client) click to toggle source
# File lib/terraforming/resource/elasti_cache_subnet_group.rb, line 14
def initialize(client)
  @client = client
end
tf(client: Aws::ElastiCache::Client.new) click to toggle source
# 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) click to toggle source
# File lib/terraforming/resource/elasti_cache_subnet_group.rb, line 10
def self.tfstate(client: Aws::ElastiCache::Client.new)
  self.new(client).tfstate
end

Public Instance Methods

tf() click to toggle source
# File lib/terraforming/resource/elasti_cache_subnet_group.rb, line 18
def tf
  apply_template(@client, "tf/elasti_cache_subnet_group")
end
tfstate() click to toggle source
# 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

Private Instance Methods

cache_subnet_groups() click to toggle source
# File lib/terraforming/resource/elasti_cache_subnet_group.rb, line 43
def cache_subnet_groups
  @client.describe_cache_subnet_groups.map(&:cache_subnet_groups).flatten
end
module_name_of(cache_subnet_group) click to toggle source
# File lib/terraforming/resource/elasti_cache_subnet_group.rb, line 51
def module_name_of(cache_subnet_group)
  normalize_module_name(cache_subnet_group.cache_subnet_group_name)
end
subnet_ids_of(cache_subnet_group) click to toggle source
# File lib/terraforming/resource/elasti_cache_subnet_group.rb, line 47
def subnet_ids_of(cache_subnet_group)
  cache_subnet_group.subnets.map { |sn| sn.subnet_identifier }
end