simple_parameter_store 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +9 -9
- data/lib/simple_parameter_store/version.rb +1 -1
- data/lib/simple_parameter_store.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0071e4ef3cd71ae0a57df53926b5a7f2fbd5a7f20e1c6d68eefa895d508cb39b
|
4
|
+
data.tar.gz: f128adff7f525f097cd0e5f04c8cfa6c89779aed514efc3b7515a5ff1804b4c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 656371046a106f78f958de51bbdbd83d43507947273068c12bfbd11530aafff57415a51594312a8c829736d3d9ff118d2aefb4bcd4b819ecfffe983ce6846b66
|
7
|
+
data.tar.gz: cfd9696da27b114efabdfaea1d88e436d0c3826b0b9b9c6c97c8cfb7f1dafc0df1f4a2a90a87e9bc62d08a437e6dd3dc4e4594e841aae55c4b46ec7ee1221c42
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SimpleParameterStore
|
2
2
|
|
3
|
-
`SimpleParameterStore` gives you
|
3
|
+
`SimpleParameterStore` gives you a nice abstraction over the AWS SSM Parameter Store.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -25,13 +25,13 @@ require 'simple_parameter_store'
|
|
25
25
|
|
26
26
|
parameters = SimpleParameterStore.new(
|
27
27
|
client: Aws::SSM::Client.new, # optional, default: `Aws::SSM::Client.new`, can be used to set custom args for the SSM client
|
28
|
-
prefix: "/#{ENV['ENVIRONMENT']}", # optional, default: `nil`, can be used to prefix all parameter names with `/production`
|
29
|
-
expires_after: 3600, # optional, default: `nil`, time in seconds after the store will be refreshed
|
30
|
-
|
31
|
-
names: { #
|
32
|
-
foo: '/bar', #
|
28
|
+
prefix: "/#{ENV['ENVIRONMENT']}", # optional, default: `nil`, can be used to prefix all parameter names (e.g. with `/production`)
|
29
|
+
expires_after: 3600, # optional, default: `nil`, time in seconds after which the store will be refreshed
|
30
|
+
decrypt: true, # optional, default: `true`, enable/disable automatic parameter decryption
|
31
|
+
names: { # required; hash with mapping of parameter names, the key will be used for the store index
|
32
|
+
foo: '/bar', # aliases the key `/bar` (if prefix is `nil`) as `:foo` in the store
|
33
33
|
max: ['max', :to_i.to_proc], # the value can be an array with the key as first and a caster as second value,
|
34
|
-
key: ['private_key', OpenSSL::PKey::RSA.method(:new)] # the caster must
|
34
|
+
key: ['private_key', OpenSSL::PKey::RSA.method(:new)] # the caster must respond to `call` and return the converted value
|
35
35
|
}
|
36
36
|
)
|
37
37
|
|
@@ -39,8 +39,8 @@ parameters[:foo] # => `'bar'`
|
|
39
39
|
parameters[:max] # => `123`
|
40
40
|
parameters[:key].class # => OpenSSL::PKey::RSA
|
41
41
|
|
42
|
-
parameters.refresh # forces
|
43
|
-
parameters.refresh_if_needed # refreshes the store is expired
|
42
|
+
parameters.refresh # forces a store refresh
|
43
|
+
parameters.refresh_if_needed # refreshes if the store is expired
|
44
44
|
```
|
45
45
|
|
46
46
|
## Development
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'simple_parameter_store/version'
|
4
|
+
require 'aws-sdk-ssm'
|
4
5
|
|
5
6
|
class SimpleParameterStore
|
6
7
|
class SSMKeyError < KeyError; end
|
@@ -15,7 +16,7 @@ class SimpleParameterStore
|
|
15
16
|
@casters = {}
|
16
17
|
@cache = {}
|
17
18
|
|
18
|
-
|
19
|
+
prepare(names)
|
19
20
|
refresh
|
20
21
|
end
|
21
22
|
|
@@ -49,12 +50,12 @@ class SimpleParameterStore
|
|
49
50
|
|
50
51
|
def fetch
|
51
52
|
result = client.get_parameters(names: @mappings.values, with_decryption: decrypt)
|
52
|
-
raise SSMKeyError if result.invalid_parameters.any?
|
53
|
+
raise SSMKeyError, "Missing keys: `#{result.invalid_parameters}`" if result.invalid_parameters.any?
|
53
54
|
|
54
55
|
result
|
55
56
|
end
|
56
57
|
|
57
|
-
def
|
58
|
+
def prepare(names)
|
58
59
|
names.each_pair do |key, (name, caster)|
|
59
60
|
@mappings[key] = "#{prefix}#{name}"
|
60
61
|
@casters[key] = caster || :itself.to_proc
|