Tear a Function Down in Dependency Order
A 5-step recipe with AWS Lambda. We can help you get access.
Recipe · 5 steps
Tear a Function Down in Dependency Order
with AWS Lambda · IT Infrastructure Management
Remove a function's event source mapping and URL, then delete the function.
- Confirm the function exists and capture its ARN before anything is deleted, so a mistyped name fails before it can detach resources belonging to some other function.
- List the event source mappings pointed at this function. These are independent resources that survive the function's deletion, so they must be enumerated before it disappears and their UUIDs become hard to recover.
- Delete the mapping so Lambda stops polling the event source. Deletion is asynchronous and returns 202 while the mapping drains in-flight records.
- Remove the public HTTPS endpoint. A function with no URL configured returns 404 here, which is a successful outcome for a teardown, so the flow continues to the deletion either way.
- Delete the function itself. Qualifier is deliberately omitted so that every version and alias is removed rather than a single version, leaving nothing behind.
What you'll need to have ready
- functionName: The name or ARN of the function to tear down.
For your developer
Arazzo workflow aws-lambda:function-teardown, 5 operations: GetFunction → ListEventSourceMappings → DeleteEventSourceMapping → DeleteFunctionUrlConfig → DeleteFunction. Specs on APIs.io.