class GeoEngineer::Resources::AwsElasticacheCluster

AwsElasticacheCluster is the aws_elasticache_cluster terrform resource,

{www.terraform.io/docs/providers/aws/r/elasticache_cluster.html Terraform Docs}

Public Class Methods

_fetch_remote_resources(provider) click to toggle source
# File lib/geoengineer/resources/aws_elasticache_cluster.rb, line 48
def self._fetch_remote_resources(provider)
  AwsClients
    .elasticache(provider)
    .describe_cache_clusters['cache_clusters']
    .map(&:to_h)
    .select { |ec| ec[:replication_group_id].nil? }
    .map do |ec|
    ec.merge(
      {
        _terraform_id: ec[:cache_cluster_id],
        _geo_id: ec[:cache_cluster_id]
      }
    )
  end
end

Public Instance Methods

short_type() click to toggle source
# File lib/geoengineer/resources/aws_elasticache_cluster.rb, line 44
def short_type
  "ec"
end
to_terraform_state() click to toggle source
# File lib/geoengineer/resources/aws_elasticache_cluster.rb, line 24
def to_terraform_state
  tfstate = super
  attributes = { 'port' => port.to_s, 'parameter_group_name' => parameter_group_name }

  # Security groups workaround
  security_group_ids.each_with_index do |sg, i|
    if sg.is_a?(GeoEngineer::Resource)
      attributes["security_group_ids.#{i}"] = sg._terraform_id
    elsif sg.is_a?(String)
      attributes["security_group_ids.#{i}"] = sg
    else
      raise SecurityGroupError, "Please pass a Geo Resource or string ID"
    end
  end
  attributes['security_group_ids.#'] = security_group_ids.count.to_s

  tfstate[:primary][:attributes] = attributes
  tfstate
end