Class: Awshark::Ssm::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/awshark/ssm/client.rb

Instance Method Summary collapse

Instance Method Details

#list_secrets(application:) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/awshark/ssm/client.rb', line 6

def list_secrets(application:)
  response = client.get_parameters_by_path({
                                             path: application,
                                             recursive: true,
                                             with_decryption: true
                                           })
  response.parameters
end

#update_secrets(application:, secrets:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/awshark/ssm/client.rb', line 15

def update_secrets(application:, secrets:)
  flat_secrets = flatten_hash(secrets)

  flat_secrets.each_pair do |key, value|
    params = {
      name: "/#{application}/#{key.downcase}",
      value: value,
      type: 'SecureString', # accepts String, StringList, SecureString
      tier: 'Standard' # accepts Standard, Advanced, Intelligent-Tiering
    }

    loop do
      client.put_parameter(params.merge(overwrite: true))
      puts "Updated secrets for: #{params[:name]}"

      break
    rescue Aws::SSM::Errors::ThrottlingException
      puts 'Aws::SSM::Errors::ThrottlingException... retrying'
      sleep 1
    end
  end
end