in source/cfn-add-edge-lambda/cfn-add-edge-lambda.py [0:0]
def remove_cache_behavior(behavior, lambda_association):
# default to an empty list if none yet
behavior["LambdaFunctionAssociations"]["Items"] = behavior[
"LambdaFunctionAssociations"].get("Items", [])
# look for existing associations
matches = [
x for x in behavior["LambdaFunctionAssociations"]["Items"]
if x == lambda_association
]
if len(matches) > 0:
logger.info(
"Found matching LambdaFunctionAssociation to remove from the CloudFront Distribution"
)
behavior["LambdaFunctionAssociations"]["Items"].remove(
lambda_association)
behavior["LambdaFunctionAssociations"]["Quantity"] = len(
behavior["LambdaFunctionAssociations"]["Items"])