How to programmatically enable and disable SQS triggering AWS Lambda?
Call Lambda's UpdateEventSourceMapping API with the {&quot;Enabled&quot;:true/false} request body.
If, for some reason, you want your own API for this, you can create one in API Gateway as described below.
Before you begin, you need the UUID of the event source mapping you wish to enable/disable. Use the AWS CLI to get this (it isn’t shown on the UI):
aws lambda list-event-source-mappings --function-name my-func

{
    &quot;EventSourceMappings&quot;: [
        {
            &quot;UUID&quot;: &quot;b962dcee-173c-47r1-9600-5c6d81catf85&quot;,
            &quot;BatchSize&quot;: 1,
            &quot;EventSourceArn&quot;: &quot;arn:aws:sqs:us-east-1:123456789012:my-queue&quot;,
            &quot;FunctionArn&quot;: &quot;arn:aws:lambda:us-east-1:123456789012:function:my-func&quot;,
            &quot;LastModified&quot;: 1595058588.141,
            &quot;State&quot;: &quot;Enabled&quot;,
            &quot;StateTransitionReason&quot;: &quot;USER_INITIATED&quot;
        }
    ]
}

Next, either create a new API in API Gateway or add a resource &amp; a GET method to your existing API. Configure it as shown below. The UUID you got above is highlighted below:

The execution role shown above must allow API Gateway to invoke Lambda APIs.
Scroll further down &amp; provide this mapping template:
Content-Type: application/json

{
    &quot;Enabled&quot; : $input.params(&quot;Enabled&quot;)
}

Save &amp; deploy to a stage. Now you can hit this API with the query param Enabled=true / Enabled=false to enable/disable your Lambda's SQS trigger. Here's a test done from the API Gateway console:

For a detailed screenshot-guided walkthrough of this entire process, see my blog post.