Skip to content

Commit fe6d5aa

Browse files
authored
Merge branch 'master' into ec2-m6i
2 parents 1b9d936 + 04d4547 commit fe6d5aa

37 files changed

Lines changed: 1685 additions & 263 deletions

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

Lines changed: 58 additions & 58 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
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.120.0](https://github.com/aws/aws-cdk/compare/v1.119.0...v1.120.0) (2021-08-26)
6+
7+
8+
### Features
9+
10+
* **assertions:** queries and assertions against the Outputs and Mappings sections ([#15892](https://github.com/aws/aws-cdk/issues/15892)) ([90f95e1](https://github.com/aws/aws-cdk/commit/90f95e10f4dd9e4992731d6262dcfc767b65ab3f))
11+
* **stepfunctions:** add support to heartbeat error inside catch block ([#16078](https://github.com/aws/aws-cdk/issues/16078)) ([2372b3c](https://github.com/aws/aws-cdk/commit/2372b3c360d13fb0224fc981a7bb1ae318581265)), closes [#16084](https://github.com/aws/aws-cdk/issues/16084)
12+
* **cfnspec:** cloudformation spec v40.0.0 ([#16183](https://github.com/aws/aws-cdk/issues/16183)) ([b059124](https://github.com/aws/aws-cdk/commit/b059124b238e27751217cbdaaa01c38b00e80fc9))
13+
* **cloudwatch:** add support for cross-account alarms ([#16007](https://github.com/aws/aws-cdk/issues/16007)) ([e547ba0](https://github.com/aws/aws-cdk/commit/e547ba0d1491af0abe703132fa06fe786ffd7070)), closes [#15959](https://github.com/aws/aws-cdk/issues/15959)
14+
* **codecommit:** make Repository a source for CodeStar Notifications ([#15739](https://github.com/aws/aws-cdk/issues/15739)) ([ae34d4a](https://github.com/aws/aws-cdk/commit/ae34d4a69a5073d8f0175b5282fa8bf92139fab5))
15+
* **cognito:** user pools - device tracking ([#16055](https://github.com/aws/aws-cdk/issues/16055)) ([64019bb](https://github.com/aws/aws-cdk/commit/64019bbf090e156261feb626a5a4bd7ff4f26545)), closes [#15013](https://github.com/aws/aws-cdk/issues/15013)
16+
* **docdb:** cluster - deletion protection ([#15216](https://github.com/aws/aws-cdk/issues/15216)) ([0f7beb2](https://github.com/aws/aws-cdk/commit/0f7beb29be18d809052f4d46e415a0394c9299ab))
17+
* **ecs:** add support for Bottlerocket on ARM64 ([#15454](https://github.com/aws/aws-cdk/issues/15454)) ([cd280a8](https://github.com/aws/aws-cdk/commit/cd280a8f4f46eb50be3a25d80c00a807881832c4)), closes [#14466](https://github.com/aws/aws-cdk/issues/14466)
18+
* **lambda:** nodejs14.x supports inline code ([#16131](https://github.com/aws/aws-cdk/issues/16131)) ([305f683](https://github.com/aws/aws-cdk/commit/305f683e86cca221705c0138572faa38043396eb))
19+
* **rds:** support 's3export' for Postgres database instances ([#16124](https://github.com/aws/aws-cdk/issues/16124)) ([1d54a45](https://github.com/aws/aws-cdk/commit/1d54a456cd5e2ff65251097f9a684e1ac200cc52)), closes [#14546](https://github.com/aws/aws-cdk/issues/14546) [#10370](https://github.com/aws/aws-cdk/issues/10370) [#14546](https://github.com/aws/aws-cdk/issues/14546)
20+
* **s3-deployment:** exclude and include filters ([#16054](https://github.com/aws/aws-cdk/issues/16054)) ([d42e89e](https://github.com/aws/aws-cdk/commit/d42e89e01034dcba08c8f8ac0390a743143c4531)), closes [#14362](https://github.com/aws/aws-cdk/issues/14362) [#14362](https://github.com/aws/aws-cdk/issues/14362)
21+
22+
23+
### Bug Fixes
24+
25+
* **apigatewayv2:** http api - disallow empty string as domain name ([#16044](https://github.com/aws/aws-cdk/issues/16044)) ([9c39bcb](https://github.com/aws/aws-cdk/commit/9c39bcb970fc791e94d199b962cc006fca1a3320))
26+
* **appsync:** addSubscription only allows for field type ([#16097](https://github.com/aws/aws-cdk/issues/16097)) ([000d151](https://github.com/aws/aws-cdk/commit/000d151bec2215aa530819c3cf2c8c432352fec3)), closes [#10078](https://github.com/aws/aws-cdk/issues/10078) [#16071](https://github.com/aws/aws-cdk/issues/16071)
27+
* **cfnspec:** changes to resource-level documentation not supported ([#16170](https://github.com/aws/aws-cdk/issues/16170)) ([82e4b4f](https://github.com/aws/aws-cdk/commit/82e4b4f07be202e2d6c6afa4f9ed0d9d6146f0a8))
28+
* **cli:** Python init template does not work in directory with '-' ([#15939](https://github.com/aws/aws-cdk/issues/15939)) ([3b2c790](https://github.com/aws/aws-cdk/commit/3b2c790c2b7d210868576540feab4e088376ab6c)), closes [#15938](https://github.com/aws/aws-cdk/issues/15938)
29+
* **cli:** unknown command pytest in build container fails integration tests ([#16134](https://github.com/aws/aws-cdk/issues/16134)) ([0f7c0b4](https://github.com/aws/aws-cdk/commit/0f7c0b421327f1ffed28de79692191af187f23ca)), closes [#15939](https://github.com/aws/aws-cdk/issues/15939)
30+
* **resourcegroups:** ResourceGroup not using TagType.STANDARD, causes deploy failure ([#16211](https://github.com/aws/aws-cdk/issues/16211)) ([cdee1af](https://github.com/aws/aws-cdk/commit/cdee1af03c34a1c08988e672bae6edc2538a8877)), closes [#12986](https://github.com/aws/aws-cdk/issues/12986)
31+
* **s3:** bucket is not emptied before update when the name changes ([#16203](https://github.com/aws/aws-cdk/issues/16203)) ([b1d69d7](https://github.com/aws/aws-cdk/commit/b1d69d7b06cd2a2ae8f578e217bdf7fef50a0163)), closes [#14011](https://github.com/aws/aws-cdk/issues/14011)
32+
* **ses:** drop spam rule appears in the incorrect order ([#16146](https://github.com/aws/aws-cdk/issues/16146)) ([677fedc](https://github.com/aws/aws-cdk/commit/677fedcc5351b8b5346970fac03e5e342f36265b)), closes [#16091](https://github.com/aws/aws-cdk/issues/16091)
33+
* **sqs:** unable to import a FIFO queue when the queue ARN is a token ([#15976](https://github.com/aws/aws-cdk/issues/15976)) ([a1a65bc](https://github.com/aws/aws-cdk/commit/a1a65bc9a38b06ec51dff462e52b1beb8d421a56)), closes [#12466](https://github.com/aws/aws-cdk/issues/12466)
34+
* **ssm:** StringParameter.fromStringParameterAttributes cannot accept version as a numeric Token ([#16048](https://github.com/aws/aws-cdk/issues/16048)) ([eb54cd4](https://github.com/aws/aws-cdk/commit/eb54cd416a48708898e30986058491e21125b2f7)), closes [#11913](https://github.com/aws/aws-cdk/issues/11913)
35+
* **ec2:** fix vpc endpoint incorrect issue in China region ([#16139](https://github.com/aws/aws-cdk/issues/16139)) ([0d0db38](https://github.com/aws/aws-cdk/commit/0d0db38e3cdb557b4a641c5993068400847cc7df)), closes [#9864](https://github.com/aws/aws-cdk/issues/9864)
36+
* **eks:** insecure kubeconfig warning ([#16063](https://github.com/aws/aws-cdk/issues/16063)) ([82dd282](https://github.com/aws/aws-cdk/commit/82dd2822a86431d0aa0be896550d421810b80c67)), closes [#14560](https://github.com/aws/aws-cdk/issues/14560)
37+
38+
39+
540
## [1.119.0](https://github.com/aws/aws-cdk/compare/v1.118.0...v1.119.0) (2021-08-17)
641

742

packages/@aws-cdk/aws-apigatewayv2/lib/common/api-mapping.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ export class ApiMapping extends Resource implements IApiMapping {
103103
}
104104
}
105105

106-
const paramRe = '^[a-zA-Z0-9]*[-_.+!,$]?[a-zA-Z0-9]*$';
107-
if (props.apiMappingKey && !new RegExp(paramRe).test(props.apiMappingKey)) {
108-
throw new Error('An ApiMapping key may contain only letters, numbers and one of $-_.+!*\'(),');
109-
}
110-
111106
if (props.apiMappingKey === '') {
112107
throw new Error('empty string for api mapping key not allowed');
113108
}

packages/@aws-cdk/aws-apigatewayv2/test/common/api-mapping.test.ts

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -83,120 +83,6 @@ describe('ApiMapping', () => {
8383
}).toThrow(/empty string for api mapping key not allowed/);
8484
});
8585

86-
test('apiMappingKey validation - single slash not allowed', () => {
87-
88-
const stack = new Stack();
89-
const api = new HttpApi(stack, 'Api');
90-
91-
const dn = new DomainName(stack, 'DomainName', {
92-
domainName,
93-
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
94-
});
95-
96-
expect(() => {
97-
new ApiMapping(stack, 'Mapping', {
98-
api,
99-
domainName: dn,
100-
apiMappingKey: '/',
101-
});
102-
}).toThrow(/An ApiMapping key may contain only letters, numbers and one of/);
103-
});
104-
105-
test('apiMappingKey validation - prefix slash not allowd', () => {
106-
107-
const stack = new Stack();
108-
const api = new HttpApi(stack, 'Api');
109-
110-
const dn = new DomainName(stack, 'DomainName', {
111-
domainName,
112-
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
113-
});
114-
115-
expect(() => {
116-
new ApiMapping(stack, 'Mapping', {
117-
api,
118-
domainName: dn,
119-
apiMappingKey: '/foo',
120-
});
121-
}).toThrow(/An ApiMapping key may contain only letters, numbers and one of/);
122-
});
123-
124-
test('apiMappingKey validation - slash in the middle not allowed', () => {
125-
126-
const stack = new Stack();
127-
const api = new HttpApi(stack, 'Api');
128-
129-
const dn = new DomainName(stack, 'DomainName', {
130-
domainName,
131-
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
132-
});
133-
134-
expect(() => {
135-
new ApiMapping(stack, 'Mapping', {
136-
api,
137-
domainName: dn,
138-
apiMappingKey: 'foo/bar',
139-
});
140-
}).toThrow(/An ApiMapping key may contain only letters, numbers and one of/);
141-
});
142-
143-
test('apiMappingKey validation - trailing slash not allowed', () => {
144-
145-
const stack = new Stack();
146-
const api = new HttpApi(stack, 'Api');
147-
148-
const dn = new DomainName(stack, 'DomainName', {
149-
domainName,
150-
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
151-
});
152-
153-
expect(() => {
154-
new ApiMapping(stack, 'Mapping', {
155-
api,
156-
domainName: dn,
157-
apiMappingKey: 'foo/',
158-
});
159-
}).toThrow(/An ApiMapping key may contain only letters, numbers and one of/);
160-
});
161-
162-
test('apiMappingKey validation - special character in the prefix not allowed', () => {
163-
164-
const stack = new Stack();
165-
const api = new HttpApi(stack, 'Api');
166-
167-
const dn = new DomainName(stack, 'DomainName', {
168-
domainName,
169-
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
170-
});
171-
172-
expect(() => {
173-
new ApiMapping(stack, 'Mapping', {
174-
api,
175-
domainName: dn,
176-
apiMappingKey: '^foo',
177-
});
178-
}).toThrow(/An ApiMapping key may contain only letters, numbers and one of/);
179-
});
180-
181-
test('apiMappingKey validation - multiple special character not allowed', () => {
182-
183-
const stack = new Stack();
184-
const api = new HttpApi(stack, 'Api');
185-
186-
const dn = new DomainName(stack, 'DomainName', {
187-
domainName,
188-
certificate: Certificate.fromCertificateArn(stack, 'cert', certArn),
189-
});
190-
191-
expect(() => {
192-
new ApiMapping(stack, 'Mapping', {
193-
api,
194-
domainName: dn,
195-
apiMappingKey: 'foo.*$',
196-
});
197-
}).toThrow(/An ApiMapping key may contain only letters, numbers and one of/);
198-
});
199-
20086
test('import mapping', () => {
20187

20288
const stack = new Stack();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ represents the amount of errors reported by that Lambda function:
2828
const errors = fn.metricErrors();
2929
```
3030

31+
`Metric` objects can be account and region aware. You can specify `account` and `region` as properties of the metric, or use the `metric.attachTo(Construct)` method. `metric.attachTo()` will automatically copy the `region` and `account` fields of the `Construct`, which can come from anywhere in the Construct tree.
32+
3133
You can also instantiate `Metric` objects to reference any
3234
[published metric](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html)
3335
that's not exposed using a convenience method on the CDK construct.
@@ -160,6 +162,8 @@ The most important properties to set while creating an Alarms are:
160162
- `evaluationPeriods`: how many consecutive periods the metric has to be
161163
breaching the the threshold for the alarm to trigger.
162164

165+
To create a cross-account alarm, make sure you have enabled [cross-account functionality](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Cross-Account-Cross-Region.html) in CloudWatch. Then, set the `account` property in the `Metric` object either manually or via the `metric.attachTo()` method.
166+
163167
### Alarm Actions
164168

165169
To add actions to an alarm, use the integration classes from the

packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ export class Alarm extends AlarmBase {
257257
return dispatchMetric(metric, {
258258
withStat(stat, conf) {
259259
self.validateMetricStat(stat, metric);
260-
if (conf.renderingProperties?.label == undefined) {
260+
const canRenderAsLegacyMetric = conf.renderingProperties?.label == undefined &&
261+
(stat.account == undefined || Stack.of(self).account == stat.account);
262+
// Do this to disturb existing templates as little as possible
263+
if (canRenderAsLegacyMetric) {
261264
return dropUndefined({
262265
dimensions: stat.dimensions,
263266
namespace: stat.namespace,
@@ -283,6 +286,7 @@ export class Alarm extends AlarmBase {
283286
unit: stat.unitFilter,
284287
},
285288
id: 'm1',
289+
accountId: stat.account,
286290
label: conf.renderingProperties?.label,
287291
returnData: true,
288292
} as CfnAlarm.MetricDataQueryProperty,
@@ -344,17 +348,14 @@ export class Alarm extends AlarmBase {
344348
}
345349

346350
/**
347-
* Validate that if a region and account are in the given stat config, they match the Alarm
351+
* Validate that if a region is in the given stat config, they match the Alarm
348352
*/
349353
private validateMetricStat(stat: MetricStatConfig, metric: IMetric) {
350354
const stack = Stack.of(this);
351355

352356
if (definitelyDifferent(stat.region, stack.region)) {
353357
throw new Error(`Cannot create an Alarm in region '${stack.region}' based on metric '${metric}' in '${stat.region}'`);
354358
}
355-
if (definitelyDifferent(stat.account, stack.account)) {
356-
throw new Error(`Cannot create an Alarm in account '${stack.account}' based on metric '${metric}' in '${stat.account}'`);
357-
}
358359
}
359360
}
360361

packages/@aws-cdk/aws-cloudwatch/test/cross-environment.test.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ const a = new Metric({ namespace: 'Test', metricName: 'ACount' });
66

77
let stack1: Stack;
88
let stack2: Stack;
9+
let stack3: Stack;
910
describe('cross environment', () => {
1011
beforeEach(() => {
1112
stack1 = new Stack(undefined, undefined, { env: { region: 'pluto', account: '1234' } });
1213
stack2 = new Stack(undefined, undefined, { env: { region: 'mars', account: '5678' } });
13-
14+
stack3 = new Stack(undefined, undefined, { env: { region: 'pluto', account: '0000' } });
1415
});
1516

1617
describe('in graphs', () => {
@@ -112,6 +113,70 @@ describe('cross environment', () => {
112113

113114

114115
});
116+
117+
test('metric attached to stack3 will render in stack1', () => {
118+
//Cross-account metrics are supported in Alarms
119+
120+
// GIVEN
121+
new Alarm(stack1, 'Alarm', {
122+
threshold: 1,
123+
evaluationPeriods: 1,
124+
metric: a.attachTo(stack3),
125+
});
126+
127+
// THEN
128+
Template.fromStack(stack1).hasResourceProperties('AWS::CloudWatch::Alarm', {
129+
Metrics: [
130+
{
131+
AccountId: '0000',
132+
Id: 'm1',
133+
MetricStat: {
134+
Metric: {
135+
MetricName: 'ACount',
136+
Namespace: 'Test',
137+
},
138+
Period: 300,
139+
Stat: 'Average',
140+
},
141+
ReturnData: true,
142+
},
143+
],
144+
});
145+
});
146+
147+
test('metric can render in a different account', () => {
148+
// GIVEN
149+
const b = new Metric({
150+
namespace: 'Test',
151+
metricName: 'ACount',
152+
account: '0000',
153+
});
154+
155+
new Alarm(stack1, 'Alarm', {
156+
threshold: 1,
157+
evaluationPeriods: 1,
158+
metric: b,
159+
});
160+
161+
// THEN
162+
Template.fromStack(stack1).hasResourceProperties('AWS::CloudWatch::Alarm', {
163+
Metrics: [
164+
{
165+
AccountId: '0000',
166+
Id: 'm1',
167+
MetricStat: {
168+
Metric: {
169+
MetricName: 'ACount',
170+
Namespace: 'Test',
171+
},
172+
Period: 300,
173+
Stat: 'Average',
174+
},
175+
ReturnData: true,
176+
},
177+
],
178+
});
179+
});
115180
});
116181
});
117182

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,16 @@ const rule = repo.onCommentOnPullRequest('CommentOnPullRequest', {
5555
target: new targets.SnsTopic(myTopic),
5656
});
5757
```
58+
59+
## CodeStar Notifications
60+
61+
To define CodeStar Notification rules for Repositories, use one of the `notifyOnXxx()` methods.
62+
They are very similar to `onXxx()` methods for CloudWatch events:
63+
64+
```ts
65+
const target = new chatbot.SlackChannelConfiguration(stack, 'MySlackChannel', {
66+
slackChannelConfigurationName: 'YOUR_CHANNEL_NAME',
67+
slackWorkspaceId: 'YOUR_SLACK_WORKSPACE_ID',
68+
slackChannelId: 'YOUR_SLACK_CHANNEL_ID',
69+
});
70+
const rule = repository.notifyOnPullRequestCreated('NotifyOnPullRequestCreated', target);

0 commit comments

Comments
 (0)