Skip to content

Commit 6d581d7

Browse files
authored
chore(cdk-lib): migrate to [email protected] / [email protected] (#24425)
Updates dependencies & code as necessary to use `[email protected]` to build the AWS CDK. BREAKING CHANGE: The return type of `aws-cdk-lib.aws_ec2.SecurityGroup.determineRuleScope` was changed from a tuple (`[SecurityGroupBase, string]`) to a struct with the same values, because tuple types are not supported over the jsii interoperability layer, but `jsii@v1` was incorrectly allowing this to be represented as the `JSON` primitive type. This made the API unusable in non-JS languages. The type of the `metadata` property of `aws-cdk-lib.aws_s3_deployment.BucketDeploymentProps` was changed from an index-only struct to an inline map, because `jsii@v1` silently ignored the index signature (which is otherwise un-supported), resulting in an empty object in non-JS/TS languages. As a consequence, the values of that map can no longer be `undefined` (as `jsii` does not currently support nullable elements in collections). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8dbca12 commit 6d581d7

File tree

482 files changed

+1090
-1015
lines changed

Some content is hidden

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

482 files changed

+1090
-1015
lines changed

allowed-breaking-changes.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,9 @@ strengthened:aws-cdk-lib.pipelines.ProduceActionOptions
158158
# reverted a change that broke deployments for anyone using Triggers
159159
removed:aws-cdk-lib.triggers.InvocationType
160160
removed:aws-cdk-lib.triggers.TriggerProps.invocationType
161-
removed:aws-cdk-lib.triggers.TriggerProps.timeout
161+
removed:aws-cdk-lib.triggers.TriggerProps.timeout
162+
163+
# broken: it used to return a tuple type, that was incorrectly interpreted by jsii
164+
change-return-type:aws-cdk-lib.aws_ec2.SecurityGroup.determineRuleScope
165+
# broken only in non-JS/TS, where that was not previously usable
166+
strengthened:aws-cdk-lib.aws_s3_deployment.BucketDeploymentProps

build.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ while [[ "${1:-}" != "" ]]; do
3636
done
3737

3838
export PATH=$(npm bin):$PATH
39-
export NODE_OPTIONS="--max-old-space-size=4096 --experimental-worker ${NODE_OPTIONS:-}"
39+
export NODE_OPTIONS="--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"
4040

4141
if ! [ -x "$(command -v yarn)" ]; then
4242
echo "yarn is not installed. Install it from here- https://yarnpkg.com/en/docs/install."
@@ -78,9 +78,12 @@ if [ "$run_tests" == "true" ]; then
7878
runtarget="$runtarget+test"
7979
fi
8080

81+
# Limit top-level concurrency to available CPUs - 1 to limit CPU load.
82+
concurrency=$(node -p 'Math.max(1, require("os").cpus().length - 1)')
83+
8184
echo "============================================================================================="
8285
echo "building..."
83-
time lerna run $bail --stream $runtarget || fail
86+
time lerna run $bail --stream --concurrency=$concurrency $runtarget || fail
8487

8588
if [ "$check_compat" == "true" ]; then
8689
/bin/bash scripts/check-api-compatibility.sh

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
"fs-extra": "^9.1.0",
2525
"graceful-fs": "^4.2.10",
2626
"jest-junit": "^13.2.0",
27-
"jsii-diff": "1.77.0",
28-
"jsii-pacmak": "1.77.0",
29-
"jsii-reflect": "1.77.0",
30-
"jsii-rosetta": "v4.9-next",
27+
"jsii-diff": "1.78.1",
28+
"jsii-pacmak": "1.78.1",
29+
"jsii-reflect": "1.78.1",
30+
"jsii-rosetta": "~5.0.0",
3131
"lerna": "^4.0.0",
3232
"patch-package": "^6.5.1",
3333
"semver": "^6.3.0",
3434
"standard-version": "^9.5.0",
35-
"typescript": "~3.9.10"
35+
"typescript": "~4.9.5"
3636
},
3737
"resolutions": {
3838
"colors": "1.4.0",

packages/@aws-cdk-testing/cli-integ/lib/aws.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class AwsClients {
7474
public async stackStatus(stackName: string): Promise<string | undefined> {
7575
try {
7676
return (await this.cloudFormation('describeStacks', { StackName: stackName })).Stacks?.[0].StackStatus;
77-
} catch (e) {
77+
} catch (e: any) {
7878
if (isStackMissingError(e)) { return undefined; }
7979
throw e;
8080
}
@@ -113,7 +113,7 @@ export class AwsClients {
113113
await this.s3('deleteBucket', {
114114
Bucket: bucketName,
115115
});
116-
} catch (e) {
116+
} catch (e: any) {
117117
if (isBucketMissingError(e)) { return; }
118118
throw e;
119119
}
@@ -126,15 +126,16 @@ export class AwsClients {
126126
* Create the correct client, do the call and resole the promise().
127127
*/
128128
async function awsCall<
129-
A extends AWS.Service,
130-
B extends keyof ServiceCalls<A>,
131-
>(ctor: new (config: any) => A, config: any, call: B, request: First<ServiceCalls<A>[B]>): Promise<Second<ServiceCalls<A>[B]>> {
129+
Svc extends AWS.Service,
130+
Calls extends ServiceCalls<Svc>,
131+
Call extends keyof Calls,
132+
>(ctor: new (config: any) => Svc, config: any, call: Call, request: First<Calls[Call]>): Promise<Second<Calls[Call]>> {
132133
const cfn = new ctor(config);
133-
const response = cfn[call](request);
134+
const response = ((cfn as any)[call] as any)(request);
134135
try {
135136
return response.promise();
136-
} catch (e) {
137-
const newErr = new Error(`${call}(${JSON.stringify(request)}): ${e.message}`);
137+
} catch (e: any) {
138+
const newErr = new Error(`${String(call)}(${JSON.stringify(request)}): ${e.message}`);
138139
(newErr as any).code = e.code;
139140
throw newErr;
140141
}
@@ -210,7 +211,7 @@ export async function retry<A>(output: NodeJS.WritableStream, operation: string,
210211
const ret = await block();
211212
output.write(`💈 ${operation}: succeeded after ${i} attempts\n`);
212213
return ret;
213-
} catch (e) {
214+
} catch (e: any) {
214215
if (e.abort || Date.now() > deadline.getTime( )) {
215216
throw new Error(`${operation}: did not succeed after ${i} attempts: ${e}`);
216217
}
@@ -290,4 +291,4 @@ function chainableCredentials(region: string): AWS.Credentials | undefined {
290291
}
291292

292293
return undefined;
293-
}
294+
}

packages/@aws-cdk-testing/cli-integ/lib/integ-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function integTest(
4848
output.write(`${s}\n`);
4949
},
5050
});
51-
} catch (e) {
51+
} catch (e: any) {
5252
process.stderr.write(`[INTEG TEST::${name}] Failed: ${e}\n`);
5353
output.write(e.message);
5454
output.write(e.stack);

packages/@aws-cdk-testing/cli-integ/lib/shell.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export function rimraf(fsPath: string) {
151151
} else {
152152
fs.unlinkSync(fsPath);
153153
}
154-
} catch (e) {
154+
} catch (e: any) {
155155
// We will survive ENOENT
156156
if (e.code !== 'ENOENT') { throw e; }
157157
}
@@ -165,4 +165,4 @@ export function addToShellPath(x: string) {
165165
}
166166

167167
process.env.PATH = parts.join(':');
168-
}
168+
}

packages/@aws-cdk-testing/cli-integ/lib/staging/codeartifact.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class TestRepository {
112112

113113
// eslint-disable-next-line no-console
114114
console.log('Deleted', this.repositoryName);
115-
} catch (e) {
115+
} catch (e: any) {
116116
if (e.code !== 'ResourceNotFoundException') { throw e; }
117117
// Okay
118118
}
@@ -199,7 +199,7 @@ export class TestRepository {
199199
try {
200200
await this.codeArtifact.describeDomain({ domain: this.domain }).promise();
201201
return true;
202-
} catch (e) {
202+
} catch (e: any) {
203203
if (e.code !== 'ResourceNotFoundException') { throw e; }
204204
return false;
205205
}
@@ -209,7 +209,7 @@ export class TestRepository {
209209
try {
210210
await this.codeArtifact.describeRepository({ domain: this.domain, repository: name }).promise();
211211
return true;
212-
} catch (e) {
212+
} catch (e: any) {
213213
if (e.code !== 'ResourceNotFoundException') { throw e; }
214214
return false;
215215
}
@@ -246,7 +246,7 @@ async function retry<A>(block: () => Promise<A>) {
246246
while (true) {
247247
try {
248248
return await block();
249-
} catch (e) {
249+
} catch (e: any) {
250250
if (attempts-- === 0) { throw e; }
251251
// eslint-disable-next-line no-console
252252
console.debug(e.message);
@@ -261,7 +261,7 @@ async function retryThrottled<A>(block: () => Promise<A>) {
261261
while (true) {
262262
try {
263263
return await block();
264-
} catch (e) {
264+
} catch (e: any) {
265265
// eslint-disable-next-line no-console
266266
console.debug(e.message);
267267
if (e.code !== 'ThrottlingException') { throw e; }
@@ -279,4 +279,4 @@ export interface LoginInformation {
279279
readonly mavenEndpoint: string;
280280
readonly nugetEndpoint: string;
281281
readonly pypiEndpoint: string;
282-
}
282+
}

packages/@aws-cdk-testing/cli-integ/lib/with-aws.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async function sanityCheck(aws: AwsClients) {
5555
try {
5656
await aws.account();
5757
sanityChecked = true;
58-
} catch (e) {
58+
} catch (e: any) {
5959
sanityChecked = false;
6060
throw new Error(`AWS credentials probably not configured, got error: ${e.message}`);
6161
}

packages/@aws-cdk-testing/cli-integ/lib/with-sam.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function withSamIntegrationCdkApp<A extends TestContext & AwsContext>(blo
6464
});
6565
}
6666
await block(fixture);
67-
} catch (e) {
67+
} catch (e: any) {
6868
// We survive certain cases involving gopkg.in
6969
if (errorCausedByGoPkg(e.message)) {
7070
return;

packages/@aws-cdk-testing/cli-integ/lib/xpmutex.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class XpMutex {
9595
// Acquire lock by being the one to create the file
9696
try {
9797
return await this.writePidFile('wx'); // Fails if the file already exists
98-
} catch (e) {
98+
} catch (e: any) {
9999
if (e.code !== 'EEXIST') { throw e; }
100100
}
101101

@@ -159,7 +159,7 @@ export class XpMutex {
159159
let contents;
160160
try {
161161
contents = await fs.readFile(this.fileName, { encoding: 'utf-8' });
162-
} catch (e) {
162+
} catch (e: any) {
163163
if (e.code === 'ENOENT') { return undefined; }
164164
throw e;
165165
}
@@ -194,7 +194,7 @@ async function fileExists(fileName: string) {
194194
try {
195195
await fs.stat(fileName);
196196
return true;
197-
} catch (e) {
197+
} catch (e: any) {
198198
if (e.code === 'ENOENT') { return false; }
199199
throw e;
200200
}
@@ -204,7 +204,7 @@ function processExists(pid: number) {
204204
try {
205205
process.kill(pid, 0);
206206
return true;
207-
} catch (e) {
207+
} catch {
208208
return false;
209209
}
210210
}

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => {
559559
});
560560
}
561561
await fixture.aws.iam('deleteRole', { RoleName: roleName });
562-
} catch (e) {
562+
} catch (e: any) {
563563
if (e.message.indexOf('cannot be found') > -1) { return; }
564564
throw e;
565565
}

packages/@aws-cdk/alexa-ask/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@
8585
"@aws-cdk/cdk-build-tools": "0.0.0",
8686
"@aws-cdk/cfn2ts": "0.0.0",
8787
"@aws-cdk/pkglint": "0.0.0",
88-
"@types/jest": "^27.5.2",
89-
"jsii": "v4.9-next"
88+
"@types/jest": "^27.5.2"
9089
},
9190
"dependencies": {
9291
"@aws-cdk/core": "0.0.0",

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

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
"description": "An assertion library for use with CDK Apps",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
7+
"typesVersions": {
8+
"<=3.9": {
9+
"*": [
10+
".types-compat/ts3.9/*"
11+
]
12+
}
13+
},
714
"scripts": {
815
"build": "cdk-build",
916
"watch": "cdk-watch",

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@
8686
"@aws-cdk/cdk-build-tools": "0.0.0",
8787
"@aws-cdk/cfn2ts": "0.0.0",
8888
"@aws-cdk/pkglint": "0.0.0",
89-
"@types/jest": "^27.5.2",
90-
"jsii": "v4.9-next"
89+
"@types/jest": "^27.5.2"
9190
},
9291
"dependencies": {
9392
"@aws-cdk/core": "0.0.0",

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@
8585
"@aws-cdk/cdk-build-tools": "0.0.0",
8686
"@aws-cdk/cfn2ts": "0.0.0",
8787
"@aws-cdk/pkglint": "0.0.0",
88-
"@types/jest": "^27.5.2",
89-
"jsii": "v4.9-next"
88+
"@types/jest": "^27.5.2"
9089
},
9190
"dependencies": {
9291
"@aws-cdk/core": "0.0.0",

packages/@aws-cdk/aws-amplify/lib/asset-deployment-handler/common.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ export abstract class ResourceHandler {
6767
console.log(JSON.stringify(x, undefined, 2));
6868
}
6969

70-
protected abstract async onCreate(): Promise<AmplifyJobId>;
71-
protected abstract async onDelete(): Promise<void>;
72-
protected abstract async onUpdate(): Promise<AmplifyJobId>;
73-
protected abstract async isCreateComplete(): Promise<IsCompleteResponse>;
74-
protected abstract async isDeleteComplete(): Promise<IsCompleteResponse>;
75-
protected abstract async isUpdateComplete(): Promise<IsCompleteResponse>;
70+
protected abstract onCreate(): Promise<AmplifyJobId>;
71+
protected abstract onDelete(): Promise<void>;
72+
protected abstract onUpdate(): Promise<AmplifyJobId>;
73+
protected abstract isCreateComplete(): Promise<IsCompleteResponse>;
74+
protected abstract isDeleteComplete(): Promise<IsCompleteResponse>;
75+
protected abstract isUpdateComplete(): Promise<IsCompleteResponse>;
7676
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@
8888
"@aws-cdk/cfn2ts": "0.0.0",
8989
"@aws-cdk/pkglint": "0.0.0",
9090
"@types/jest": "^27.5.2",
91-
"aws-sdk": "^2.1329.0",
92-
"jsii": "v4.9-next"
91+
"aws-sdk": "^2.1329.0"
9392
},
9493
"dependencies": {
9594
"@aws-cdk/aws-codebuild": "0.0.0",

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@
8989
"@aws-cdk/cfn2ts": "0.0.0",
9090
"@aws-cdk/pkglint": "0.0.0",
9191
"@types/jest": "^27.5.2",
92-
"@types/node": "18.11.19",
93-
"jsii": "v4.9-next"
92+
"@types/node": "18.11.19"
9493
},
9594
"dependencies": {
9695
"@aws-cdk/core": "0.0.0",

packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract class LambdaAuthorizer extends Authorizer implements IAuthorizer {
5252
* The id of the authorizer.
5353
* @attribute
5454
*/
55-
public abstract readonly authorizerId: string;
55+
public abstract override readonly authorizerId: string;
5656

5757
/**
5858
* The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.

packages/@aws-cdk/aws-apigateway/test/authorizers/integ.request-authorizer.lit.js.snapshot/asset.3dc8c5549b88fef617feef923524902b3650973ae1159c9489ee8405344dd5a0.handler/index.js

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

0 commit comments

Comments
 (0)