Search code examples
amazon-web-servicesaws-lambda

How to kill/terminate a running AWS Lambda function?


I have a lambda function that runs over a period of ~10mins. Decently long for a Lambda but given our current needs/setup it's the simplest way for it to do what we need it to do.

However, a recent bug in our Lambda code made the lambda go haywire and basically DOS our own server. This is where I realized I have no idea how to kill this process if ever I need to (vs just wait for it to end/timeout). so...

Is there a way to do terminate a running lambda process from the AWS console? Is there a way to do it via AWS CLI?


Solution

  • There's no way to kill a running lambda. However, you can set concurrency limit to 0 to stop it from starting any more executions

    e.g.

    $ aws lambda put-function-concurrency --function-name my-function --reserved-concurrent-executions 0
    

    https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html