Class: Dev::EndOfLife::Aws
- Defined in:
- lib/firespring_dev_commands/eol/aws.rb
Overview
Class which queries several different AWS product types and returns ProductVersion entities which can be checked for EOL
Instance Method Summary collapse
-
#default_products ⇒ Object
Queries and returns product versions for the default product types.
-
#elasticache_products ⇒ Object
Queries and returns product versions for elasticache products.
-
#lambda_products ⇒ Object
Queries and returns product versions for lambda products.
-
#opensearch_products ⇒ Object
Queries and returns product versions for opensearch products.
-
#rds_cluster_products ⇒ Object
Queries and returns product versions for rds cluster products.
-
#rds_instance_products ⇒ Object
Queries and returns product versions for rds instance products.
-
#rds_products ⇒ Object
Queries and returns product versions for rds products.
Instance Method Details
#default_products ⇒ Object
Queries and returns product versions for the default product types
12 13 14 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 12 def default_products (elasticache_products + lambda_products + opensearch_products + rds_products).flatten.compact end |
#elasticache_products ⇒ Object
Queries and returns product versions for elasticache products
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 17 def elasticache_products client = ::Aws::ElastiCache::Client.new [].tap do |ary| Dev::Aws.each_page(client, :describe_cache_clusters) do |response| response.cache_clusters.each do |cluster| name = cluster.cache_cluster_id product = cluster.engine version = cluster.engine_version.reverse.split('.')[-2..].join('.').reverse ary << Dev::EndOfLife::ProductVersion.new(product, version, name) end end end end |
#lambda_products ⇒ Object
Queries and returns product versions for lambda products
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 33 def lambda_products client = ::Aws::Lambda::Client.new [].tap do |ary| Dev::Aws.each_page(client, :list_functions) do |response| response.functions.each do |function| # Runtime is empty if using a docker image next unless function.runtime name = function.function_name product = function&.runtime&.split(/[0-9]/, 2)&.first version = function&.runtime&.split(/#{product}/, 2)&.last&.chomp('.x') ary << Dev::EndOfLife::ProductVersion.new(product, version, name) end end end end |
#opensearch_products ⇒ Object
Queries and returns product versions for opensearch products
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 52 def opensearch_products client = ::Aws::OpenSearchService::Client.new [].tap do |ary| Dev::Aws.each_page(client, :list_domain_names) do |response| response.domain_names.each do |domain| name = domain.domain_name product = domain.engine_type version = client.describe_domain(domain_name: name).domain_status.engine_version.split('_').last.split('.').first ary << Dev::EndOfLife::ProductVersion.new(product, version, name) end end end end |
#rds_cluster_products ⇒ Object
Queries and returns product versions for rds cluster products
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 99 def rds_cluster_products aws_engines = %w(mysql postgresql) aws_sqlserver_engines = %w(sqlserver-ee sqlserver-ex sqlserver-se sqlserver-web) client = ::Aws::RDS::Client.new [].tap do |ary| Dev::Aws.each_page(client, :describe_db_clusters) do |response| response.db_clusters.each do |cluster| name = cluster.db_cluster_identifier engine = cluster.engine.gsub('aurora-', '') product = if aws_engines.include?(engine) "amazon-rds-#{engine}" elsif aws_sqlserver_engines.include?(engine) 'mssqlserver' else engine end version = cluster.engine_version.reverse.split('.')[-2..].join('.').reverse version.chop! if version.end_with?('.00') ary << Dev::EndOfLife::ProductVersion.new(product, version, name) end end end end |
#rds_instance_products ⇒ Object
Queries and returns product versions for rds instance products
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 73 def rds_instance_products aws_engines = %w(mysql postgresql) aws_sqlserver_engines = %w(sqlserver-ee sqlserver-ex sqlserver-se sqlserver-web) client = ::Aws::RDS::Client.new [].tap do |ary| Dev::Aws.each_page(client, :describe_db_instances) do |response| response.db_instances.each do |instance| name = instance.db_instance_identifier engine = instance.engine.gsub('aurora-', '') product = if aws_engines.include?(engine) "amazon-rds-#{engine}" elsif aws_sqlserver_engines.include?(engine) 'mssqlserver' else engine end version = instance.engine_version.reverse.split('.')[-2..].join('.').reverse version.chop! if version.end_with?('.00') ary << Dev::EndOfLife::ProductVersion.new(product, version, name) end end end end |
#rds_products ⇒ Object
Queries and returns product versions for rds products
68 69 70 |
# File 'lib/firespring_dev_commands/eol/aws.rb', line 68 def rds_products rds_instance_products + rds_cluster_products end |