Skip to content

Commit 23ca6fc

Browse files
authored
feat(rds): add fromLookup method for Amazon Aurora Database Cluster (#34849)
### Issue # (if applicable) Closes #34848 . ### Reason for this change Implement a lookup function for RDS DatabaseCluster similar to the existing DatabaseInstance.fromLookup functionality. #33258 This allows users to fetch an Aurora RDS cluster reference by identifier rather than having to manually provide all connection details. ### Description of changes Add `fromLookup` method to `DatabaseCluster`. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Add unit tests and an integ test. ### 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*
1 parent 965e055 commit 23ca6fc

12 files changed

+1052
-2
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-lookup.js.snapshot/aws-cdk-rds-cluster-lookup.assets.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
{
2+
"Outputs": {
3+
"LookedUpClusterEndpoint": {
4+
"Value": "TESTADDRESS:5432"
5+
},
6+
"LookedUpClusterReadEndpoint": {
7+
"Value": "TESTREADERADDRESS:5432"
8+
},
9+
"LookedUpClusterIdentifier": {
10+
"Value": "test-cluster-lookup"
11+
},
12+
"LookedUpClusterResourceIdentifier": {
13+
"Value": "TESTID"
14+
},
15+
"LookedUpClusterArn": {
16+
"Value": {
17+
"Fn::Join": [
18+
"",
19+
[
20+
"arn:",
21+
{
22+
"Ref": "AWS::Partition"
23+
},
24+
":rds:test-region:12345678:cluster:test-cluster-lookup"
25+
]
26+
]
27+
}
28+
},
29+
"SecurityGroupIds": {
30+
"Value": ""
31+
}
32+
},
33+
"Resources": {
34+
"DbAccessRole408BD73D": {
35+
"Type": "AWS::IAM::Role",
36+
"Properties": {
37+
"AssumeRolePolicyDocument": {
38+
"Statement": [
39+
{
40+
"Action": "sts:AssumeRole",
41+
"Effect": "Allow",
42+
"Principal": {
43+
"Service": "ec2.amazonaws.com"
44+
}
45+
}
46+
],
47+
"Version": "2012-10-17"
48+
},
49+
"Description": "Role for accessing the Aurora cluster via IAM authentication"
50+
}
51+
},
52+
"DbAccessRoleDefaultPolicy8020DC70": {
53+
"Type": "AWS::IAM::Policy",
54+
"Properties": {
55+
"PolicyDocument": {
56+
"Statement": [
57+
{
58+
"Action": "rds-db:connect",
59+
"Effect": "Allow",
60+
"Resource": {
61+
"Fn::Join": [
62+
"",
63+
[
64+
"arn:",
65+
{
66+
"Ref": "AWS::Partition"
67+
},
68+
":rds-db:test-region:12345678:dbuser:TESTID/admin"
69+
]
70+
]
71+
}
72+
},
73+
{
74+
"Action": [
75+
"rds-data:BatchExecuteStatement",
76+
"rds-data:BeginTransaction",
77+
"rds-data:CommitTransaction",
78+
"rds-data:ExecuteStatement",
79+
"rds-data:RollbackTransaction"
80+
],
81+
"Effect": "Allow",
82+
"Resource": {
83+
"Fn::Join": [
84+
"",
85+
[
86+
"arn:",
87+
{
88+
"Ref": "AWS::Partition"
89+
},
90+
":rds:test-region:12345678:cluster:test-cluster-lookup"
91+
]
92+
]
93+
}
94+
}
95+
],
96+
"Version": "2012-10-17"
97+
},
98+
"PolicyName": "DbAccessRoleDefaultPolicy8020DC70",
99+
"Roles": [
100+
{
101+
"Ref": "DbAccessRole408BD73D"
102+
}
103+
]
104+
}
105+
},
106+
"HighConnectionsAlarm3E20B33C": {
107+
"Type": "AWS::CloudWatch::Alarm",
108+
"Properties": {
109+
"AlarmDescription": "Database has high number of connections",
110+
"ComparisonOperator": "GreaterThanThreshold",
111+
"Dimensions": [
112+
{
113+
"Name": "DBClusterIdentifier",
114+
"Value": "test-cluster-lookup"
115+
}
116+
],
117+
"EvaluationPeriods": 3,
118+
"MetricName": "DatabaseConnections",
119+
"Namespace": "AWS/RDS",
120+
"Period": 300,
121+
"Statistic": "Average",
122+
"Threshold": 100
123+
}
124+
},
125+
"HighCPUAlarm56BE6E7D": {
126+
"Type": "AWS::CloudWatch::Alarm",
127+
"Properties": {
128+
"AlarmDescription": "Database CPU utilization is high",
129+
"ComparisonOperator": "GreaterThanThreshold",
130+
"Dimensions": [
131+
{
132+
"Name": "DBClusterIdentifier",
133+
"Value": "test-cluster-lookup"
134+
}
135+
],
136+
"EvaluationPeriods": 3,
137+
"MetricName": "CPUUtilization",
138+
"Namespace": "AWS/RDS",
139+
"Period": 300,
140+
"Statistic": "Average",
141+
"Threshold": 90
142+
}
143+
},
144+
"LowMemoryAlarmD9E02E14": {
145+
"Type": "AWS::CloudWatch::Alarm",
146+
"Properties": {
147+
"AlarmDescription": "Database is running low on memory",
148+
"ComparisonOperator": "LessThanThreshold",
149+
"Dimensions": [
150+
{
151+
"Name": "DBClusterIdentifier",
152+
"Value": "test-cluster-lookup"
153+
}
154+
],
155+
"EvaluationPeriods": 3,
156+
"MetricName": "FreeableMemory",
157+
"Namespace": "AWS/RDS",
158+
"Period": 300,
159+
"Statistic": "Average",
160+
"Threshold": 104857600
161+
}
162+
},
163+
"DeadlockAlarmC7257573": {
164+
"Type": "AWS::CloudWatch::Alarm",
165+
"Properties": {
166+
"AlarmDescription": "Database has deadlocks",
167+
"ComparisonOperator": "GreaterThanThreshold",
168+
"Dimensions": [
169+
{
170+
"Name": "DBClusterIdentifier",
171+
"Value": "test-cluster-lookup"
172+
}
173+
],
174+
"EvaluationPeriods": 2,
175+
"MetricName": "Deadlocks",
176+
"Namespace": "AWS/RDS",
177+
"Period": 300,
178+
"Statistic": "Average",
179+
"Threshold": 5
180+
}
181+
}
182+
},
183+
"Parameters": {
184+
"BootstrapVersion": {
185+
"Type": "AWS::SSM::Parameter::Value<String>",
186+
"Default": "/cdk-bootstrap/hnb659fds/version",
187+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
188+
}
189+
},
190+
"Rules": {
191+
"CheckBootstrapVersion": {
192+
"Assertions": [
193+
{
194+
"Assert": {
195+
"Fn::Not": [
196+
{
197+
"Fn::Contains": [
198+
[
199+
"1",
200+
"2",
201+
"3",
202+
"4",
203+
"5"
204+
],
205+
{
206+
"Ref": "BootstrapVersion"
207+
}
208+
]
209+
}
210+
]
211+
},
212+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
213+
}
214+
]
215+
}
216+
}
217+
}

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-lookup.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-lookup.js.snapshot/integ.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-lookup.js.snapshot/integrdsclusterfromlookupDefaultTestDeployAssert0EEE7886.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-lookup.js.snapshot/integrdsclusterfromlookupDefaultTestDeployAssert0EEE7886.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)