Created
July 11, 2019 11:50
-
-
Save adhorn/db0891711255fa9a6d671ed18bea19dd to your computer and use it in GitHub Desktop.
Get Failure Injection configuration
This file contains 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
def get_config(config_key): | |
param = SSMParameter(os.environ['FAILURE_INJECTION_PARAM']) | |
try: | |
value = json.loads(param.value) | |
if not value["isEnabled"]: | |
return 0, 1 | |
return value[config_key], value.get('rate', 1) | |
except InvalidParameterError as e: | |
# key does not exist in SSM | |
raise InvalidParameterError("{} does not exist in SSM".format(e)) | |
except KeyError as e: | |
# not a valid Key in the SSM configuration | |
raise KeyError("{} is not a valid Key in the SSM configuration".format(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment