Question:
Is it possible in AWS API Gateway to “turn off”/”disable” an API in API Gateway, without deleting the API itself? I’m hoping to keep the configuration of an API, without losing it through the otherwise deletion I’m hoping to avoid; that would also have the beneficial parallel motivation of preventing AWS billed API usage.
Is it possible, or is delete the only option?
Answer:
There is no disable button, but there are two possibilities that can be considered as a workaround:
- Delete the API stage(s). Without stage, API wont be accessible.
- Since one can be problematic if there are multiple stages with lots of custom setttings, you can add
Deny
resource base policy to the API.
1 2 3 4 5 6 7 8 9 10 11 12 |
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Principal": "*", "Action": "execute-api:Invoke", "Resource": "execute-api:/{{stageNameOrWildcard}}/{{httpVerbOrWildcard}}/{{resourcePathOrWildcard}}" } ] } |
The policy will Deny all invocations of the API, making it effectively disabled. But the invocations will still count towards API usage.