Skip to content

Commit deac253

Browse files
authored
chore: forward merge 'master' into 'v2-main' (#19423)
Automated action from aws/cdk-ops
2 parents b0df65d + 378beb8 commit deac253

File tree

325 files changed

+5763
-2387
lines changed

Some content is hidden

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

325 files changed

+5763
-2387
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ env:
8181
{"area":"@aws-cdk/aws-appintegrations","keywords":["(aws-appintegrations)","(appintegrations)"],"labels":["@aws-cdk/aws-appintegrations"],"assignees":["skinny85"]},
8282
{"area":"@aws-cdk/aws-applicationautoscaling","keywords":["aws-applicationautoscaling","application-autoscaling","scalabletarget"],"labels":["@aws-cdk/aws-applicationautoscaling"],"assignees":["comcalvi"]},
8383
{"area":"@aws-cdk/aws-applicationinsights","keywords":["aws-applicationinsights","application-insights"],"labels":["@aws-cdk/aws-applicationinsights"],"assignees":["corymhall"]},
84-
{"area":"@aws-cdk/aws-appmesh","keywords":["aws-appmesh","app-mesh","GatewayRoute","VirtualGateway","VirtualNode","VirtualRouter","VirtualService"],"labels":["@aws-cdk/aws-appmesh"],"assignees":["Seiya6329"]},
84+
{"area":"@aws-cdk/aws-appmesh","keywords":["aws-appmesh","app-mesh","GatewayRoute","VirtualGateway","VirtualNode","VirtualRouter","VirtualService"],"labels":["@aws-cdk/aws-appmesh"],"assignees":["ytsssun"]},
8585
{"area":"@aws-cdk/aws-appstream","keywords":["aws-appstream","app-stream"],"labels":["@aws-cdk/aws-appstream"],"assignees":["madeline-k"]},
8686
{"area":"@aws-cdk/aws-appsync","keywords":["aws-appsync","app-sync","appsyncfunction","graphqlapi","dynamodbdatasource","lambdadatasource","nonedatasource","rdsdatasource","resolver"],"labels":["@aws-cdk/aws-appsync"],"assignees":["otaviomacedo"]},
8787
{"area":"@aws-cdk/aws-athena","keywords":["aws-athena","athena","cfndatacatalog","cfnnamedquery","cfnworkgroup"],"labels":["@aws-cdk/aws-athena"],"assignees":["comcalvi"]},
@@ -273,5 +273,6 @@ env:
273273
{"area":"@aws-cdk/yaml-cfn","keywords":["(aws-yaml-cfn)","(yaml-cfn)"],"labels":["@aws-cdk/aws-yaml-cfn"],"assignees":["skinny85"]},
274274
{"area":"@aws-cdk/aws-apprunner","keywords":["apprunner","aws-apprunner"],"labels":["@aws-cdk/aws-apprunner"],"assignees":["corymhall"]},
275275
{"area":"@aws-cdk/aws-lightsail","keywords":["lightsail","aws-lightsail"],"labels":["@aws-cdk/aws-lightsail"],"assignees":["corymhall"]},
276-
{"area":"@aws-cdk/aws-aps","keywords":["aps","aws-aps","prometheus"],"labels":["@aws-cdk/aws-aps"],"assignees":["corymhall"]}
276+
{"area":"@aws-cdk/aws-aps","keywords":["aps","aws-aps","prometheus"],"labels":["@aws-cdk/aws-aps"],"assignees":["corymhall"]},
277+
{"area":"@aws-cdk/triggers","keywords":["trigger","aws-cdk/triggers","triggers"],"labels":["@aws-cdk/triggers"],"assignees":["otaviomacedo"]}
277278
]

.github/workflows/yarn-upgrade.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ jobs:
115115
team-reviewers: aws-cdk-team
116116
# Github prevents further Github actions to be run if the default Github token is used.
117117
# Instead use a privileged token here, so further GH actions can be triggered on this PR.
118-
token: ${{ secrets.AUTOMATION_GITHUB_TOKEN }}
118+
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}

CHANGELOG.md

+34
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
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+
## [1.148.0](https://github.com/aws/aws-cdk/compare/v1.147.0...v1.148.0) (2022-03-09)
6+
7+
8+
### Features
9+
10+
* **aws-apigateway:** add ability to include authorizer context in apigw sfn integration ([#18892](https://github.com/aws/aws-cdk/issues/18892)) ([e7c0c75](https://github.com/aws/aws-cdk/commit/e7c0c75dbc7cf71164673626dc0ab63fb3706223)), closes [#18891](https://github.com/aws/aws-cdk/issues/18891)
11+
* **aws-s3objectlambda:** add L2 construct for S3 Object Lambda ([#15833](https://github.com/aws/aws-cdk/issues/15833)) ([fe9f750](https://github.com/aws/aws-cdk/commit/fe9f750bd9dd9974b9ae6f73c78fcd12ab2edd91)), closes [#13675](https://github.com/aws/aws-cdk/issues/13675)
12+
* **cfnspec:** cloudformation spec v59.0.0 ([#19236](https://github.com/aws/aws-cdk/issues/19236)) ([f46a14d](https://github.com/aws/aws-cdk/commit/f46a14da9bec1aad7096b62666cb80ce42f04b53))
13+
* **codebuild:** improved support for ARM build images ([#19052](https://github.com/aws/aws-cdk/issues/19052)) ([4eac4de](https://github.com/aws/aws-cdk/commit/4eac4deb98411e921e5a2e6477185207b8588f75)), closes [#18916](https://github.com/aws/aws-cdk/issues/18916) [#9817](https://github.com/aws/aws-cdk/issues/9817)
14+
* **eks:** Service Account names validation ([#19251](https://github.com/aws/aws-cdk/issues/19251)) ([7c3099e](https://github.com/aws/aws-cdk/commit/7c3099e958d7bf0ddb5a7b08afb672a0c652b27d)), closes [#18189](https://github.com/aws/aws-cdk/issues/18189)
15+
* **elasticsearch:** Decouple setting access policies from domain constructor ([#15876](https://github.com/aws/aws-cdk/issues/15876)) ([cefdfd3](https://github.com/aws/aws-cdk/commit/cefdfd384eeac1752567f672452296def68b1206))
16+
* **iotevents:** support actions ([#18869](https://github.com/aws/aws-cdk/issues/18869)) ([e01654e](https://github.com/aws/aws-cdk/commit/e01654e792708ee283d7a31e1370d0d1ae383171))
17+
* **iotevents:** support setting Events on input and exit for State ([#19249](https://github.com/aws/aws-cdk/issues/19249)) ([ffa9e0d](https://github.com/aws/aws-cdk/commit/ffa9e0d287d0a86e1e0eb7dc2dec16d9f3e84450))
18+
* **lambda-nodejs:** support esbuild inject ([#19221](https://github.com/aws/aws-cdk/issues/19221)) ([3432c45](https://github.com/aws/aws-cdk/commit/3432c457fe38a83743d7ce2a5cb6c36a6ec01b8f)), closes [#19133](https://github.com/aws/aws-cdk/issues/19133)
19+
* **s3:** add `s3:ObjectRestore:Delete` to `EventType` for notification ([#19250](https://github.com/aws/aws-cdk/issues/19250)) ([e0f863a](https://github.com/aws/aws-cdk/commit/e0f863a4c56041860e14c75b9aa5a6d35860fae6)), closes [#19223](https://github.com/aws/aws-cdk/issues/19223)
20+
* **servicecatalog:** Service Catalog is now in Developer Preview ([#19204](https://github.com/aws/aws-cdk/issues/19204)) ([6dfc254](https://github.com/aws/aws-cdk/commit/6dfc254e1925597b4ef2ece9c132b1a0e580dd6d))
21+
22+
23+
### Bug Fixes
24+
25+
* **apigatewayv2-integrations:** in case of multiple routes, only one execute permission is created ([#18716](https://github.com/aws/aws-cdk/issues/18716)) ([1e352ca](https://github.com/aws/aws-cdk/commit/1e352ca2ab458bfe4e1de6cf431166654ce9aa58))
26+
* **aws-apigateway:** missing comma to make failure response payload valid json ([#19253](https://github.com/aws/aws-cdk/issues/19253)) ([b1fce4f](https://github.com/aws/aws-cdk/commit/b1fce4f1641c90a4b7d1d33139453260b452d5cd)), closes [#19252](https://github.com/aws/aws-cdk/issues/19252)
27+
* **aws-route53-targets:** add support for custom cname_prefix urls in elastic beanstalk environment endpoint target ([#18804](https://github.com/aws/aws-cdk/issues/18804)) ([289a794](https://github.com/aws/aws-cdk/commit/289a79467d9974ee3582c9e30843b0eb9e90b467))
28+
* **cli:** `watch` logs always end with the 'truncated' message ([#19241](https://github.com/aws/aws-cdk/issues/19241)) ([d3fdfe5](https://github.com/aws/aws-cdk/commit/d3fdfe5264e64cb333795b32edbad36cfaab3dc7)), closes [#18805](https://github.com/aws/aws-cdk/issues/18805)
29+
* **cli:** deprecated stack ids printed at the end of synth ([#19216](https://github.com/aws/aws-cdk/issues/19216)) ([7d8a479](https://github.com/aws/aws-cdk/commit/7d8a4792a142f45109f35a51c6e1b3888d4111d3)), closes [#18599](https://github.com/aws/aws-cdk/issues/18599)
30+
* **cli:** notices refresh doesn't respect the --no-notices flag ([#19226](https://github.com/aws/aws-cdk/issues/19226)) ([b3c5fe8](https://github.com/aws/aws-cdk/commit/b3c5fe8d0b695e06558bce23a6dd39b20265594f))
31+
* **efs:** fix bug when setting both lifecyclePolicy and outOfInfrequentAccessPolicy ([#19082](https://github.com/aws/aws-cdk/issues/19082)) ([d435ab6](https://github.com/aws/aws-cdk/commit/d435ab6120c47464427489d98bea9347983a2123)), closes [#19058](https://github.com/aws/aws-cdk/issues/19058)
32+
* **lambda-nodejs:** local tsc detection with pre compilation ([#19266](https://github.com/aws/aws-cdk/issues/19266)) ([5de7b86](https://github.com/aws/aws-cdk/commit/5de7b86d916be6ab892e75e18c54a327fe1f65ff)), closes [#19242](https://github.com/aws/aws-cdk/issues/19242)
33+
* **lambda-python:** asset bundling fails on windows ([#19270](https://github.com/aws/aws-cdk/issues/19270)) ([0da57da](https://github.com/aws/aws-cdk/commit/0da57da9606d982788350a6257f0f0ed6e9fd92a)), closes [#18861](https://github.com/aws/aws-cdk/issues/18861)
34+
* **lambda-python:** docker image gets built even when we don't need to bundle assets ([#16192](https://github.com/aws/aws-cdk/issues/16192)) ([5dc61ea](https://github.com/aws/aws-cdk/commit/5dc61eabc0ea3e6294f83db5deb8528461a1d5bc)), closes [#14747](https://github.com/aws/aws-cdk/issues/14747)
35+
* **rds:** allow cluster from snapshot to enable encrypted storage ([#19175](https://github.com/aws/aws-cdk/issues/19175)) ([bd4141d](https://github.com/aws/aws-cdk/commit/bd4141d864612974829c95d530085d4f18bdfeb8)), closes [#17241](https://github.com/aws/aws-cdk/issues/17241)
36+
* **rds:** read replica instance cannot join domain ([#19202](https://github.com/aws/aws-cdk/issues/19202)) ([cef8fec](https://github.com/aws/aws-cdk/commit/cef8fec1b0410daa6b57c152e9bad73dcc034397)), closes [#18786](https://github.com/aws/aws-cdk/issues/18786)
37+
* **rds:** subnet selection not respected for multi user secret rotation ([#19237](https://github.com/aws/aws-cdk/issues/19237)) ([dc7a17c](https://github.com/aws/aws-cdk/commit/dc7a17cd20198a6eb52c2ab25857e73bd7048d26)), closes [#19233](https://github.com/aws/aws-cdk/issues/19233)
38+
539
## [1.147.0](https://github.com/aws/aws-cdk/compare/v1.146.0...v1.147.0) (2022-03-01)
640

741

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ specific to the CDK.
8989

9090
### Build
9191

92-
The full build of the CDK takes a long time complete; 1-2 hours depending on the performance of the build machine.
92+
The full build of the CDK takes a long time to complete; 1-2 hours depending on the performance of the build machine.
9393
However, most first time contributions will require changing only one CDK module, sometimes two. A full build of the
9494
CDK is not required in these cases.
9595

@@ -481,7 +481,7 @@ grantAwesomePowerBeta1();
481481
```
482482

483483
Times goes by, we get feedback that this method will actually be much better
484-
if it accept a `Principal`. Since adding a required property is a breaking
484+
if it accepts a `Principal`. Since adding a required property is a breaking
485485
change, we will add `grantAwesomePowerBeta2()` and deprecate
486486
`grantAwesomePowerBeta1`:
487487

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"devDependencies": {
1919
"@yarnpkg/lockfile": "^1.1.0",
20-
"cdk-generate-synthetic-examples": "^0.1.6",
20+
"cdk-generate-synthetic-examples": "^0.1.8",
2121
"conventional-changelog-cli": "^2.2.2",
2222
"fs-extra": "^9.1.0",
2323
"graceful-fs": "^4.2.9",

packages/@aws-cdk/assertions/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ Annotations.fromStack(stack).hasError(
550550

551551
Here are the available APIs for `Annotations`:
552552

553-
- `hasError()` and `findError()`
554-
- `hasWarning()` and `findWarning()`
555-
- `hasInfo()` and `findInfo()`
553+
- `hasError()`, `hasNoError()`, and `findError()`
554+
- `hasWarning()`, `hasNoWarning()`, and `findWarning()`
555+
- `hasInfo()`, `hasNoInfo()`, and `findInfo()`
556556

557557
The corresponding `findXxx()` API is complementary to the `hasXxx()` API, except instead
558558
of asserting its presence, it returns the set of matching messages.

packages/@aws-cdk/assertions/lib/annotations.ts

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Stack, Stage } from '@aws-cdk/core';
22
import { SynthesisMessage } from '@aws-cdk/cx-api';
33
import { Messages } from './private/message';
4-
import { findMessage, hasMessage } from './private/messages';
4+
import { findMessage, hasMessage, hasNoMessage } from './private/messages';
55

66
/**
77
* Suite of assertions that can be run on a CDK Stack.
@@ -35,6 +35,19 @@ export class Annotations {
3535
}
3636
}
3737

38+
/**
39+
* Assert that an error with the given message does not exist in the synthesized CDK `Stack`.
40+
*
41+
* @param constructPath the construct path to the error. Provide `'*'` to match all errors in the template.
42+
* @param message the error message as should be expected. This should be a string or Matcher object.
43+
*/
44+
public hasNoError(constructPath: string, message: any): void {
45+
const matchError = hasNoMessage(this._messages, constructPath, constructMessage('error', message));
46+
if (matchError) {
47+
throw new Error(matchError);
48+
}
49+
}
50+
3851
/**
3952
* Get the set of matching errors of a given construct path and message.
4053
*
@@ -58,6 +71,19 @@ export class Annotations {
5871
}
5972
}
6073

74+
/**
75+
* Assert that an warning with the given message does not exist in the synthesized CDK `Stack`.
76+
*
77+
* @param constructPath the construct path to the warning. Provide `'*'` to match all warnings in the template.
78+
* @param message the warning message as should be expected. This should be a string or Matcher object.
79+
*/
80+
public hasNoWarning(constructPath: string, message: any): void {
81+
const matchError = hasNoMessage(this._messages, constructPath, constructMessage('warning', message));
82+
if (matchError) {
83+
throw new Error(matchError);
84+
}
85+
}
86+
6187
/**
6288
* Get the set of matching warning of a given construct path and message.
6389
*
@@ -81,6 +107,19 @@ export class Annotations {
81107
}
82108
}
83109

110+
/**
111+
* Assert that an info with the given message does not exist in the synthesized CDK `Stack`.
112+
*
113+
* @param constructPath the construct path to the info. Provide `'*'` to match all info in the template.
114+
* @param message the info message as should be expected. This should be a string or Matcher object.
115+
*/
116+
public hasNoInfo(constructPath: string, message: any): void {
117+
const matchError = hasNoMessage(this._messages, constructPath, constructMessage('info', message));
118+
if (matchError) {
119+
throw new Error(matchError);
120+
}
121+
}
122+
84123
/**
85124
* Get the set of matching infos of a given construct path and message.
86125
*

packages/@aws-cdk/assertions/lib/private/messages.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SynthesisMessage } from '@aws-cdk/cx-api';
22
import { Messages } from './message';
3-
import { formatFailure, matchSection } from './section';
3+
import { formatAllMatches, formatFailure, matchSection } from './section';
44

55
export function findMessage(messages: Messages, constructPath: string, props: any = {}): { [key: string]: { [key: string]: any } } {
66
const section: { [key: string]: SynthesisMessage } = messages;
@@ -32,6 +32,20 @@ export function hasMessage(messages: Messages, constructPath: string, props: any
3232
].join('\n');
3333
}
3434

35+
export function hasNoMessage(messages: Messages, constructPath: string, props: any): string | void {
36+
const section: { [key: string]: SynthesisMessage } = messages;
37+
const result = matchSection(filterPath(section, constructPath), props);
38+
39+
if (!result.match) {
40+
return;
41+
}
42+
43+
return [
44+
`Expected no matches, but stack has ${Object.keys(result.matches).length} messages as follows:`,
45+
formatAllMatches(result.matches),
46+
].join('\n');
47+
}
48+
3549
// We redact the stack trace by default because it is unnecessarily long and unintelligible.
3650
// If there is a use case for rendering the trace, we can add it later.
3751
function handleTrace(match: any, redact: boolean = true): void {

packages/@aws-cdk/assertions/lib/private/section.ts

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ function eachEntryInSection(
4343
}
4444
}
4545

46+
export function formatAllMatches(matches: {[key: string]: any}): string {
47+
return [
48+
leftPad(JSON.stringify(matches, undefined, 2)),
49+
].join('\n');
50+
}
51+
4652
export function formatFailure(closestResult: MatchResult): string {
4753
return [
4854
'The closest result is:',

packages/@aws-cdk/assertions/test/annotations.test.ts

+33
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ describe('Messages', () => {
5050
});
5151
});
5252

53+
describe('hasNoError', () => {
54+
test('match', () => {
55+
annotations.hasNoError('/Default/Fred', Match.anyValue());
56+
});
57+
58+
test('no match', () => {
59+
expect(() => annotations.hasNoError('/Default/Foo', 'this is an error'))
60+
.toThrowError(/Expected no matches, but stack has 1 messages as follows:/);
61+
});
62+
});
63+
5364
describe('findError', () => {
5465
test('match', () => {
5566
const result = annotations.findError('*', Match.anyValue());
@@ -72,6 +83,17 @@ describe('Messages', () => {
7283
});
7384
});
7485

86+
describe('hasNoWarning', () => {
87+
test('match', () => {
88+
annotations.hasNoWarning('/Default/Foo', Match.anyValue());
89+
});
90+
91+
test('no match', () => {
92+
expect(() => annotations.hasNoWarning('/Default/Fred', 'this is a warning'))
93+
.toThrowError(/Expected no matches, but stack has 1 messages as follows:/);
94+
});
95+
});
96+
7597
describe('findWarning', () => {
7698
test('match', () => {
7799
const result = annotations.findWarning('*', Match.anyValue());
@@ -94,6 +116,17 @@ describe('Messages', () => {
94116
});
95117
});
96118

119+
describe('hasNoInfo', () => {
120+
test('match', () => {
121+
annotations.hasNoInfo('/Default/Qux', 'this info is incorrect');
122+
});
123+
124+
test('no match', () => {
125+
expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info'))
126+
.toThrowError(/Expected no matches, but stack has 1 messages as follows:/);
127+
});
128+
});
129+
97130
describe('findInfo', () => {
98131
test('match', () => {
99132
const result = annotations.findInfo('/Default/Qux', 'this is an info');

packages/@aws-cdk/aws-apigatewayv2-authorizers/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@aws-cdk/cdk-build-tools": "0.0.0",
8686
"@aws-cdk/cdk-integ-tools": "0.0.0",
8787
"@aws-cdk/pkglint": "0.0.0",
88-
"@types/aws-lambda": "^8.10.92",
88+
"@types/aws-lambda": "^8.10.93",
8989
"@types/jest": "^27.4.1"
9090
},
9191
"dependencies": {

packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ export class ScalableTarget extends Resource implements IScalableTarget {
148148
if (action.minCapacity === undefined && action.maxCapacity === undefined) {
149149
throw new Error(`You must supply at least one of minCapacity or maxCapacity, got ${JSON.stringify(action)}`);
150150
}
151+
152+
// add a warning on synth when minute is not defined in a cron schedule
153+
action.schedule._bind(this);
154+
151155
this.actions.push({
152156
scheduledActionName: id,
153157
schedule: action.schedule.expressionString,

packages/@aws-cdk/aws-applicationautoscaling/lib/schedule.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Duration } from '@aws-cdk/core';
1+
import { Annotations, Duration } from '@aws-cdk/core';
2+
import { Construct } from 'constructs';
23

34
/**
45
* Schedule for scheduled scaling actions
@@ -58,16 +59,29 @@ export abstract class Schedule {
5859
const day = fallback(options.day, options.weekDay !== undefined ? '?' : '*');
5960
const weekDay = fallback(options.weekDay, '?');
6061

61-
return new LiteralSchedule(`cron(${minute} ${hour} ${day} ${month} ${weekDay} ${year})`);
62+
return new class extends Schedule {
63+
public readonly expressionString: string = `cron(${minute} ${hour} ${day} ${month} ${weekDay} ${year})`;
64+
public _bind(scope: Construct) {
65+
if (!options.minute) {
66+
Annotations.of(scope).addWarning('cron: If you don\'t pass \'minute\', by default the event runs every minute. Pass \'minute: \'*\'\' if that\'s what you intend, or \'minute: 0\' to run once per hour instead.');
67+
}
68+
return new LiteralSchedule(this.expressionString);
69+
}
70+
};
6271
}
6372

6473
/**
6574
* Retrieve the expression for this schedule
6675
*/
6776
public abstract readonly expressionString: string;
6877

69-
protected constructor() {
70-
}
78+
protected constructor() {}
79+
80+
/**
81+
*
82+
* @internal
83+
*/
84+
public abstract _bind(scope: Construct): void;
7185
}
7286

7387
/**
@@ -126,6 +140,8 @@ class LiteralSchedule extends Schedule {
126140
constructor(public readonly expressionString: string) {
127141
super();
128142
}
143+
144+
public _bind() {}
129145
}
130146

131147
function fallback<T>(x: T | undefined, def: T): T {

0 commit comments

Comments
 (0)