19

How to manually forcefully discard a aws lambda function in the cluster using aws console or aws cli for development and testing purposes ?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
auhuman
  • 962
  • 2
  • 13
  • 34
  • Do you mean "How do I delete a Lambda function?" – John Hanley Nov 23 '17 at 00:53
  • 1
    No I don't want to delete a Lambda function instead just want to remove a frozen lambda from the container. http://docs.aws.amazon.com/lambda/latest/dg/lambda-introduction.html – auhuman Nov 27 '17 at 18:41
  • Easiest way I found was via editing basic settings as laid out here https://stackoverflow.com/a/63214467 – user3041539 Aug 02 '20 at 12:39

2 Answers2

17

If you redeploy the function it'll terminate all existing containers. It could be as simple as assigning the current date/time to the description of the Lambda function and redeploying. This will allow you to redeploy as many times as you need because something is unique and it will tear down all existing containers each time you do the deployment.

With that said, Lambda functions are supposed to be stateless. You should keep that in mind when you write your code (eg. avoid using global variables, use random file names if creating something temp, etc). From the sounds of things, I think you might have an issue with your design if you require the Lambda container to be torn down.

Hubert Grzeskowiak
  • 15,137
  • 5
  • 57
  • 74
Moe
  • 2,672
  • 10
  • 22
  • 1
    The net result is as you described, but to be precisely correct, the service may not necessarily terminate existing containers right away... it will just abandon them from your perspective and they'll eventually be destroyed. This is true because the newly-deployed code is not the same code, thus it will run in all-new containers. – Michael - sqlbot Nov 23 '17 at 05:38
13

If you're using the UI, then a simple way to do this is to add or alter an environment variable on the function configuration page.

When you click "Save" the function will be reloaded.

Note: this won't work if you're using the versioned functions feature.

teppic
  • 7,051
  • 1
  • 29
  • 35
  • 1
    huh - that doesn't appear to be true. The reason I want to cycle my container is because it appears an environment variable update is not taking affect. After updating the variable and "Save"'ing via the console, my logs still say that the container is much older than my update. – Jmoney38 Nov 14 '19 at 02:03
  • This seems like an answer to me :) Thanks for saving my re-deploying time! – Sang Yun Park Aug 12 '20 at 19:02