Class: SecretConfig::Providers::Ssm
- Inherits:
-
Object
- Object
- 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
- #each(path) ⇒ Object
-
#initialize(key_id: nil) ⇒ Ssm
constructor
A new instance of Ssm.
- #set(key, value, encrypt: true) ⇒ Object
Constructor Details
#initialize(key_id: nil) ⇒ Ssm
9 10 11 12 13 |
# File 'lib/secret_config/providers/ssm.rb', line 9 def initialize(key_id: nil) @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.
7 8 9 |
# File 'lib/secret_config/providers/ssm.rb', line 7 def client @client end |
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
7 8 9 |
# File 'lib/secret_config/providers/ssm.rb', line 7 def key_id @key_id end |
Instance Method Details
#each(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/secret_config/providers/ssm.rb', line 15 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
30 31 32 33 34 35 36 37 38 |
# File 'lib/secret_config/providers/ssm.rb', line 30 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 |