Module: CloudFormation::Bridge::Resources::BaseElastiCacheResource
- Includes:
- Names
- Defined in:
- lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb
Constant Summary collapse
- UnknownCacheEngineError =
Class.new(StandardError)
Instance Method Summary collapse
- #client ⇒ Object
- #config_endpoint(cluster_id) ⇒ Object
- #find_cluster(cluster_id) ⇒ Object
- #node_urls(cluster_id) ⇒ Object
- #replication_group_available?(replication_group_id) ⇒ Boolean
- #wait_until_cluster_is_available(cluster_id) ⇒ Object
Instance Method Details
#client ⇒ Object
46 47 48 |
# File 'lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb', line 46 def client @client ||= AWS::ElastiCache.new.client end |
#config_endpoint(cluster_id) ⇒ Object
33 34 35 36 |
# File 'lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb', line 33 def config_endpoint(cluster_id) cluster = find_cluster(cluster_id) "#{cluster[:configuration_endpoint][:address]}:#{cluster[:configuration_endpoint][:port]}" if cluster[:engine] == 'memcached' end |
#find_cluster(cluster_id) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb', line 18 def find_cluster(cluster_id) client.describe_cache_clusters( cache_cluster_id: cluster_id, show_cache_node_info: true )[:cache_clusters][0] end |
#node_urls(cluster_id) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb', line 25 def node_urls(cluster_id) cluster = find_cluster(cluster_id) cluster[:cache_nodes].map do |node| "#{node[:endpoint][:address]}:#{node[:endpoint][:port]}" end.join(",") end |
#replication_group_available?(replication_group_id) ⇒ Boolean
13 14 15 16 |
# File 'lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb', line 13 def replication_group_available?(replication_group_id) replication_group = client.describe_replication_groups(replication_group_id: replication_group_id)[:replication_groups][0] replication_group[:status] == ELASTI_CACHE::AVAILABLE end |
#wait_until_cluster_is_available(cluster_id) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/cloud_formation/bridge/resources/base_elasti_cache_resource.rb', line 38 def wait_until_cluster_is_available(cluster_id) wait_until("replica #{cluster_id} to be available") do cluster = find_cluster(cluster_id) Util.logger.info("Cluster info is #{cluster.inspect}") cluster[:cache_cluster_status] == ELASTI_CACHE::AVAILABLE end end |