Module: Awspec::Helper::Finder::Acm

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

Instance Method Summary collapse

Instance Method Details

#find_certificate(id) ⇒ Object



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

def find_certificate(id)
  selected = []
  loop do
    req = {}
    res = acm_client.list_certificates(req)
    selected += res.certificate_summary_list.select do |c|
      c.certificate_arn == id || c.domain_name == id
    end
    break if res.next_token.nil?
    req[:next_token] = res.next_token
  end

  cert = selected.single_resource(id)
  acm_client.describe_certificate({ certificate_arn: cert.certificate_arn }).certificate
end

#select_all_certificatesObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/awspec/helper/finder/acm.rb', line 20

def select_all_certificates
  certs = []
  loop do
    req = {}
    res = acm_client.list_certificates(req)
    res.certificate_summary_list.each do |c|
      certs << c.certificate_arn
    end
    break if res.next_token.nil?
    req[:next_token] = res.next_token
  end

  certificates = []
  certs.each do |cert|
    certificates << acm_client.describe_certificate({ certificate_arn: cert }).certificate
  end
  certificates
end