Skip to content

Commit

Permalink
issue6: update README. set version to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleygould committed Feb 15, 2021
1 parent e026a56 commit bc398fd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Intended for use by CDL UC3 services. We rely on EC2 instance profiles to provi

### Parameters

- `ssm_root_path`: prefix to apply to all parameter name lookups. This must be
a fully qualified parameter path, i.e. it must start with a forward slash
('/'). Defaults to value of environment var `SSM_ROOT_PATH` if defined.
- `ssm_root_path`: colon separated list of path prefixes to apply to all
parameter name lookups. Each path prefix in `ssm_root_path` must be a fully
qualified parameter path, i.e. it must start with a forward slash ('/').
Defaults to value of environment var `SSM_ROOT_PATH` if defined.

- `region`: AWS region in which to perform the SSM lookup. Defaults to value
of environment var `AWS_REGION` if defined, or failing that, to `us-west-2`.
Expand All @@ -25,7 +26,7 @@ Intended for use by CDL UC3 services. We rely on EC2 instance profiles to provi
- `ssm_skip_resolution`: boolean flag. When set, no SSM ParameterStore
lookups will occur. Key lookups fall back to local environment lookups or to
defined default values. Defaults to value of environment var
`SSM_SKIP_RESOLUTION` if defined.
`SSM_SKIP_RESOLUTION`, or to 'false' if `SSM_SKIP_RESOLUTION` is not defined.


### Instantiation
Expand All @@ -43,15 +44,15 @@ Explicit parameter declaration. All unqualified lookup keys will have the

```ruby
myResolver = Uc3Ssm::ConfigResolver.new(
ssm_root_path: "/my/root/path"
ssm_root_path: "/my/root/path:/my/other/root/path"
region: "us-west-2",
)
```

Implicit parameter declaration using environment vars.

```ruby
ENV['SSM_ROOT_PATH'] = '/my/other/root/path'
ENV['SSM_ROOT_PATH'] = '/my/root/path:/my/other/root/path'
ENV['AWS_REGION'] = 'us-west-2'
myResolver = Uc3Ssm::ConfigResolver.new()
```
Expand All @@ -65,8 +66,12 @@ perform a simple lookup for a single ssm parameter.

When `key` is prefixed be a forward slash (e.g. `/cleverman` or
`/price/tea/china`), it is considered to be a fully qualified parameter name
and is passed 'as is' to SSM. If not so prefixed, then `ssm_root_path` is
prepended to `key` to form a fully qualified parameter name.
and is passed 'as is' to SSM.

If `key` is not fully qaulified, then each path prefix in `ssm_root_path` is
prepended to `key` to form a fully qualified parameter name. A lookup is
performed for each such fully qualified parameter name in order until a value
is found or all lookups fail.

NOTE: if `ssm_root_path` is not defined, and `key` is unqualified (no forward
slash prefix), an exception is thrown.
Expand All @@ -75,12 +80,15 @@ slash prefix), an exception is thrown.
Example:

```ruby
myResolver = Uc3Ssm::ConfigResolver.new(ssm_root_path: "/my/root/path")
myResolver = Uc3Ssm::ConfigResolver.new(
ssm_root_path: "/my/root/path:/my/other/root/path"
)
myResolver.parameter_for_key('/cheese/blue')
# returns value for parameter name '/cheese/blue'

myResolver.parameter_for_key('blee')
# returns value for parameter name '/my/root/path/blee'
# performs a lookup for parameter name '/my/root/path/blee'.`
# if this is not found, performs a lookup for '/my/other/root/path/blee'.

myDefaultResolver = Uc3Ssm::ConfigResolver.new()
myDefaultResolver.parameter_for_key('blee')
Expand All @@ -102,22 +110,25 @@ client_secret = ssm.parameter_for_key('client_secret') || ''
perform a lookup for all parameters prefixed by `options['path']`.

As with `myResolver.parameter_for_key(key)`, when `options[path]` is not fully
qualified, `ssm_root_path` is prepended to `path` to form a fully qualified
parameter path. If `options['path'] is not specified, then the search is done
with `ssm_root_path.
qualified, each path prefix in `ssm_root_path` is prepended to `path` to form a
fully qualified parameter path. If `options['path'] is not specified, then the
search is done for each path prefix in `ssm_root_path`. Returns a list of
parameters which is the union of all searches made.

All other keys in `options` are passed to `Aws::SSM::Client.get_parameters_by_path`.
See https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/SSM/Client.html#get_parameters_by_path-instance_method

Example:

```ruby
myResolver = Uc3Ssm::ConfigResolver.new(ssm_root_path: "/my/base/path")
myResolver = Uc3Ssm::ConfigResolver.new(
ssm_root_path: "/my/base/path:/my/other/path"
)
myResolver.parameter_for_key(path: 'args')
# returns values for all parameter names directly under "/my/base/path/args"
# returns values for all parameter names directly under both `/my/base/path/args` and `/my/other/path`.`

myResolver.parameter_for_key(path: 'args', resursive: true)
# returns values for all parameter names recursively starting with "/my/base/path/args"
# returns values for all parameter names recursively under both `/my/base/path/args` and `/my/other/path`.
```


Expand Down
2 changes: 1 addition & 1 deletion lib/uc3-ssm/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Uc3Ssm
VERSION = '0.2.0'
VERSION = '0.3.0'
end

0 comments on commit bc398fd

Please sign in to comment.