Skip to content

Commit 8fdfa8f

Browse files
authored
Merge branch 'master' into fix-dotnet-run-project-deprecation-warning
2 parents 96a488e + 97a9b51 commit 8fdfa8f

File tree

312 files changed

+3495
-1148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+3495
-1148
lines changed

.github/workflows/issue-label-assign.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
{"area":"@aws-cdk/app-delivery","keywords":["app-delivery","PipelineDeployStackAction"],"labels":["@aws-cdk/app-delivery"],"assignees":["skinny85"]},
2727
{"area":"@aws-cdk/assert","keywords":["assert"],"labels":["@aws-cdk/assert"],"assignees":["kaizen3031593"]},
2828
{"area":"@aws-cdk/assertions","keywords":["assertions"],"labels":["@aws-cdk/assertions"],"assignees":["kaizen3031593"]},
29-
{"area":"@aws-cdk/assets","keywords":["assets","staging"],"labels":["@aws-cdk/assets"],"assignees":["eladb"]},
29+
{"area":"@aws-cdk/assets","keywords":["assets","staging"],"labels":["@aws-cdk/assets"],"assignees":["otaviomacedo"]},
3030
{"area":"@aws-cdk/aws-accessanalyzer","keywords":["aws-accessanalyzer","accessanalyzer","cfnanalyzer"],"labels":["@aws-cdk/aws-accessanalyzer"],"assignees":["skinny85"]},
3131
{"area":"@aws-cdk/aws-acmpca","keywords":["aws-acmpca","acmpca","certificateauthority"],"labels":["@aws-cdk/aws-acmpca"],"assignees":["skinny85"]},
3232
{"area":"@aws-cdk/aws-amazonmq","keywords":["aws-amazonmq","amazonmq","cfnbroker"],"labels":["@aws-cdk/aws-amazonmq"],"assignees":["otaviomacedo"]},
@@ -92,7 +92,7 @@ jobs:
9292
{"area":"@aws-cdk/aws-dynamodb-global","keywords":["aws-dynamodb-global","dynamodb global"],"labels":["@aws-cdk/aws-dynamodb-global"],"assignees":["skinny85"]},
9393
{"area":"@aws-cdk/aws-ec2","keywords":["aws-ec2","ec2","vpc","privatesubnet","publicsubnet","vpngateway","vpnconnection","networkacl"],"labels":["@aws-cdk/aws-ec2"],"assignees":["njlynch"]},
9494
{"area":"@aws-cdk/aws-ecr","keywords":["aws-ecr","ecr"],"labels":["@aws-cdk/aws-ecr"],"assignees":["madeline-k"]},
95-
{"area":"@aws-cdk/aws-ecr-assets","keywords":["aws-ecr-assets","ecrassets"],"labels":["@aws-cdk/aws-ecr-assets"],"assignees":["eladb"]},
95+
{"area":"@aws-cdk/aws-ecr-assets","keywords":["aws-ecr-assets","ecrassets"],"labels":["@aws-cdk/aws-ecr-assets"],"assignees":["madeline-k"]},
9696
{"area":"@aws-cdk/aws-ecs","keywords":["(aws-ecs)","(ecs)"],"labels":["@aws-cdk/aws-ecs"],"assignees":["madeline-k"]},
9797
{"area":"@aws-cdk/aws-ecs-patterns","keywords":["(aws-ecs-patterns)","(ecs-patterns)"],"labels":["@aws-cdk/aws-ecs-patterns"],"assignees":["madeline-k"]},
9898
{"area":"@aws-cdk/aws-efs","keywords":["aws-efs","efs","accesspoint"],"labels":["@aws-cdk/aws-efs"],"assignees":["corymhall"]},
@@ -224,7 +224,7 @@ jobs:
224224
{"area":"@aws-cdk/custom-resources","keywords":["custom-resource","provider"],"labels":["@aws-cdk/custom-resources"],"assignees":["rix0rrr"]},
225225
{"area":"@aws-cdk/cx-api","keywords":["cx-api","cloudartifact","cloudassembly"],"labels":["@aws-cdk/cx-api"],"assignees":["rix0rrr"]},
226226
{"area":"@aws-cdk/aws-lambda-layer-awscli","keywords":["(aws-lambda-layer-awscli)","(lambda-layer-awscli)"],"labels":["@aws-cdk/aws-lambda-layer-awscli"],"assignees":["rix0rrr"]},
227-
{"area":"@aws-cdk/aws-lambda-layer-kubectl","keywords":["(aws-lambda-layer-kubectl)","(lambda-layer-kubectl)"],"labels":["@aws-cdk/aws-lambda-layer-kubectl"],"assignees":["eladb"]},
227+
{"area":"@aws-cdk/aws-lambda-layer-kubectl","keywords":["(aws-lambda-layer-kubectl)","(lambda-layer-kubectl)"],"labels":["@aws-cdk/aws-lambda-layer-kubectl"],"assignees":["otaviomacedo"]},
228228
{"area":"@aws-cdk/pipelines","keywords":["pipelines","cdk-pipelines","sourceaction","synthaction"],"labels":["@aws-cdk/pipelines"],"assignees":["rix0rrr"]},
229229
{"area":"@aws-cdk/region-info","keywords":["region-info","fact"],"labels":["@aws-cdk/region-info"],"assignees":["skinny85"]},
230230
{"area":"aws-cdk-lib","keywords":["aws-cdk-lib","cdk-v2","v2","ubergen"],"labels":["aws-cdk-lib"],"assignees":["njlynch"]},

packages/@aws-cdk/app-delivery/test/integ.cicd.expected.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"s3:List*",
3535
"s3:DeleteObject*",
3636
"s3:PutObject",
37+
"s3:PutObjectLegalHold",
38+
"s3:PutObjectRetention",
39+
"s3:PutObjectTagging",
40+
"s3:PutObjectVersionTagging",
3741
"s3:Abort*"
3842
],
3943
"Effect": "Allow",

packages/@aws-cdk/assert-internal/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
---
55

6-
![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
6+
![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)
77

8-
> The APIs of higher level constructs in this module are experimental and under active development.
9-
> They are subject to non-backward compatible changes or removal in any future version. These are
10-
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
11-
> announced in the release notes. This means that while you may use them, you may need to update
12-
> your source code when upgrading to a newer version of this package.
8+
> This API may emit warnings. Backward compatibility is not guaranteed.
139
14-
If using monocdk, use [@monocdk-experiment/assert](https://www.npmjs.com/package/@monocdk-experiment/assert) instead.
10+
## Replacement recommended
11+
12+
This library has been deprecated. We recommend you use the
13+
[@aws-cdk/assertions](https://docs.aws.amazon.com/cdk/api/v1/docs/assertions-readme.html) module instead.
1514

1615
---
1716

packages/@aws-cdk/assert-internal/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"engines": {
5656
"node": ">= 10.13.0 <13 || >=13.7.0"
5757
},
58-
"stability": "experimental",
59-
"maturity": "experimental",
58+
"stability": "deprecated",
59+
"maturity": "deprecated",
6060
"publishConfig": {
6161
"tag": "latest"
6262
},

packages/@aws-cdk/assert/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
"exclude": true
7272
},
7373
"nozem": false,
74-
"stability": "experimental",
75-
"maturity": "developer-preview",
74+
"stability": "deprecated",
75+
"maturity": "deprecated",
7676
"publishConfig": {
7777
"tag": "latest-1"
7878
}

packages/@aws-cdk/aws-apprunner/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
},
8484
"license": "Apache-2.0",
8585
"devDependencies": {
86-
"@aws-cdk/assert-internal": "0.0.0",
8786
"@aws-cdk/assertions": "0.0.0",
8887
"@aws-cdk/cdk-build-tools": "0.0.0",
8988
"@aws-cdk/cdk-integ-tools": "0.0.0",

packages/@aws-cdk/aws-certificatemanager/lambda-packages/dns_validated_certificate_handler/lib/index.js

Lines changed: 96 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -110,69 +110,28 @@ const requestCertificate = async function (requestId, domainName, subjectAlterna
110110

111111
console.log('Waiting for ACM to provide DNS records for validation...');
112112

113-
let records;
114-
for (let attempt = 0; attempt < maxAttempts && !records; attempt++) {
113+
let records = [];
114+
for (let attempt = 0; attempt < maxAttempts && !records.length; attempt++) {
115115
const { Certificate } = await acm.describeCertificate({
116116
CertificateArn: reqCertResponse.CertificateArn
117117
}).promise();
118-
const options = Certificate.DomainValidationOptions || [];
119-
// Ensure all records are ready; there is (at least a theory there's) a chance of a partial response here in rare cases.
120-
if (options.length > 0 && options.every(opt => opt && !!opt.ResourceRecord)) {
121-
// some alternative names will produce the same validation record
122-
// as the main domain (eg. example.com + *.example.com)
123-
// filtering duplicates to avoid errors with adding the same record
124-
// to the route53 zone twice
125-
const unique = options
126-
.map((val) => val.ResourceRecord)
127-
.reduce((acc, cur) => {
128-
acc[cur.Name] = cur;
129-
return acc;
130-
}, {});
131-
records = Object.keys(unique).sort().map(key => unique[key]);
132-
} else {
118+
119+
records = getDomainValidationRecords(Certificate);
120+
if (!records.length) {
133121
// Exponential backoff with jitter based on 200ms base
134122
// component of backoff fixed to ensure minimum total wait time on
135123
// slow targets.
136124
const base = Math.pow(2, attempt);
137125
await sleep(random() * base * 50 + base * 150);
138126
}
139127
}
140-
if (!records) {
128+
if (!records.length) {
141129
throw new Error(`Response from describeCertificate did not contain DomainValidationOptions after ${maxAttempts} attempts.`)
142130
}
143131

144-
145132
console.log(`Upserting ${records.length} DNS records into zone ${hostedZoneId}:`);
146133

147-
const changeBatch = await route53.changeResourceRecordSets({
148-
ChangeBatch: {
149-
Changes: records.map((record) => {
150-
console.log(`${record.Name} ${record.Type} ${record.Value}`)
151-
return {
152-
Action: 'UPSERT',
153-
ResourceRecordSet: {
154-
Name: record.Name,
155-
Type: record.Type,
156-
TTL: 60,
157-
ResourceRecords: [{
158-
Value: record.Value
159-
}]
160-
}
161-
};
162-
}),
163-
},
164-
HostedZoneId: hostedZoneId
165-
}).promise();
166-
167-
console.log('Waiting for DNS records to commit...');
168-
await route53.waitFor('resourceRecordSetsChanged', {
169-
// Wait up to 5 minutes
170-
$waiter: {
171-
delay: 30,
172-
maxAttempts: 10
173-
},
174-
Id: changeBatch.ChangeInfo.Id
175-
}).promise();
134+
await commitRoute53Records(route53, records, hostedZoneId);
176135

177136
console.log('Waiting for validation...');
178137
await acm.waitFor('certificateValidated', {
@@ -193,47 +152,126 @@ const requestCertificate = async function (requestId, domainName, subjectAlterna
193152
*
194153
* @param {string} arn The certificate ARN
195154
*/
196-
const deleteCertificate = async function (arn, region) {
155+
const deleteCertificate = async function (arn, region, hostedZoneId, route53Endpoint, cleanupRecords) {
197156
const acm = new aws.ACM({ region });
157+
const route53 = route53Endpoint ? new aws.Route53({ endpoint: route53Endpoint }) : new aws.Route53();
158+
if (waiter) {
159+
// Used by the test suite, since waiters aren't mockable yet
160+
route53.waitFor = acm.waitFor = waiter;
161+
}
198162

199163
try {
200164
console.log(`Waiting for certificate ${arn} to become unused`);
201165

202166
let inUseByResources;
167+
let records = [];
203168
for (let attempt = 0; attempt < maxAttempts; attempt++) {
204169
const { Certificate } = await acm.describeCertificate({
205170
CertificateArn: arn
206171
}).promise();
207172

173+
if (cleanupRecords) {
174+
records = getDomainValidationRecords(Certificate);
175+
}
208176
inUseByResources = Certificate.InUseBy || [];
209177

210-
if (inUseByResources.length) {
178+
if (inUseByResources.length || !records.length) {
211179
// Exponential backoff with jitter based on 200ms base
212180
// component of backoff fixed to ensure minimum total wait time on
213181
// slow targets.
214182
const base = Math.pow(2, attempt);
215183
await sleep(random() * base * 50 + base * 150);
216184
} else {
217-
break
185+
break;
218186
}
219187
}
220188

221189
if (inUseByResources.length) {
222190
throw new Error(`Response from describeCertificate did not contain an empty InUseBy list after ${maxAttempts} attempts.`)
223191
}
192+
if (cleanupRecords && !records.length) {
193+
throw new Error(`Response from describeCertificate did not contain DomainValidationOptions after ${maxAttempts} attempts.`)
194+
}
224195

225196
console.log(`Deleting certificate ${arn}`);
226197

227198
await acm.deleteCertificate({
228199
CertificateArn: arn
229200
}).promise();
201+
202+
if (cleanupRecords) {
203+
console.log(`Deleting ${records.length} DNS records from zone ${hostedZoneId}:`);
204+
205+
await commitRoute53Records(route53, records, hostedZoneId, 'DELETE');
206+
}
207+
230208
} catch (err) {
231209
if (err.name !== 'ResourceNotFoundException') {
232210
throw err;
233211
}
234212
}
235213
};
236214

215+
/**
216+
* Retrieve the unique domain validation options as records to be upserted (or deleted) from Route53.
217+
*
218+
* Returns an empty array ([]) if the domain validation options is empty or the records are not yet ready.
219+
*/
220+
function getDomainValidationRecords(certificate) {
221+
const options = certificate.DomainValidationOptions || [];
222+
// Ensure all records are ready; there is (at least a theory there's) a chance of a partial response here in rare cases.
223+
if (options.length > 0 && options.every(opt => opt && !!opt.ResourceRecord)) {
224+
// some alternative names will produce the same validation record
225+
// as the main domain (eg. example.com + *.example.com)
226+
// filtering duplicates to avoid errors with adding the same record
227+
// to the route53 zone twice
228+
const unique = options
229+
.map((val) => val.ResourceRecord)
230+
.reduce((acc, cur) => {
231+
acc[cur.Name] = cur;
232+
return acc;
233+
}, {});
234+
return Object.keys(unique).sort().map(key => unique[key]);
235+
}
236+
return [];
237+
}
238+
239+
/**
240+
* Execute Route53 ChangeResourceRecordSets for a set of records within a Hosted Zone,
241+
* and wait for the records to commit. Defaults to an 'UPSERT' action.
242+
*/
243+
async function commitRoute53Records(route53, records, hostedZoneId, action = 'UPSERT') {
244+
const changeBatch = await route53.changeResourceRecordSets({
245+
ChangeBatch: {
246+
Changes: records.map((record) => {
247+
console.log(`${record.Name} ${record.Type} ${record.Value}`);
248+
return {
249+
Action: action,
250+
ResourceRecordSet: {
251+
Name: record.Name,
252+
Type: record.Type,
253+
TTL: 60,
254+
ResourceRecords: [{
255+
Value: record.Value
256+
}]
257+
}
258+
};
259+
}),
260+
},
261+
HostedZoneId: hostedZoneId
262+
}).promise();
263+
264+
console.log('Waiting for DNS records to commit...');
265+
await route53.waitFor('resourceRecordSetsChanged', {
266+
// Wait up to 5 minutes
267+
$waiter: {
268+
delay: 30,
269+
maxAttempts: 10
270+
},
271+
Id: changeBatch.ChangeInfo.Id
272+
}).promise();
273+
}
274+
237275
/**
238276
* Main handler, invoked by Lambda
239277
*/
@@ -262,7 +300,13 @@ exports.certificateRequestHandler = async function (event, context) {
262300
// If the resource didn't create correctly, the physical resource ID won't be the
263301
// certificate ARN, so don't try to delete it in that case.
264302
if (physicalResourceId.startsWith('arn:')) {
265-
await deleteCertificate(physicalResourceId, event.ResourceProperties.Region);
303+
await deleteCertificate(
304+
physicalResourceId,
305+
event.ResourceProperties.Region,
306+
event.ResourceProperties.HostedZoneId,
307+
event.ResourceProperties.Route53Endpoint,
308+
event.ResourceProperties.CleanupRecords === "true",
309+
);
266310
}
267311
break;
268312
default:

0 commit comments

Comments
 (0)