Skip to content

Instantly share code, notes, and snippets.

@adhorn
Created July 11, 2019 11:50
Show Gist options
  • Save adhorn/db0891711255fa9a6d671ed18bea19dd to your computer and use it in GitHub Desktop.
Save adhorn/db0891711255fa9a6d671ed18bea19dd to your computer and use it in GitHub Desktop.
Get Failure Injection configuration
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