Last active
April 14, 2024 17:24
-
-
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
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 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