Skip to content

Instantly share code, notes, and snippets.

@jpbarto
Created December 7, 2016 23:46
Show Gist options
  • Save jpbarto/38ce994ced3f85128243d50fc11b7b0b to your computer and use it in GitHub Desktop.
Save jpbarto/38ce994ced3f85128243d50fc11b7b0b to your computer and use it in GitHub Desktop.
AWS Lambda function that deletes itself
import os
import boto3
lclient = boto3.client ('lambda')
print ('function loaded')
def lambda_handler(event, context):
lclient.delete_function (FunctionName = context.function_name)
print ('I am deleted')
return True
@iDVB
Copy link

iDVB commented Jan 22, 2022

Does this actually work?
I always wondered if this could work.
I assume this means you would have to give that function's role the permission to delete itself?

[Update]
I can confirm this DOES work.
You do need to give that function's role permission to delete itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment