Module: Awspec::Helper::Finder::Rds

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/rds.rb

Instance Method Summary collapse

Instance Method Details

#find_db_cluster(db_cluster_identifier) ⇒ Object



75
76
77
78
79
80
# File 'lib/awspec/helper/finder/rds.rb', line 75

def find_db_cluster(db_cluster_identifier)
  res = rds_client.describe_db_clusters({
                                          db_cluster_identifier: db_cluster_identifier
                                        })
  res.db_clusters.single_resource(db_cluster_identifier)
end

#find_db_subnet_group(db_subnet_group_name) ⇒ Object



89
90
91
92
93
94
# File 'lib/awspec/helper/finder/rds.rb', line 89

def find_db_subnet_group(db_subnet_group_name)
  res = rds_client.describe_db_subnet_groups({
                                               db_subnet_group_name: db_subnet_group_name
                                             })
  res.db_subnet_groups.single_resource(db_subnet_group_name)
end

#find_global_cluster(global_cluster_identifier) ⇒ Object



82
83
84
85
86
87
# File 'lib/awspec/helper/finder/rds.rb', line 82

def find_global_cluster(global_cluster_identifier)
  res = rds_client.describe_global_clusters({
                                              global_cluster_identifier: global_cluster_identifier
                                            })
  res.global_clusters.single_resource(global_cluster_identifier)
end

#find_rds(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/awspec/helper/finder/rds.rb', line 6

def find_rds(id)
  begin
    res = rds_client.describe_db_instances({
                                             db_instance_identifier: id
                                           })
  rescue StandardError
    res = rds_client.describe_db_instances({
                                             filters: [{ name: 'db-instance-id', values: [id] }]
                                           })
  end
  res.db_instances.single_resource(id)
end

#find_rds_proxy(db_proxy_name) ⇒ Object



61
62
63
64
65
66
# File 'lib/awspec/helper/finder/rds.rb', line 61

def find_rds_proxy(db_proxy_name)
  res = rds_client.describe_db_proxies({
                                         db_proxy_name: db_proxy_name
                                       })
  res.db_proxies.single_resource(db_proxy_name)
end

#select_all_rds_db_cluster_parameters(parameter_group) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/awspec/helper/finder/rds.rb', line 45

def select_all_rds_db_cluster_parameters(parameter_group)
  parameters = {}
  next_marker = nil
  loop do
    res = rds_client.describe_db_cluster_parameters({
                                                      marker: next_marker,
                                                      db_cluster_parameter_group_name: parameter_group
                                                    })
    res.parameters.each do |param|
      parameters[param.parameter_name] = param.parameter_value
    end
    (res.marker.present? && next_marker = res.marker) || break
  end
  parameters
end

#select_all_rds_db_parameters(parameter_group) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/awspec/helper/finder/rds.rb', line 26

def select_all_rds_db_parameters(parameter_group)
  parameters = {}
  res = rds_client.describe_db_parameters({
                                            db_parameter_group_name: parameter_group
                                          })
  loop do
    res.parameters.each do |param|
      parameters[param.parameter_name] = param.parameter_value
    end
    break if res.marker.nil?

    res = rds_client.describe_db_parameters({
                                              db_parameter_group_name: parameter_group,
                                              marker: res.marker
                                            })
  end
  parameters
end

#select_rds_by_vpc_id(vpc_id) ⇒ Object



19
20
21
22
23
24
# File 'lib/awspec/helper/finder/rds.rb', line 19

def select_rds_by_vpc_id(vpc_id)
  res = rds_client.describe_db_instances
  res.db_instances.select do |db_instance|
    db_instance.db_subnet_group.vpc_id == vpc_id
  end
end

#select_rds_proxy_by_vpc_id(vpc_id) ⇒ Object



68
69
70
71
72
73
# File 'lib/awspec/helper/finder/rds.rb', line 68

def select_rds_proxy_by_vpc_id(vpc_id)
  res = rds_client.describe_db_proxies
  res.db_proxies.select do |db_proxy|
    db_proxy.vpc_id == vpc_id
  end
end