Last active
March 28, 2018 01:44
-
-
Save jtatum/4f6a81099fe56904414c0b4e803a7309 to your computer and use it in GitHub Desktop.
Get config from AWS SSM parameters. Import this file in your lambda and access parameters like config.SOME_PARAM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
def _get_secrets(path: str): | |
client = boto3.client('ssm') | |
secrets = {} | |
kwargs = {} | |
while True: | |
result = client.get_parameters_by_path( | |
Path=path, | |
WithDecryption=True, | |
**kwargs) | |
for param in result['Parameters']: | |
secrets[param['Name']] = param['Value'] | |
try: | |
kwargs['NextToken'] = result['NextToken'] | |
except KeyError: | |
break | |
return secrets | |
_secrets = _get_secrets('/some/path') | |
for key in _secrets: | |
vars()[key] = _secrets[key] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment