Search code examples
amazon-web-servicesaws-api-gateway

Turn off (Disable) individual API in API Gateway temporarily without Deleting?


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?


Solution

  • There is no disable button, but there are two possibilities that can be considered as a workaround:

    1. Delete the API stage(s). Without stage, API wont be accessible.
    2. 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.
    {
        "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.