Reputation: 3123
Is there a way to Delete a Amazon API Gateway from the aws cli ?
I created a bunch of gateways, and it takes a while to remove them from the GUI. Is there a way to do it from aws cli
Couldn't find any examples anywhere
Upvotes: 2
Views: 2144
Reputation: 11
Just an update to Harald Langmar's comment, the rate limit for DeleteRestApi is now at 1 request per 30 seconds.
Change sleep 10 to sleep 30, or sleep 31 to be on the safe side.
https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
Upvotes: 1
Reputation: 1
for rest_api_id in $(aws apigateway get-rest-apis --region eu-central-1 --query 'items[*].id' --output text); do aws apigateway delete-rest-api --region eu-central-1 --rest-api-id $rest_api_id; sleep 10; done
^ In case you run into rate limiting issues like I did.
Upvotes: 0
Reputation: 7366
Yes, you can delete the APIs using AWS CLI. To delete a Rest API using CLI, we need the rest API id. To get that, run the get-rest-apis
CLI and then delete it.
Here's a script to delete all the rest APIs:
for rest_api_id in $(aws apigateway get-rest-apis --region us-east-1 --query 'items[*].id' --output text); do aws apigateway delete-rest-api --region us-east-1 --rest-api-id $rest_api_id ; done
Of course this will delete all the APIs. To delete selectively, run the commands separately.
References:
Upvotes: 5