Class: Dev::Aws::Parameter

Inherits:
Object show all
Defined in:
lib/firespring_dev_commands/aws/parameter.rb

Overview

Class containing methods for get/put ssm parameters in Aws

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Parameter

Returns a new instance of Parameter.



9
10
11
# File 'lib/firespring_dev_commands/aws/parameter.rb', line 9

def initialize
  @client = nil
end

Instance Attribute Details

#client ⇒ Object

Create/set a new client if none is present Return the client



15
16
17
# File 'lib/firespring_dev_commands/aws/parameter.rb', line 15

def client
  @client
end

Instance Method Details

#get(name, with_decryption: true) ⇒ Object

Retrieve the ssm parameter object with the given name



25
26
27
28
29
# File 'lib/firespring_dev_commands/aws/parameter.rb', line 25

def get(name, with_decryption: true)
  client.get_parameter(name:, with_decryption:)&.parameter
rescue ::Aws::SSM::Errors::ParameterNotFound
  raise "parameter #{name} does not exist in #{Dev::Aws::Profile.new.current}"
end

#get_value(name, with_decryption: true) ⇒ Object

Get the value of the given parameter name



20
21
22
# File 'lib/firespring_dev_commands/aws/parameter.rb', line 20

def get_value(name, with_decryption: true)
  get(name, with_decryption:)&.value
end