Skip to content

Commit d0d7547

Browse files
authored
2 parents 8e4485b + b70b893 commit d0d7547

File tree

156 files changed

+116515
-331
lines changed

Some content is hidden

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

156 files changed

+116515
-331
lines changed

.github/workflows/request-cli-integ-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
persist-credentials: false
2020
- name: Find changed cli files
2121
id: changed-cli-files
22-
uses: tj-actions/changed-files@408093d9ff9c134c33b974e0722ce06b9d6e8263
22+
uses: tj-actions/changed-files@95690f9ece77c1740f4a55b7f1de9023ed6b1f87
2323
with:
2424
base_sha: ${{ github.event.pull_request.base.sha }}
2525
files_yaml: |
@@ -46,7 +46,7 @@ jobs:
4646
git config --global user.email '[email protected]'
4747
git push --force --atomic https://github.com/${{ github.repository }}.git FETCH_HEAD:test-main-pipeline
4848
- name: Explain next steps
49-
uses: thollander/actions-comment-pull-request@d61db783da9abefc3437960d0cce08552c7c004f
49+
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308
5050
with:
5151
message: |
5252
:arrow_right: **PR build request submitted to `test-main-pipeline`** :arrow_left:

CHANGELOG.v2.alpha.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
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.103.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.102.1-alpha.0...v2.103.0-alpha.0) (2023-10-25)
6+
7+
### Features
8+
9+
* **schedule-alpha:** support customer managed KMS keys ([#27609](https://github.com/aws/aws-cdk/issues/27609)) ([df24d22](https://github.com/aws/aws-cdk/commit/df24d22a2afae63a6fc7683ddbe2659cc269230d)), closes [#27543](https://github.com/aws/aws-cdk/issues/27543)
10+
511
## [2.102.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.102.0-alpha.0...v2.102.1-alpha.0) (2023-10-25)
612

713
## [2.102.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.101.1-alpha.0...v2.102.0-alpha.0) (2023-10-18)

CHANGELOG.v2.md

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
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.103.0](https://github.com/aws/aws-cdk/compare/v2.102.1...v2.103.0) (2023-10-25)
6+
7+
8+
### Features
9+
10+
* update AWS Service Spec ([#27650](https://github.com/aws/aws-cdk/issues/27650)) ([d1c36c6](https://github.com/aws/aws-cdk/commit/d1c36c6433aadc7394aa00847c1b8131b6a74346))
11+
* **cli:** support `Fn::ImportValue` intrinsic function for hotswap deployments ([#27292](https://github.com/aws/aws-cdk/issues/27292)) ([a54ea0f](https://github.com/aws/aws-cdk/commit/a54ea0f2dd4c6525ac3fd264b6d0f085414d3a37))
12+
* **ec2:** support for c7i and r7iz instance types in aws-ec2 ([#27611](https://github.com/aws/aws-cdk/issues/27611)) ([382a0ed](https://github.com/aws/aws-cdk/commit/382a0edadfdb4f1e505f920cad05e3321bd5c017)), closes [/docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2](https://github.com/aws//docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html/issues/cfn-ec2)
13+
* **ec2:** support for i4g instance types in aws-ec2 ([#27639](https://github.com/aws/aws-cdk/issues/27639)) ([039071d](https://github.com/aws/aws-cdk/commit/039071dde0fe3bc40978e6f967a58ac63cbdda8f)), closes [/docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instance.html#cfn-ec2](https://github.com/aws//docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instance.html/issues/cfn-ec2) [#27631](https://github.com/aws/aws-cdk/issues/27631)
14+
* **lambda:** add grantInvokeCompositePrincipal method ([#27529](https://github.com/aws/aws-cdk/issues/27529)) ([447b63c](https://github.com/aws/aws-cdk/commit/447b63ce636884c9c86e36e783aee73a3b489d90)), closes [#27503](https://github.com/aws/aws-cdk/issues/27503)
15+
* **opensearch:** OpenSearch 2.9 engine version ([#27612](https://github.com/aws/aws-cdk/issues/27612)) ([1f7075f](https://github.com/aws/aws-cdk/commit/1f7075f8bd6bd3c1d760cb9e899a7cba52e2993a)), closes [#27574](https://github.com/aws/aws-cdk/issues/27574)
16+
* **secretsmanager:** validate maximum value of automaticallyAfter in RotationSchedule ([#27592](https://github.com/aws/aws-cdk/issues/27592)) ([99740b3](https://github.com/aws/aws-cdk/commit/99740b3211d09e573e7b30e0e0baa7e3e5669447)), closes [/github.com/aws/aws-cdk/pull/27570#pullrequestreview-1682163803](https://github.com/aws//github.com/aws/aws-cdk/pull/27570/issues/pullrequestreview-1682163803) [/github.com/aws/aws-cdk/pull/27570#pullrequestreview-1684311044](https://github.com/aws//github.com/aws/aws-cdk/pull/27570/issues/pullrequestreview-1684311044)
17+
* **synthetics:** syn-python-selenium-2.0 runtime ([#27565](https://github.com/aws/aws-cdk/issues/27565)) ([1a89ef9](https://github.com/aws/aws-cdk/commit/1a89ef9632d89094486fab26b7cc930c0c83aab0)), closes [#27566](https://github.com/aws/aws-cdk/issues/27566)
18+
19+
20+
### Bug Fixes
21+
22+
* **cdk:** Add AppSync:Api_Key as hot swappable and fix a bug with AppSync.function ([#27559](https://github.com/aws/aws-cdk/issues/27559)) ([12ff023](https://github.com/aws/aws-cdk/commit/12ff0235e5b6909691f656da1707c039f7000dbe))
23+
* **ec2:** naming collisions when using `ec2.InitFile.fromAsset()` on multiple instances in the same stack ([#27468](https://github.com/aws/aws-cdk/issues/27468)) ([fc3be31](https://github.com/aws/aws-cdk/commit/fc3be313daf40bbf12b55f0b3ed3027505ca3a87)), closes [#16891](https://github.com/aws/aws-cdk/issues/16891) [/github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts#L427](https://github.com/aws//github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ec2/lib/cfn-init-elements.ts/issues/L427)
24+
* **pipelines:** using the same source (s3, connection, or codecommit) in a pipeline causes duplicate id error ([#27602](https://github.com/aws/aws-cdk/issues/27602)) ([70acc84](https://github.com/aws/aws-cdk/commit/70acc844e2a652aea4f1328e4e758c3c5030d501)), closes [#23916](https://github.com/aws/aws-cdk/issues/23916) [#19875](https://github.com/aws/aws-cdk/issues/19875)
25+
* **region-info:** facts only returned from constant region list ([#27506](https://github.com/aws/aws-cdk/issues/27506)) ([7121c7e](https://github.com/aws/aws-cdk/commit/7121c7ee9eed595acfed1fb09f55b8bd966c01e3)), closes [#27260](https://github.com/aws/aws-cdk/issues/27260)
26+
* **stepfunctions-tasks:** cloudwatchlogs service generates wrong action in role policy ([#27623](https://github.com/aws/aws-cdk/issues/27623)) ([de7fb04](https://github.com/aws/aws-cdk/commit/de7fb043c37569d39776623fe137860e279b9fbf)), closes [#27573](https://github.com/aws/aws-cdk/issues/27573)
27+
528
## [2.102.1](https://github.com/aws/aws-cdk/compare/v2.102.0...v2.102.1) (2023-10-25)
629

730
### Bug Fixes

CONTRIBUTING.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,14 @@ CDK integration tests.
485485

486486
### Step 4: Pull Request
487487

488-
* Create a commit with your changes and push them to a
489-
[fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
488+
* Create a [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of the CDK repository.
489+
* Create a new branch for your change, and push the change commits on it.
490490
> [!IMPORTANT]
491-
> We will not be able to accept your contribution if you do not allow commits to your PR branch, as it introduces
492-
> friction in our review process and breaks our automation that syncs with the main branch. In these scenarios, we will close
493-
> your pull request and ask that you recreate it with the necessary permissions.
494-
> This means that you must contribute from a fork within your personal account (as opposed to an organization owned account) and also develop
495-
> your contribution on a branch other than `main`. See
496-
> [Allowing changes to a pull request branch created from a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
497-
> for more information.
491+
> Your pull request must be based off of a branch in a personal account (not an organization owned account, and not the `main` branch).
492+
> You must also have the setting enabled that [allows the CDK team to push changes to your branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) (this setting is enabled by default for personal accounts,
493+
> and cannot be enabled for organization owned accounts).
494+
> The reason for this is that our automation needs to synchronize your branch with our `main` after it has been approved, and
495+
> we cannot do that if we cannot push to your branch.
498496
499497
> [!NOTE]
500498
> CDK core members can push to a branch on the AWS CDK repo (naming convention: `<user>/<feature-bug-name>`).

INTEGRATION_TESTS.md

+36-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All Construct libraries in the CDK code base have integration tests that serve t
2424
This is done by running `yarn integ` which will run `cdk deploy` across all of the integration tests in that package.
2525
If you are developing a new integration test or for some other reason want to work on a single integration test
2626
over and over again without running through all the integration tests you can do so using
27-
`yarn integ integ.test-name.js` .Remember to set up AWS credentials before doing this.
27+
`yarn integ integ.test-name.js`. Remember to set up AWS credentials before doing this.
2828
3. (Optionally) Acts as a way to validate that constructs set up the CloudFormation resources as expected.
2929
A successful CloudFormation deployment does not mean that the resources are set up correctly.
3030

@@ -75,8 +75,7 @@ you have good test coverage.
7575

7676
### Creating a Test
7777

78-
An integration tests is any file located in the `test/` directory that has a name that starts with `integ.`
79-
(e.g. `integ.*.ts`).
78+
Integration tests for stable modules live in `@aws-cdk-testing/framework-integ/test/MODULE_NAME/test/`. Alpha module integ tests still live in their `test/` directories. Names of integration tests start with integ (e.g. `integ.*.ts`).
8079

8180
To create a new integration test, first create a new file, for example `integ.my-new-construct.ts`.
8281
The contents of this file should be a CDK app. For example, a very simple integration test for a
@@ -86,7 +85,7 @@ _integ.lambda.ts_
8685
```ts
8786
import * as iam from 'aws-cdk-lib/aws-iam';
8887
import * as cdk from 'aws-cdk-lib/core';
89-
import * as lambda from '../lib';
88+
import * as lambda from 'aws-cdk-lib/aws-lambda';
9089
import * as integ from '@aws-cdk/integ-tests-alpha';
9190

9291
const app = new cdk.App();
@@ -102,8 +101,6 @@ const fn = new lambda.Function(stack, 'MyLambda', {
102101
new integ.IntegTest(app, 'LambdaTest', {
103102
testCases: [stack],
104103
});
105-
106-
app.synth();
107104
```
108105

109106
To run the test you would run:
@@ -243,11 +240,13 @@ want to validate that the _integration_ connecting `StepFunctions` to the `Event
243240
way to do that is to actually trigger the `StateMachine` and validate that it was successful.
244241

245242
```ts
243+
import * as integ from '@aws-cdk/integ-tests-alpha';
244+
246245
declare const app: App;
247246
declare const sm: sfn.StateMachine;
248247
declare const stack: Stack;
249248

250-
const testCase = new IntegTest(app, 'PutEvents', {
249+
const testCase = new integ.IntegTest(app, 'PutEvents', {
251250
testCases: [stack],
252251
});
253252

@@ -262,21 +261,47 @@ const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecut
262261
});
263262

264263
// assert the results
265-
describe.expect(ExpectedResult.objectLike({
264+
describe.expect(integ.ExpectedResult.objectLike({
266265
status: 'SUCCEEDED',
267266
}));
268267
```
269268

270-
Not every test requires an assertion. We typically do not need to assert CloudFormation behavior. For example, if we create an S3 Bucket
269+
If we want to pick out certain values from the api call response, we can use the `assertAtPath()` method, as in the [integ.pipeline-with-additional-inputs.ts](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk-testing/framework-integ/test/pipelines/test/integ.pipeline-with-additional-inputs.ts) integ test. Note that using the `outputPaths` optional parameter on the `awsApiCall()` function often interacts poorly with the `expect()` function.
270+
271+
```ts
272+
import * as integ from '@aws-cdk/integ-tests-alpha';
273+
274+
declare const app: App;
275+
declare const stack: Stack;
276+
declare const pipelineName: string;
277+
declare const expectedString: string;
278+
279+
const testCase = new integ.IntegTest(app, 'PipelineAdditionalInputsTest', {
280+
testCases: [stack],
281+
});
282+
283+
const source = testCase.assertions.awsApiCall('CodePipeline', 'GetPipeline', {
284+
name: pipelineName,
285+
});
286+
287+
// assert the value at the given path matches the expected string
288+
// the numbers index arryas in the json response object
289+
source.assertAtPath('pipeline.stages.0.actions.0.name', integ.ExpectedResult.stringLikeRegexp(expectedString));
290+
```
291+
A helpful trick is to deploy the integ test with `--no-clean` and then make the api call locally. We can then trace the path to specific values easily. For example, `> aws codepipeline get-pipeline --name MyFirstPipeline`.
292+
293+
Adding assertions is prefered on all new integ tests; however, it is not strictly required. We typically do not need to assert CloudFormation behavior. For example, if we create an S3 Bucket
271294
with Encryption, we do not need to assert that Encryption is set on the bucket. We can trust that the CloudFormation behavior works.
272295
Some things you should look for in deciding if the test needs an assertion:
273296

274-
- Integrations between services (i.e. integration libraries like `aws-cdk-lib/aws-lambda-destinations`, `aws-cdk-lib/aws-stepfunctions-tasks`, etc)
275-
- Anything that bundles or deploys custom code (i.e. does a Lambda function bundled with `aws-cdk-lib/aws-lambda-nodejs` still invoke or did we break bundling behavior)
297+
- Integrations between services (i.e. integration libraries like `aws-cdk-lib/aws-lambda-destinations`, `aws-cdk-lib/aws-stepfunctions-tasks`, etc).
298+
- All custom resources. Must assert the expected behavior of the lambda is correct.
299+
- Anything that bundles or deploys custom code (i.e. does a Lambda function bundled with `aws-cdk-lib/aws-lambda-nodejs` still invoke or did we break bundling behavior).
276300
- IAM/Networking connections.
277301
- This one is a bit of a judgement call. Most things do not need assertions, but sometimes we handle complicated configurations involving IAM permissions or
278302
Networking access.
279303

304+
280305
## Running Integration Tests
281306

282307
Most of the time you will only need to run integration tests for an individual module (i.e. `aws-lambda`). Other times you may need to run tests across multiple modules.

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

+24-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,12 @@ class LambdaHotswapStack extends cdk.Stack {
252252
handler: 'index.handler',
253253
description: process.env.DYNAMIC_LAMBDA_PROPERTY_VALUE ?? "description",
254254
environment: {
255-
SomeVariable: process.env.DYNAMIC_LAMBDA_PROPERTY_VALUE ?? "environment",
256-
}
255+
SomeVariable:
256+
process.env.DYNAMIC_LAMBDA_PROPERTY_VALUE ?? "environment",
257+
ImportValueVariable: process.env.USE_IMPORT_VALUE_LAMBDA_PROPERTY
258+
? cdk.Fn.importValue(TEST_EXPORT_OUTPUT_NAME)
259+
: "no-import",
260+
},
257261
});
258262

259263
new cdk.CfnOutput(this, 'FunctionName', { value: fn.functionName });
@@ -343,6 +347,22 @@ class ConditionalResourceStack extends cdk.Stack {
343347
}
344348
}
345349

350+
const TEST_EXPORT_OUTPUT_NAME = 'test-export-output';
351+
352+
class ExportValueStack extends cdk.Stack {
353+
constructor(parent, id, props) {
354+
super(parent, id, props);
355+
356+
// just need any resource to exist within the stack
357+
const topic = new sns.Topic(this, 'Topic');
358+
359+
new cdk.CfnOutput(this, 'ExportValueOutput', {
360+
exportName: TEST_EXPORT_OUTPUT_NAME,
361+
value: topic.topicArn,
362+
});
363+
}
364+
}
365+
346366
class BundlingStage extends cdk.Stage {
347367
constructor(parent, id, props) {
348368
super(parent, id, props);
@@ -450,6 +470,8 @@ switch (stackSet) {
450470

451471
new ImportableStack(app, `${stackPrefix}-importable-stack`);
452472

473+
new ExportValueStack(app, `${stackPrefix}-export-value-stack`);
474+
453475
new BundlingStage(app, `${stackPrefix}-bundling-stage`);
454476
break;
455477

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

+42
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,48 @@ integTest('hotswap deployment supports Lambda function\'s description and enviro
12261226
expect(deployOutput).toContain(`Lambda Function '${functionName}' hotswapped!`);
12271227
}));
12281228

1229+
integTest('hotswap deployment supports Fn::ImportValue intrinsic', withDefaultFixture(async (fixture) => {
1230+
// GIVEN
1231+
try {
1232+
await fixture.cdkDeploy('export-value-stack');
1233+
const stackArn = await fixture.cdkDeploy('lambda-hotswap', {
1234+
captureStderr: false,
1235+
modEnv: {
1236+
DYNAMIC_LAMBDA_PROPERTY_VALUE: 'original value',
1237+
USE_IMPORT_VALUE_LAMBDA_PROPERTY: 'true',
1238+
},
1239+
});
1240+
1241+
// WHEN
1242+
const deployOutput = await fixture.cdkDeploy('lambda-hotswap', {
1243+
options: ['--hotswap'],
1244+
captureStderr: true,
1245+
onlyStderr: true,
1246+
modEnv: {
1247+
DYNAMIC_LAMBDA_PROPERTY_VALUE: 'new value',
1248+
USE_IMPORT_VALUE_LAMBDA_PROPERTY: 'true',
1249+
},
1250+
});
1251+
1252+
const response = await fixture.aws.cloudFormation('describeStacks', {
1253+
StackName: stackArn,
1254+
});
1255+
const functionName = response.Stacks?.[0].Outputs?.[0].OutputValue;
1256+
1257+
// THEN
1258+
1259+
// The deployment should not trigger a full deployment, thus the stack's status must remains
1260+
// "CREATE_COMPLETE"
1261+
expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE');
1262+
expect(deployOutput).toContain(`Lambda Function '${functionName}' hotswapped!`);
1263+
1264+
} finally {
1265+
// Ensure cleanup in reverse order due to use of import/export
1266+
await fixture.cdkDestroy('lambda-hotswap');
1267+
await fixture.cdkDestroy('export-value-stack');
1268+
}
1269+
}));
1270+
12291271
async function listChildren(parent: string, pred: (x: string) => Promise<boolean>) {
12301272
const ret = new Array<string>();
12311273
for (const child of await fs.readdir(parent, { encoding: 'utf-8' })) {

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init-multiple.js.snapshot/asset.04c44be8722f4360fe0830af22298ad0870480310d7bd6eedbbd2391aecf59a8

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

0 commit comments

Comments
 (0)