Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rds): enable
grantDataApiAccess
method for imported database c…
…luster (#31280) ### Issue # (if applicable) Closes #31116 . ### Reason for this change It was not possible to call the `grantDataApiAccess` method for an imported database cluster. Because the imported database cluster always has the `enableDataApi` with false. https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L983 ```ts class ImportedDatabaseCluster extends DatabaseClusterBase implements IDatabaseCluster { // ... protected readonly enableDataApi = false; ``` But the `grantDataApiAccess` throws an error when the `enableDataApi` is set to false. https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L523-L526 ```ts public grantDataApiAccess(grantee: iam.IGrantable): iam.Grant { if (this.enableDataApi === false) { throw new Error('Cannot grant Data API access when the Data API is disabled'); } // ... } ``` ### Description of changes Added the property `dataApiEnabled` to attributes for the imported database cluster. If the `dataApiEnabled` to the attributes is set to true, the `enableDataApi` in the imported cluster will be set to true and the `grantDataApiAccess` can be called. ### Description of how you validated changes Unit and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
3c92012
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this change! I'm struggling with this issue right now. Thanks for making a PR to fix this.