Skip to content

Commit fb74c41

Browse files
authored
chore: release 2.126.0 (#28967)
See CHANGELOG.v2.md and CHANGELOG.v2.alpha.md ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
2 parents 5e3c3c6 + 47acb43 commit fb74c41

File tree

29 files changed

+1472
-139
lines changed

29 files changed

+1472
-139
lines changed

CHANGELOG.v2.alpha.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.126.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.125.0-alpha.0...v2.126.0-alpha.0) (2024-02-02)
6+
57
## [2.125.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.124.0-alpha.0...v2.125.0-alpha.0) (2024-01-31)
68

79

CHANGELOG.v2.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.126.0](https://github.com/aws/aws-cdk/compare/v2.125.0...v2.126.0) (2024-02-02)
6+
7+
8+
### Features
9+
10+
* **migrate:** Add CDK Migrate `--from-scan` functionality ([#28962](https://github.com/aws/aws-cdk/issues/28962)) ([bbc14b3](https://github.com/aws/aws-cdk/commit/bbc14b32801f103bc465fd910d507ffa0d06b7fe))
11+
512
## [2.125.0](https://github.com/aws/aws-cdk/compare/v2.124.0...v2.125.0) (2024-01-31)
613

714

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

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { AwsContext, withAws } from './with-aws';
1212
import { withTimeout } from './with-timeout';
1313

1414
export const DEFAULT_TEST_TIMEOUT_S = 10 * 60;
15+
export const EXTENDED_TEST_TIMEOUT_S = 30 * 60;
1516

1617
/**
1718
* Higher order function to execute a block with a CDK app fixture
@@ -185,6 +186,10 @@ export function withDefaultFixture(block: (context: TestFixture) => Promise<void
185186
return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCdkApp(block)));
186187
}
187188

189+
export function withExtendedTimeoutFixture(block: (context: TestFixture) => Promise<void>) {
190+
return withAws(withTimeout(EXTENDED_TEST_TIMEOUT_S, withCdkApp(block)));
191+
}
192+
188193
export function withCDKMigrateFixture(language: string, block: (content: TestFixture) => Promise<void>) {
189194
return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCdkMigrateApp(language, block)));
190195
}

packages/@aws-cdk-testing/cli-integ/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"dependencies": {
4141
"@octokit/rest": "^18.12.0",
42-
"aws-sdk": "^2.1547.0",
42+
"aws-sdk": "^2.1548.0",
4343
"axios": "^1.6.7",
4444
"fs-extra": "^9.1.0",
4545
"glob": "^7.2.3",

packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js

+28
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,35 @@ class MigrateStack extends cdk.Stack {
8686
value: queue.node.defaultChild.logicalId,
8787
});
8888
}
89+
if (process.env.SAMPLE_RESOURCES) {
90+
const myTopic = new sns.Topic(this, 'migratetopic1', {
91+
removalPolicy: cdk.RemovalPolicy.DESTROY,
92+
});
93+
cdk.Tags.of(myTopic).add('tag1', 'value1');
94+
const myTopic2 = new sns.Topic(this, 'migratetopic2', {
95+
removalPolicy: cdk.RemovalPolicy.DESTROY,
96+
});
97+
cdk.Tags.of(myTopic2).add('tag2', 'value2');
98+
const myQueue = new sqs.Queue(this, 'migratequeue1', {
99+
removalPolicy: cdk.RemovalPolicy.DESTROY,
100+
});
101+
cdk.Tags.of(myQueue).add('tag3', 'value3');
102+
}
103+
if (process.env.LAMBDA_RESOURCES) {
104+
const myFunction = new lambda.Function(this, 'migratefunction1', {
105+
code: lambda.Code.fromInline('console.log("hello world")'),
106+
handler: 'index.handler',
107+
runtime: lambda.Runtime.NODEJS_18_X,
108+
});
109+
cdk.Tags.of(myFunction).add('lambda-tag', 'lambda-value');
89110

111+
const myFunction2 = new lambda.Function(this, 'migratefunction2', {
112+
code: lambda.Code.fromInline('console.log("hello world2")'),
113+
handler: 'index.handler',
114+
runtime: lambda.Runtime.NODEJS_18_X,
115+
});
116+
cdk.Tags.of(myFunction2).add('lambda-tag', 'lambda-value');
117+
}
90118
}
91119
}
92120

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

+115-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs, existsSync } from 'fs';
22
import * as os from 'os';
33
import * as path from 'path';
4-
import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture } from '../../lib';
4+
import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture, withExtendedTimeoutFixture } from '../../lib';
55

66
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
77

@@ -571,9 +571,9 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => {
571571
}
572572
}));
573573

574-
// TODO add go back in when template synths properly
574+
// TODO add more testing that ensures the symmetry of the generated constructs to the resources.
575575
['typescript', 'python', 'csharp', 'java'].forEach(language => {
576-
integTest(`cdk migrate ${language}`, withCDKMigrateFixture(language, async (fixture) => {
576+
integTest(`cdk migrate ${language} deploys successfully`, withCDKMigrateFixture(language, async (fixture) => {
577577
if (language === 'python') {
578578
await fixture.shell(['pip', 'install', '-r', 'requirements.txt']);
579579
}
@@ -588,6 +588,118 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => {
588588
}));
589589
});
590590

591+
integTest('cdk migrate generates migrate.json', withCDKMigrateFixture('typescript', async (fixture) => {
592+
593+
const migrateFile = await fs.readFile(path.join(fixture.integTestDir, 'migrate.json'), 'utf8');
594+
const expectedFile = `{
595+
\"//\": \"This file is generated by cdk migrate. It will be automatically deleted after the first successful deployment of this app to the environment of the original resources.\",
596+
\"Source\": \"localfile\"
597+
}`;
598+
expect(JSON.parse(migrateFile)).toEqual(JSON.parse(expectedFile));
599+
await fixture.cdkDestroy(fixture.stackNamePrefix);
600+
}));
601+
602+
integTest('cdk migrate --from-scan with AND/OR filters correctly filters resources', withExtendedTimeoutFixture(async (fixture) => {
603+
const stackName = `cdk-migrate-integ-${fixture.randomString}`;
604+
605+
await fixture.cdkDeploy('migrate-stack', {
606+
modEnv: { SAMPLE_RESOURCES: '1' },
607+
});
608+
await fixture.cdk(
609+
['migrate', '--stack-name', stackName, '--from-scan', 'new', '--filter', 'type=AWS::SNS::Topic,tag-key=tag1', 'type=AWS::SQS::Queue,tag-key=tag3'],
610+
{ modEnv: { MIGRATE_INTEG_TEST: '1' }, neverRequireApproval: true, verbose: true, captureStderr: false },
611+
);
612+
613+
try {
614+
const response = await fixture.aws.cloudFormation('describeGeneratedTemplate', {
615+
GeneratedTemplateName: stackName,
616+
});
617+
const resourceNames = [];
618+
for (const resource of response.Resources || []) {
619+
if (resource.LogicalResourceId) {
620+
resourceNames.push(resource.LogicalResourceId);
621+
}
622+
}
623+
fixture.log(`Resources: ${resourceNames}`);
624+
expect(resourceNames.some(ele => ele && ele.includes('migratetopic1'))).toBeTruthy();
625+
expect(resourceNames.some(ele => ele && ele.includes('migratequeue1'))).toBeTruthy();
626+
} finally {
627+
await fixture.cdkDestroy('migrate-stack');
628+
await fixture.aws.cloudFormation('deleteGeneratedTemplate', {
629+
GeneratedTemplateName: stackName,
630+
});
631+
}
632+
}));
633+
634+
integTest('cdk migrate --from-scan for resources with Write Only Properties generates warnings', withExtendedTimeoutFixture(async (fixture) => {
635+
const stackName = `cdk-migrate-integ-${fixture.randomString}`;
636+
637+
await fixture.cdkDeploy('migrate-stack', {
638+
modEnv: {
639+
LAMBDA_RESOURCES: '1',
640+
},
641+
});
642+
await fixture.cdk(
643+
['migrate', '--stack-name', stackName, '--from-scan', 'new', '--filter', 'type=AWS::Lambda::Function,tag-key=lambda-tag'],
644+
{ modEnv: { MIGRATE_INTEG_TEST: '1' }, neverRequireApproval: true, verbose: true, captureStderr: false },
645+
);
646+
647+
try {
648+
649+
const response = await fixture.aws.cloudFormation('describeGeneratedTemplate', {
650+
GeneratedTemplateName: stackName,
651+
});
652+
const resourceNames = [];
653+
for (const resource of response.Resources || []) {
654+
if (resource.LogicalResourceId && resource.ResourceType === 'AWS::Lambda::Function') {
655+
resourceNames.push(resource.LogicalResourceId);
656+
}
657+
}
658+
fixture.log(`Resources: ${resourceNames}`);
659+
const readmePath = path.join(fixture.integTestDir, stackName, 'README.md');
660+
const readme = await fs.readFile(readmePath, 'utf8');
661+
expect(readme).toContain('## Warnings');
662+
for (const resourceName of resourceNames) {
663+
expect(readme).toContain(`### ${resourceName}`);
664+
}
665+
} finally {
666+
await fixture.cdkDestroy('migrate-stack');
667+
await fixture.aws.cloudFormation('deleteGeneratedTemplate', {
668+
GeneratedTemplateName: stackName,
669+
});
670+
}
671+
}));
672+
673+
['typescript', 'python', 'csharp', 'java'].forEach(language => {
674+
integTest(`cdk migrate --from-stack creates deployable ${language} app`, withExtendedTimeoutFixture(async (fixture) => {
675+
const migrateStackName = fixture.fullStackName('migrate-stack');
676+
await fixture.aws.cloudFormation('createStack', {
677+
StackName: migrateStackName,
678+
TemplateBody: await fs.readFile(path.join(__dirname, '..', '..', 'resources', 'templates', 'sqs-template.json'), 'utf8'),
679+
});
680+
try {
681+
let stackStatus = 'CREATE_IN_PROGRESS';
682+
while (stackStatus === 'CREATE_IN_PROGRESS') {
683+
stackStatus = await (await (fixture.aws.cloudFormation('describeStacks', { StackName: migrateStackName }))).Stacks?.[0].StackStatus!;
684+
await sleep(1000);
685+
}
686+
await fixture.cdk(
687+
['migrate', '--stack-name', migrateStackName, '--from-stack'],
688+
{ modEnv: { MIGRATE_INTEG_TEST: '1' }, neverRequireApproval: true, verbose: true, captureStderr: false },
689+
);
690+
await fixture.shell(['cd', path.join(fixture.integTestDir, migrateStackName)]);
691+
await fixture.cdk(['deploy', migrateStackName], { neverRequireApproval: true, verbose: true, captureStderr: false });
692+
const response = await fixture.aws.cloudFormation('describeStacks', {
693+
StackName: migrateStackName,
694+
});
695+
696+
expect(response.Stacks?.[0].StackStatus).toEqual('UPDATE_COMPLETE');
697+
} finally {
698+
await fixture.cdkDestroy('migrate-stack');
699+
}
700+
}));
701+
});
702+
591703
integTest('cdk diff', withDefaultFixture(async (fixture) => {
592704
const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]);
593705
expect(diff1).toContain('AWS::SNS::Topic');

packages/@aws-cdk-testing/framework-integ/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@aws-cdk/integ-tests-alpha": "0.0.0",
4242
"@aws-cdk/lambda-layer-kubectl-v24": "^2.0.242",
4343
"aws-cdk-lib": "0.0.0",
44-
"aws-sdk": "^2.1547.0",
44+
"aws-sdk": "^2.1548.0",
4545
"aws-sdk-mock": "5.6.0",
4646
"cdk8s": "2.68.32",
4747
"cdk8s-plus-27": "2.7.74",

packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES

+5-15
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ The @aws-cdk/cli-lib-alpha package includes the following third-party software/l
207207

208208
----------------
209209

210-
** @jsii/check-node@1.93.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.93.0 | Apache-2.0
210+
** @jsii/check-node@1.94.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.94.0 | Apache-2.0
211211
jsii
212212
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
213213

@@ -471,17 +471,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE
471471

472472
----------------
473473

474-
** [email protected] - https://www.npmjs.com/package/aws-sdk/v/2.1517.0 | Apache-2.0
475-
AWS SDK for JavaScript
476-
Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
477-
478-
This product includes software developed at
479-
Amazon Web Services, Inc. (http://aws.amazon.com/).
480-
481-
482-
----------------
483-
484-
** [email protected] - https://www.npmjs.com/package/aws-sdk/v/2.1532.0 | Apache-2.0
474+
** [email protected] - https://www.npmjs.com/package/aws-sdk/v/2.1548.0 | Apache-2.0
485475
AWS SDK for JavaScript
486476
Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
487477

@@ -495,7 +485,7 @@ Amazon Web Services, Inc. (http://aws.amazon.com/).
495485

496486
----------------
497487

498-
** [email protected].3 - https://www.npmjs.com/package/basic-ftp/v/5.0.3 | MIT
488+
** [email protected].4 - https://www.npmjs.com/package/basic-ftp/v/5.0.4 | MIT
499489
Copyright (c) 2019 Patrick Juchli
500490

501491
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -678,7 +668,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
678668

679669
----------------
680670

681-
** cdk-from-cfn@0.116.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.116.0 | MIT OR Apache-2.0
671+
** cdk-from-cfn@0.125.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.125.0 | MIT OR Apache-2.0
682672

683673
----------------
684674

@@ -3515,7 +3505,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35153505

35163506
----------------
35173507

3518-
** xml2js@0.5.0 - https://www.npmjs.com/package/xml2js/v/0.5.0 | MIT
3508+
** xml2js@0.6.2 - https://www.npmjs.com/package/xml2js/v/0.6.2 | MIT
35193509
Copyright 2010, 2011, 2012, 2013. All rights reserved.
35203510

35213511
Permission is hereby granted, free of charge, to any person obtaining a copy

packages/@aws-cdk/cloudformation-diff/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@types/string-width": "^4.0.1",
3939
"fast-check": "^3.15.1",
4040
"jest": "^29.7.0",
41-
"aws-sdk": "2.1547.0",
41+
"aws-sdk": "2.1548.0",
4242
"ts-jest": "^29.1.2"
4343
},
4444
"repository": {

packages/@aws-cdk/custom-resource-handlers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@aws-sdk/client-synthetics": "3.421.0",
6464
"@aws-sdk/client-ecr": "3.421.0",
6565
"@aws-sdk/client-s3": "3.421.0",
66-
"aws-sdk": "^2.1547.0"
66+
"aws-sdk": "^2.1548.0"
6767
},
6868
"repository": {
6969
"url": "https://github.com/aws/aws-cdk.git",

packages/aws-cdk-lib/core/lib/private/metadata-resource.ts

+24-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { Token } from '../token';
1616
export class MetadataResource extends Construct {
1717
constructor(scope: Stack, id: string) {
1818
super(scope, id);
19-
2019
const metadataServiceExists = Token.isUnresolved(scope.region) || RegionInfo.get(scope.region).cdkMetadataResourceAvailable;
2120
if (metadataServiceExists) {
2221
const resource = new CfnResource(this, 'Default', {
@@ -51,22 +50,30 @@ function makeCdkMetadataAvailableCondition() {
5150
class Trie extends Map<string, Trie> { }
5251

5352
/**
54-
* Formats a list of construct fully-qualified names (FQNs) and versions into a (possibly compressed) prefix-encoded string.
53+
* Formats the analytics string which has 3 or 4 sections separated by colons (:)
54+
*
55+
* version:encoding:constructinfo OR version:encoding:constructinfo:appinfo
5556
*
56-
* The list of ConstructInfos is logically formatted into:
57-
* ${version}!${fqn} (e.g., "1.90.0!aws-cdk-lib.Stack")
58-
* and then all of the construct-versions are grouped with common prefixes together, grouping common parts in '{}' and separating items with ','.
57+
* The constructinfo section is a list of construct fully-qualified names (FQNs)
58+
* and versions into a (possibly compressed) prefix-encoded string.
59+
*
60+
* The list of ConstructInfos is logically formatted into: ${version}!${fqn}
61+
* (e.g., "1.90.0!aws-cdk-lib.Stack") and then all of the construct-versions are
62+
* grouped with common prefixes together, grouping common parts in '{}' and
63+
* separating items with ','.
5964
*
6065
* Example:
6166
* [1.90.0!aws-cdk-lib.Stack, 1.90.0!aws-cdk-lib.Construct, 1.90.0!aws-cdk-lib.service.Resource, 0.42.1!aws-cdk-lib-experiments.NewStuff]
6267
* Becomes:
6368
* 1.90.0!aws-cdk-lib.{Stack,Construct,service.Resource},0.42.1!aws-cdk-lib-experiments.NewStuff
6469
*
65-
* The whole thing is then either included directly as plaintext as:
66-
* v2:plaintext:{prefixEncodedList}
67-
* Or is compressed and base64-encoded, and then formatted as:
70+
* The whole thing is then compressed and base64-encoded, and then formatted as:
6871
* v2:deflate64:{prefixEncodedListCompressedAndEncoded}
6972
*
73+
* The appinfo section is optional, and currently only added if the app was generated using `cdk migrate`
74+
* It is also compressed and base64-encoded. In this case, the string will be formatted as:
75+
* v2:deflate64:{prefixEncodedListCompressedAndEncoded}:{'cdk-migrate'CompressedAndEncoded}
76+
*
7077
* Exported/visible for ease of testing.
7178
*/
7279
export function formatAnalytics(infos: ConstructInfo[]) {
@@ -81,7 +88,15 @@ export function formatAnalytics(infos: ConstructInfo[]) {
8188
setGzipOperatingSystemToUnknown(compressedConstructsBuffer);
8289

8390
const compressedConstructs = compressedConstructsBuffer.toString('base64');
84-
return `v2:deflate64:${compressedConstructs}`;
91+
const analyticsString = `v2:deflate64:${compressedConstructs}`;
92+
93+
if (process.env.CDK_CONTEXT_JSON && JSON.parse(process.env.CDK_CONTEXT_JSON)['cdk-migrate']) {
94+
const compressedAppInfoBuffer = zlib.gzipSync(Buffer.from('cdk-migrate'));
95+
const compressedAppInfo = compressedAppInfoBuffer.toString('base64');
96+
analyticsString.concat(':', compressedAppInfo);
97+
}
98+
99+
return analyticsString;
85100
}
86101

87102
/**

packages/aws-cdk-lib/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"@types/lodash": "^4.14.202",
164164
"@types/punycode": "^2.1.3",
165165
"@aws-cdk/lazify": "0.0.0",
166-
"aws-sdk": "^2.1547.0",
166+
"aws-sdk": "^2.1548.0",
167167
"aws-sdk-client-mock": "^3.0.1",
168168
"aws-sdk-client-mock-jest": "^3.0.1",
169169
"aws-sdk-mock": "5.8.0",

0 commit comments

Comments
 (0)