-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rds): add clusterArn property to DatabaseCluster #29289
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4052,6 +4052,34 @@ describe('cluster', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
test('check that clusterArn property works', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aws-cdk/packages/aws-cdk-lib/aws-rds/test/serverless-cluster.test.ts Lines 602 to 627 in 1f30b5d
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
// GIVEN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
const stack = testStack(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
const vpc = new ec2.Vpc(stack, 'VPC'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
const exportName = 'DbCluterArn'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
// WHEN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
const cluster = new DatabaseCluster(stack, 'Database', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
engine: DatabaseClusterEngine.AURORA, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
writer: ClusterInstance.provisioned('writer'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
vpc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
new cdk.CfnOutput(stack, exportName, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
exportName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
value: cluster.clusterArn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
// THEN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
expect(stack.resolve(cluster.clusterArn)).toEqual({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
'Fn::Join': ['', [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
'arn:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ Ref: 'AWS::Partition' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
':rds:us-test-1:12345:cluster:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ Ref: 'DatabaseB269D8BB' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
test.each([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just like
ServerlessCluster
aws-cdk/packages/aws-cdk-lib/aws-rds/lib/serverless-cluster.ts
Lines 345 to 355 in 1f30b5d
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.
@blimmer Is this how CDK normally handles this? I ask because the output becomes a
Join
instead of doing aGetAtt
on the resource. Trying to wrap my head around why we should do this over theGetAtt
path. I tried looking at the Lambda Function L2, since there is areadonly
property for the Arn.Honestly not sure if it matters (likely not) but trying to learn different parts of this as I go. To me seems like we have two patterns going on, the one you have here and the
readonly
property for the Arn.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.
I'm not sure - I just followed the pattern in the linked code. One of the core contributors might be able to tell us.
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.
I asked the team directly. I did find SQS which does this differently. https://github.com/aws/aws-cdk/blob/v2.130.0/packages/aws-cdk-lib/aws-sqs/lib/queue.ts#L437-L440
CFN Synth
Which fits my mental model better. I am not sure if there is a big difference or a reason it was done this way in RDS. Maybe one is a "legacy" way of doing things.
Generally, this looks fine. I just want to get some deeper clarity on what is typical.
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.
@jfuss Sorry to jump in - I was looking at something similar recently. This is a very typical pattern that is used in the codebase here are just a few examples:
aws-cdk/packages/aws-cdk-lib/aws-kms/lib/alias.ts
Line 69 in 0d6ef63
aws-cdk/packages/aws-cdk-lib/aws-docdb/lib/instance.ts
Line 103 in 0d6ef63
aws-cdk/packages/aws-cdk-lib/aws-apigateway/lib/stage.ts
Line 260 in 0d6ef63
Also, this is just a "getter" for the
clusterArn
so I don't think we want to be producing any outputs in the synthesized template. Instead, this just allowsclusterArn
to be exposed for use throughout the rest of their app.