File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package resources
2
2
3
3
import (
4
4
"context"
5
+ "go.uber.org/ratelimit"
5
6
"time"
6
7
7
8
"github.com/aws/aws-sdk-go/aws"
@@ -16,6 +17,12 @@ import (
16
17
17
18
const APIGatewayAPIKeyResource = "APIGatewayAPIKey"
18
19
20
+ // Rate limit to avoid throttling when deleting API Gateway Rest APIs
21
+ // The API Gateway Delete Rest API has a limit of 1 request per 30 seconds for each account
22
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
23
+ // Note: due to time drift, set to 31 seconds to be safe.
24
+ var deleteAPIKeyLimit = ratelimit .New (1 , ratelimit .Per (32 * time .Second ))
25
+
19
26
func init () {
20
27
registry .Register (& registry.Registration {
21
28
Name : APIGatewayAPIKeyResource ,
@@ -72,6 +79,8 @@ type APIGatewayAPIKey struct {
72
79
}
73
80
74
81
func (r * APIGatewayAPIKey ) Remove (_ context.Context ) error {
82
+ deleteAPIKeyLimit .Take ()
83
+
75
84
_ , err := r .svc .DeleteApiKey (& apigateway.DeleteApiKeyInput {
76
85
ApiKey : r .apiKey ,
77
86
})
You can’t perform that action at this time.
0 commit comments