Skip to content

Commit

Permalink
feat(AppSync): addRdsDataSource support for DatabaseCluster (#29544)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

(aws-appsync): addRdsDataSource doesnt support taking a DatabaseCluster 

Closes #29302

### Reason for this change

AppSync CDK construct currently accept only IServerlessCluster for RDS source as cluster type. However, with Aurora V2, serverless aurora clusters such as postgres aurora v14 and above are construct using the DatabaseCluster construct and as such AppSync.addRdsDataSource() method need ability to support both type of cluster interfaces.

### Description of changes

To support the change I created a second props to support IDatabaseCluster in addition to IServerlessCluster already supported and I overloaded the constructor to support both type of props.

However, to make the change possible, some modification to aws-rds were also required:

1 - Need IDatabaseCluster interface to have grantDataApiAccess() method published as part of the interface (the method was there but not published in the interface, when IServerlessCLuster interface have it published. 

2 - need DatabaseCluster.grantDataApiAccess() to follow the same IAM permission pattern than ServerlessCluster.grantDataApiAccess() to have consistency. 

ServerlessCluster.grantDataApiAccess() method is adding automatically the required permission to secret manager if Data API is enabled. 

However, DatabaseCluster.grantDataApiAccess() do not. As such without the change it will have been required for end users to add that IAM permission to secret manager as an extra line when they will have assigned a serverless V2 cluster to AppSync datasource. 

To keep the experience unified across the 2 type of RDS clusters, i updated the method to have that IAM permission embedded.

### Description of how you validated changes

- Unit test created for the new feature
- Unit test updated and validated for RDS changes
- Integration test created for the new feature

I run all unit test and the integration test successfully.


### 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
sebastien6 authored Apr 10, 2024
1 parent f7d4f41 commit 1894f2d
Show file tree
Hide file tree
Showing 23 changed files with 3,798 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
schema {
query: Query
mutation: Mutation
}

type Query {
getPost(id:ID!): Post
allPosts: [Post]
}

type Mutation {
addPost(id: ID!, author: String!, title: String, content: String, url: String): Post!
}

type Post {
id: ID!
author: String!
title: String
content: String
url: String
ups: Int
downs: Int
relatedPosts: [Post]
relatedPostsMaxBatchSize: [Post]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1894f2d

Please sign in to comment.