user3888307
user3888307

Reputation: 3123

Amazon AWS CLI delete ApiGateway, possible?

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

Answers (3)

tkp
tkp

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

Harald Langmar
Harald Langmar

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

krishna_mee2004
krishna_mee2004

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

Related Questions