Class: Terraforming::Resource::ElastiCacheCluster
- Inherits:
-
Object
- Object
- Terraforming::Resource::ElastiCacheCluster
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/elasti_cache_cluster.rb
Class Method Summary collapse
- .tf(client: Aws::ElastiCache::Client.new) ⇒ Object
- .tfstate(client: Aws::ElastiCache::Client.new) ⇒ Object
Instance Method Summary collapse
-
#initialize(client) ⇒ ElastiCacheCluster
constructor
A new instance of ElastiCacheCluster.
- #tf ⇒ Object
- #tfstate ⇒ Object
Methods included from Util
#apply_template, #name_from_tag, #normalize_module_name, #prettify_policy, #template_path
Constructor Details
#initialize(client) ⇒ ElastiCacheCluster
Returns a new instance of ElastiCacheCluster.
14 15 16 |
# File 'lib/terraforming/resource/elasti_cache_cluster.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_cluster.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_cluster.rb', line 10 def self.tfstate(client: Aws::ElastiCache::Client.new) self.new(client).tfstate end |
Instance Method Details
#tf ⇒ Object
18 19 20 |
# File 'lib/terraforming/resource/elasti_cache_cluster.rb', line 18 def tf apply_template(@client, "tf/elasti_cache_cluster") end |
#tfstate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/terraforming/resource/elasti_cache_cluster.rb', line 22 def tfstate cache_clusters.inject({}) do |resources, cache_cluster| attributes = { "cache_nodes.#" => cache_cluster.cache_nodes.length.to_s, "cluster_id" => cache_cluster.cache_cluster_id, "engine" => cache_cluster.engine, "engine_version" => cache_cluster.engine_version, "id" => cache_cluster.cache_cluster_id, "node_type" => cache_cluster.cache_node_type, "num_cache_nodes" => "1", "parameter_group_name" => cache_cluster.cache_parameter_group.cache_parameter_group_name, "security_group_ids.#" => security_group_ids_of(cache_cluster).length.to_s, "security_group_names.#" => security_group_names_of(cache_cluster).length.to_s, "subnet_group_name" => cache_cluster.cache_subnet_group_name, "tags.#" => "0", } attributes["port"] = if cache_cluster.configuration_endpoint cache_cluster.configuration_endpoint.port.to_s else cache_cluster.cache_nodes[0].endpoint.port.to_s end resources["aws_elasticache_cluster.#{module_name_of(cache_cluster)}"] = { "type" => "aws_elasticache_cluster", "primary" => { "id" => cache_cluster.cache_cluster_id, "attributes" => attributes } } resources end end |