Skip to content

Commit

Permalink
log a warning when we get no params from SSM for a given prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
cmurtaugh committed Nov 27, 2019
1 parent 3d65a13 commit 4fe7b63
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dj_secure_settings/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ def _load_params_from_ssm(config, path_prefix, region_name=None):
ssm = boto3.client("ssm", region_name=region_name)
args = {"Path": path_prefix, "Recursive": True, "WithDecryption": True}
more = None
params_found = 0
while more is not False:
if more:
args["NextToken"] = more
params = ssm.get_parameters_by_path(**args)
for param in params["Parameters"]:
keys = param['Name'][len(path_prefix):].split('/')
_set_nested(config, keys, param['Value'])
params_found += 1
more = params.get("NextToken", False)

if params_found == 0:
logging.warning('Found no SSM parameters for prefix {}'.format(path_prefix))


def _set_nested(dic, keys, value):
# this sets a value in an arbitrarily-deeply nested dict
Expand Down

0 comments on commit 4fe7b63

Please sign in to comment.