aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.38k stars 3.79k forks source link

(custom_resources): retry after Rate exceeded #24210

Open mattiamatrix opened 1 year ago

mattiamatrix commented 1 year ago

Describe the bug

In our project, we use AwsCustomResource to run many API calls against Lake Formation (grantPermissions, revokePermissions.)

However, in many cases, it happens that the deployment fails after a Rate exceeded error.

Expected Behavior

It would be nice to have the option to enable an exponential backoff retry

Current Behavior

The deployment fails with no other options.

Reproduction Steps

Steps

new AwsCustomResource(this.scope, id, {
      role: this.customResourceRole,
      onCreate: {
        service: 'LakeFormation',
        action: 'grantPermissions',
        parameters: {
          Principal: { ... },
          Resource: {
            LFTagPolicy: { ... },
          Permissions: permissions,
        },
        physicalResourceId: PhysicalResourceId.of(id),
      },

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.65.0

Framework Version

No response

Node.js Version

18

OS

macOs 13.0.1

Language

Typescript

Language Version

No response

Other information

No response

pahud commented 1 year ago

Yeah it would be great to have this feature. I am making it as p2 and any PR submission would be highly appreciated!

kemalunel commented 3 months ago

you have to implement retry behavior mechanism to your code. see https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html