Varunkumar Nagarajan
Varunkumar Nagarajan

Reputation: 2047

Does event source mapping get deleted along with the lambda?

I have an AWS lambda and have created an event source mapping for the same. When I delete the lambda using Python boto3, does the event source mapping also get deleted along with that?

Upvotes: 0

Views: 356

Answers (1)

fedonev
fedonev

Reputation: 25659

No. A Lambda Event Source Mapping is a separate, customer-managed resource. It has its own CRUD API and CloudFormation AWS::Lambda::EventSourceMapping resource type. You must delete it yourself with delete_event_source_mapping.

res = client.list_event_source_mappings(EventSourceArn=queue_arn, FunctionName=function_name)
assert len(res["EventSourceMappings"]) == 1

client.delete_function(FunctionName=function_name)

res = client.list_event_source_mappings(EventSourceArn=queue_arn, FunctionName=function_name)
assert len(res["EventSourceMappings"]) == 1

client.delete_event_source_mapping(UUID=mapping_uuid)

res = client.list_event_source_mappings(EventSourceArn=queue_arn, FunctionName=function_name)
assert len(res["EventSourceMappings"]) == 0 # wait a few seconds for deletion to finish

Upvotes: 2

Related Questions