Class: SecretConfig::Providers::Ssm
- Defined in:
- lib/secret_config/providers/ssm.rb
Overview
Use the AWS System Manager Parameter Store for Centralized Configuration / Secrets Management
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#key_id ⇒ Object
readonly
Returns the value of attribute key_id.
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #each(path) ⇒ Object
-
#initialize(key_id: ENV["AWS_ACCESS_KEY_ID"]) ⇒ Ssm
constructor
A new instance of Ssm.
- #set(key, value, encrypt: true) ⇒ Object
Methods inherited from Provider
Constructor Details
#initialize(key_id: ENV["AWS_ACCESS_KEY_ID"]) ⇒ Ssm
Returns a new instance of Ssm.
13 14 15 16 17 |
# File 'lib/secret_config/providers/ssm.rb', line 13 def initialize(key_id: ENV["AWS_ACCESS_KEY_ID"]) @key_id = key_id logger = SemanticLogger['Aws::SSM'] if defined?(SemanticLogger) @client = Aws::SSM::Client.new(logger: logger) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/secret_config/providers/ssm.rb', line 11 def client @client end |
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
11 12 13 |
# File 'lib/secret_config/providers/ssm.rb', line 11 def key_id @key_id end |
Instance Method Details
#delete(key) ⇒ Object
44 45 46 |
# File 'lib/secret_config/providers/ssm.rb', line 44 def delete(key) client.delete_parameter(name: key) end |
#each(path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/secret_config/providers/ssm.rb', line 19 def each(path) token = nil loop do resp = client.get_parameters_by_path( path: path, recursive: true, with_decryption: true, next_token: token ) resp.parameters.each { |param| yield(param.name, param.value) } token = resp.next_token break if token.nil? end end |
#set(key, value, encrypt: true) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/secret_config/providers/ssm.rb', line 34 def set(key, value, encrypt: true) client.put_parameter( name: key, value: value.to_s, type: encrypt ? "SecureString" : "String", key_id: key_id, overwrite: true ) end |