in src/lambda_functions/cw_metric_filter_cr/lambda_function.py [0:0]
def create_or_update_metric_filter_dimension(event, _):
"""Create or Update Resource"""
resource_type = event["ResourceType"]
resource_properties = event["ResourceProperties"]
if resource_type == "Custom::MetricFilterDimension":
filter_name = resource_properties["FilterName"]
log_group_name = resource_properties["LogGroupName"]
metric_transformations = resource_properties["MetricTransformations"]
for metric_transformation in metric_transformations:
put_metric_filter_dimension(
filter_name=filter_name,
log_group_name=log_group_name,
metric_transformation=metric_transformation,
request_type=event["RequestType"],
)
return
raise ValueError(f"invalid resource type: {resource_type}")