Skip to content

Commit 5fff3d6

Browse files
feat(ecr): lookup existing repository (#33662)
### Issue # (if applicable) Closes #8461. ### Reason for this change `ecr.Repository` construct does not support lookup method. ### Description of changes - Add `fromLookup` method ### Describe any new or updated permissions being added None ### Description of how you validated changes Add both 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*
1 parent 4e958d4 commit 5fff3d6

12 files changed

+702
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ecr/test/integ.repository-lookup.js.snapshot/EcrRepoLookupStack.assets.json

+20
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,140 @@
1+
{
2+
"Resources": {
3+
"LambdaServiceRoleA8ED4D3B": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"LambdaServiceRoleDefaultPolicyDAE46E21": {
35+
"Type": "AWS::IAM::Policy",
36+
"Properties": {
37+
"PolicyDocument": {
38+
"Statement": [
39+
{
40+
"Action": [
41+
"ecr:DescribeImages",
42+
"ecr:DescribeRepositories"
43+
],
44+
"Effect": "Allow",
45+
"Resource": {
46+
"Fn::Join": [
47+
"",
48+
[
49+
"arn:",
50+
{
51+
"Ref": "AWS::Partition"
52+
},
53+
":ecr:us-east-1:123456789012:repository/DUMMY_ARN"
54+
]
55+
]
56+
}
57+
}
58+
],
59+
"Version": "2012-10-17"
60+
},
61+
"PolicyName": "LambdaServiceRoleDefaultPolicyDAE46E21",
62+
"Roles": [
63+
{
64+
"Ref": "LambdaServiceRoleA8ED4D3B"
65+
}
66+
]
67+
}
68+
},
69+
"LambdaD247545B": {
70+
"Type": "AWS::Lambda::Function",
71+
"Properties": {
72+
"Code": {
73+
"ZipFile": "exports.handler = async function(event, context) { return \"Hello, World!\"; }"
74+
},
75+
"Handler": "index.handler",
76+
"Role": {
77+
"Fn::GetAtt": [
78+
"LambdaServiceRoleA8ED4D3B",
79+
"Arn"
80+
]
81+
},
82+
"Runtime": "nodejs20.x"
83+
},
84+
"DependsOn": [
85+
"LambdaServiceRoleDefaultPolicyDAE46E21",
86+
"LambdaServiceRoleA8ED4D3B"
87+
]
88+
}
89+
},
90+
"Outputs": {
91+
"RepositoryUri": {
92+
"Value": {
93+
"Fn::Join": [
94+
"",
95+
[
96+
"123456789012.dkr.ecr.us-east-1.",
97+
{
98+
"Ref": "AWS::URLSuffix"
99+
},
100+
"/DUMMY_ARN"
101+
]
102+
]
103+
}
104+
}
105+
},
106+
"Parameters": {
107+
"BootstrapVersion": {
108+
"Type": "AWS::SSM::Parameter::Value<String>",
109+
"Default": "/cdk-bootstrap/hnb659fds/version",
110+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
111+
}
112+
},
113+
"Rules": {
114+
"CheckBootstrapVersion": {
115+
"Assertions": [
116+
{
117+
"Assert": {
118+
"Fn::Not": [
119+
{
120+
"Fn::Contains": [
121+
[
122+
"1",
123+
"2",
124+
"3",
125+
"4",
126+
"5"
127+
],
128+
{
129+
"Ref": "BootstrapVersion"
130+
}
131+
]
132+
}
133+
]
134+
},
135+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
136+
}
137+
]
138+
}
139+
}
140+
}

packages/@aws-cdk-testing/framework-integ/test/aws-ecr/test/integ.repository-lookup.js.snapshot/EcrRepoLookupTestDefaultTestDeployAssert7F088AF3.assets.json

+19
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-ecr/test/integ.repository-lookup.js.snapshot/EcrRepoLookupTestDefaultTestDeployAssert7F088AF3.template.json

+36
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-ecr/test/integ.repository-lookup.js.snapshot/cdk.out

+1
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-ecr/test/integ.repository-lookup.js.snapshot/integ.json

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)