Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kob-aha/e34b03cfce8c1a2584799c92eda008da to your computer and use it in GitHub Desktop.
Save kob-aha/e34b03cfce8c1a2584799c92eda008da to your computer and use it in GitHub Desktop.
SSM Document for attaching extension to a Lambda function and enable fault injection - Handler function
def handler(event, context):
# Parse the input event to an internal class
config: DocumentConfig = DocumentConfig.from_event(event)
if config.chaos_mode == 'ENABLED':
enable_chaos(config)
else:
disable_chaos(config)
def enable_chaos(config):
lambda_config_existing = client.get_function_configuration(FunctionName=config.function_name)
updated_layers = _get_updated_layers(lambda_config_existing, config.layer_arn)
updated_variables = _add_chaos_vars(lambda_config_existing)
_update_function(config, updated_layers, updated_variables)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment