API Gateway & Lambda: Unable to delete Lambda function from AWS API Gateway (Lambda still in use by API Gateway) #30658
Labels
@aws-cdk/aws-lambda
Related to AWS Lambda
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p3
Describe the bug
What I'm trying to do, is remove a Lambda Function from the API Gateway. I don't want to delete the whole Lambda Function itself (though that's not even possible when I try to).
I try to do this by simply commenting out the line of code that adds the Lambda Function to the API Gateway.
Here is my ApiGatewayStack:
And this is my
Launcher.ts
file:And this is what I try to do:
// postResourcesV1.addMethod("DELETE", props.testLambda);
this results in the following error in the Console:
The CloudFormation Console for this stack tells me this:
Export ButlaiLambdaStack-dev:ExportsOutputFnGetAtttestFunctionFOOBAR cannot be deleted as it is in use by ButlaiApiGatewayStack-dev
But there aren't any other references to that testLambda function elsewhere in my codebase. Next to that, I'm not trying to DELETE the whole Lambda function, I want to deploy a new version of the API without that Method.
Expected Behavior
In the next deployment (that I'm trying to deploy), the method that I want to delete from the API Gateway should be removed.
The Lambda function itself will still exist in AWS, in case we want to revert to an older deployment version.
Current Behavior
The current behaviour is a ROLLBACK.
Nothing else happens, the stack won't be updated, the method still exists and is callable.
Reproduction Steps
If you would copy and paste the code that I posted above (the ApiGatewayStack). And deploy it using:
cdk deploy --all
Then, comment out one of the added Lambda Functions an re-run:
cdk deploy --all
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.147.0 (build 3338fc0)
Framework Version
No response
Node.js Version
v22.2.0
OS
Mac OS 14.5 (23F79)
Language
TypeScript
Language Version
TypeScript (5.4.3)
Other information
No response
The text was updated successfully, but these errors were encountered: