Skip to content

Commit 596db3b

Browse files
authored
Merge branch 'master' into huijbers/re-enable-rosetta-strict
2 parents 0c8c39f + bde44e7 commit 596db3b

File tree

21 files changed

+385
-23
lines changed

21 files changed

+385
-23
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
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.132.0](https://github.com/aws/aws-cdk/compare/v1.131.0...v1.132.0) (2021-11-09)
6+
7+
8+
### Features
9+
10+
* **apigatewayv2:** http api - mTLS support ([#17284](https://github.com/aws/aws-cdk/issues/17284)) ([54be156](https://github.com/aws/aws-cdk/commit/54be1567546ffd52e83fbe52531f901c0b6c29c9)), closes [#12559](https://github.com/aws/aws-cdk/issues/12559)
11+
* **stepfunctions-tasks:** add `AutoTerminationPolicy` to `EmrCreateCluster` ([#16976](https://github.com/aws/aws-cdk/issues/16976)) ([27ad7d8](https://github.com/aws/aws-cdk/commit/27ad7d86824b6378d470cda7304e7ae89ebbebf4))
12+
* the assertions module is now stable! ([#17395](https://github.com/aws/aws-cdk/issues/17395)) ([ede5e22](https://github.com/aws/aws-cdk/commit/ede5e22da2e59218534c17c33a21cab98a3001a9))
13+
* **cfnspec:** cloudformation spec v47.0.0 ([#17392](https://github.com/aws/aws-cdk/issues/17392)) ([7100d43](https://github.com/aws/aws-cdk/commit/7100d43ba7b9e9ce74fb64b33403aa8eaee63255))
14+
* **lambda-nodejs:** custom asset hash ([#16412](https://github.com/aws/aws-cdk/issues/16412)) ([90da730](https://github.com/aws/aws-cdk/commit/90da730244513f9614604f6be3a77adbb6b17f79)), closes [#16157](https://github.com/aws/aws-cdk/issues/16157)
15+
16+
17+
### Bug Fixes
18+
19+
* **codecommit:** notifyOnPullRequestMerged method has a typo in its name ([#17348](https://github.com/aws/aws-cdk/issues/17348)) ([cac5726](https://github.com/aws/aws-cdk/commit/cac572620210a435f679cf7d7d9f8b6e733b340c))
20+
* **opensearch:** domain doesn't handle tokens in capacity configuration ([#17131](https://github.com/aws/aws-cdk/issues/17131)) ([2627939](https://github.com/aws/aws-cdk/commit/2627939108a2e979e385bf2942da1c05d48c678c)), closes [#15014](https://github.com/aws/aws-cdk/issues/15014)
21+
522
## [1.131.0](https://github.com/aws/aws-cdk/compare/v1.130.0...v1.131.0) (2021-11-07)
623

724

pack.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ function lerna_scopes() {
4141
echo "Extracting code samples" >&2
4242
scripts/run-rosetta.sh $TMPDIR/jsii.txt
4343

44+
echo "Infusing examples back into assemblies" >&2
45+
$ROSETTA infuse \
46+
samples.tabl.json \
47+
$(cat $TMPDIR/jsii.txt)
48+
4449
# Jsii packaging (all at once using jsii-pacmak)
4550
echo "Packaging jsii modules" >&2
4651
$PACMAK \

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
"nohoist": [
7272
"**/jszip",
7373
"**/jszip/**",
74+
"@aws-cdk/assertions-alpha/fs-extra",
75+
"@aws-cdk/assertions-alpha/fs-extra/**",
76+
"@aws-cdk/assertions/fs-extra",
77+
"@aws-cdk/assertions/fs-extra/**",
7478
"@aws-cdk/aws-amplify-alpha/yaml",
7579
"@aws-cdk/aws-amplify-alpha/yaml/**",
7680
"@aws-cdk/aws-amplify/yaml",
Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,88 @@
11
AWS Cloud Development Kit (AWS CDK)
2-
Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+
-------------------------------------------------------------------------------
5+
6+
The AWS CDK includes the following third-party software/licensing:
7+
8+
** fs-extra - https://www.npmjs.com/package/fs-extra
9+
Copyright (c) 2011-2017 JP Richardson
10+
11+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
12+
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
13+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
20+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
----------------
24+
25+
** at-least-node - https://www.npmjs.com/package/at-least-node
26+
Copyright (c) 2020 Ryan Zimmerman <[email protected]>
27+
28+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31+
32+
----------------
33+
34+
** graceful-fs - https://www.npmjs.com/package/graceful-fs
35+
Copyright (c) Isaac Z. Schlueter, Ben Noordhuis, and Contributors
36+
37+
Permission to use, copy, modify, and/or distribute this software for any
38+
purpose with or without fee is hereby granted, provided that the above
39+
copyright notice and this permission notice appear in all copies.
40+
41+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
42+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
43+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
44+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
46+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
47+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48+
49+
----------------
50+
51+
** jsonfile - https://www.npmjs.com/package/jsonfile
52+
Copyright (c) 2012-2015, JP Richardson <[email protected]>
53+
54+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
55+
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
56+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
57+
furnished to do so, subject to the following conditions:
58+
59+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
60+
61+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
62+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
63+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
64+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65+
66+
----------------
67+
68+
** universalify - https://www.npmjs.com/package/universalify
69+
Copyright (c) 2017, Ryan Zimmerman <[email protected]>
70+
71+
Permission is hereby granted, free of charge, to any person obtaining a copy of
72+
this software and associated documentation files (the 'Software'), to deal in
73+
the Software without restriction, including without limitation the rights to
74+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
75+
the Software, and to permit persons to whom the Software is furnished to do so,
76+
subject to the following conditions:
77+
78+
The above copyright notice and this permission notice shall be included in all
79+
copies or substantial portions of the Software.
80+
81+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
83+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
84+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
85+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
86+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
87+
88+
----------------

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import * as path from 'path';
12
import { Stack, Stage } from '@aws-cdk/core';
3+
import * as fs from 'fs-extra';
24
import { Match } from './match';
35
import { Matcher } from './matcher';
46
import { findMappings, hasMapping } from './private/mappings';
@@ -179,5 +181,9 @@ function toTemplate(stack: Stack): any {
179181
throw new Error('unexpected: all stacks must be part of a Stage or an App');
180182
}
181183
const assembly = root.synth();
184+
if (stack.nestedStackParent) {
185+
// if this is a nested stack (it has a parent), then just read the template as a string
186+
return JSON.parse(fs.readFileSync(path.join(assembly.directory, stack.templateFile)).toString('utf-8'));
187+
}
182188
return assembly.getStackArtifact(stack.artifactId).template;
183189
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"devDependencies": {
6565
"@aws-cdk/cdk-build-tools": "0.0.0",
6666
"@aws-cdk/pkglint": "0.0.0",
67+
"@types/fs-extra": "^9.0.13",
6768
"@types/jest": "^27.0.2",
6869
"constructs": "^3.3.69",
6970
"jest": "^27.3.1",
@@ -73,14 +74,18 @@
7374
"@aws-cdk/cloud-assembly-schema": "0.0.0",
7475
"@aws-cdk/core": "0.0.0",
7576
"@aws-cdk/cx-api": "0.0.0",
76-
"constructs": "^3.3.69"
77+
"constructs": "^3.3.69",
78+
"fs-extra": "^9.1.0"
7779
},
7880
"peerDependencies": {
7981
"@aws-cdk/cloud-assembly-schema": "0.0.0",
8082
"@aws-cdk/core": "0.0.0",
8183
"@aws-cdk/cx-api": "0.0.0",
8284
"constructs": "^3.3.69"
8385
},
86+
"bundledDependencies": [
87+
"fs-extra"
88+
],
8489
"repository": {
8590
"url": "https://github.com/aws/aws-cdk.git",
8691
"type": "git",

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { App, CfnMapping, CfnOutput, CfnResource, Stack } from '@aws-cdk/core';
1+
import { App, CfnMapping, CfnOutput, CfnResource, NestedStack, Stack } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { Match, Template } from '../lib';
44

55
describe('Template', () => {
6-
describe('asObject', () => {
7-
test('fromString', () => {
8-
const template = Template.fromString(`{
6+
test('fromString', () => {
7+
const template = Template.fromString(`{
98
"Resources": {
109
"Foo": {
1110
"Type": "Baz::Qux",
@@ -14,30 +13,57 @@ describe('Template', () => {
1413
}
1514
}`);
1615

16+
expect(template.toJSON()).toEqual({
17+
Resources: {
18+
Foo: {
19+
Type: 'Baz::Qux',
20+
Properties: { Fred: 'Waldo' },
21+
},
22+
},
23+
});
24+
});
25+
26+
describe('fromStack', () => {
27+
test('default', () => {
28+
const app = new App({
29+
context: {
30+
'@aws-cdk/core:newStyleStackSynthesis': false,
31+
},
32+
});
33+
const stack = new Stack(app);
34+
new CfnResource(stack, 'Foo', {
35+
type: 'Foo::Bar',
36+
properties: {
37+
Baz: 'Qux',
38+
},
39+
});
40+
const template = Template.fromStack(stack);
41+
1742
expect(template.toJSON()).toEqual({
1843
Resources: {
1944
Foo: {
20-
Type: 'Baz::Qux',
21-
Properties: { Fred: 'Waldo' },
45+
Type: 'Foo::Bar',
46+
Properties: { Baz: 'Qux' },
2247
},
2348
},
2449
});
2550
});
2651

27-
test('fromStack', () => {
52+
test('nested', () => {
2853
const app = new App({
2954
context: {
3055
'@aws-cdk/core:newStyleStackSynthesis': false,
3156
},
3257
});
3358
const stack = new Stack(app);
34-
new CfnResource(stack, 'Foo', {
59+
const nested = new NestedStack(stack, 'MyNestedStack');
60+
new CfnResource(nested, 'Foo', {
3561
type: 'Foo::Bar',
3662
properties: {
3763
Baz: 'Qux',
3864
},
3965
});
40-
const template = Template.fromStack(stack);
66+
const template = Template.fromStack(nested);
4167

4268
expect(template.toJSON()).toEqual({
4369
Resources: {

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Higher level constructs for Websocket APIs | ![Experimental](https://img.shields
4040
- [VPC Link](#vpc-link)
4141
- [Private Integration](#private-integration)
4242
- [WebSocket API](#websocket-api)
43+
- [Manage Connections Permission](#manage-connections-permission)
4344

4445
## Introduction
4546

@@ -403,3 +404,22 @@ webSocketApi.addRoute('sendmessage', {
403404
}),
404405
});
405406
```
407+
408+
### Manage Connections Permission
409+
410+
Grant permission to use API Gateway Management API of a WebSocket API by calling the `grantManageConnections` API.
411+
You can use Management API to send a callback message to a connected client, get connection information, or disconnect the client. Learn more at [Use @connections commands in your backend service](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html).
412+
413+
```ts
414+
const lambda = new lambda.Function(this, 'lambda', { /* ... */ });
415+
416+
const webSocketApi = new WebSocketApi(stack, 'mywsapi');
417+
const stage = new WebSocketStage(stack, 'mystage', {
418+
webSocketApi,
419+
stageName: 'dev',
420+
});
421+
// per stage permission
422+
stage.grantManageConnections(lambda);
423+
// for all the stages permission
424+
webSocketApi.grantManageConnections(lambda);
425+
```

packages/@aws-cdk/aws-apigatewayv2/lib/websocket/api.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Grant, IGrantable } from '@aws-cdk/aws-iam';
2+
import { Stack } from '@aws-cdk/core';
13
import { Construct } from 'constructs';
24
import { CfnApi } from '../apigatewayv2.generated';
35
import { IApi } from '../common/api';
@@ -127,4 +129,23 @@ export class WebSocketApi extends ApiBase implements IWebSocketApi {
127129
...options,
128130
});
129131
}
132+
133+
/**
134+
* Grant access to the API Gateway management API for this WebSocket API to an IAM
135+
* principal (Role/Group/User).
136+
*
137+
* @param identity The principal
138+
*/
139+
public grantManageConnections(identity: IGrantable): Grant {
140+
const arn = Stack.of(this).formatArn({
141+
service: 'execute-api',
142+
resource: this.apiId,
143+
});
144+
145+
return Grant.addToPrincipal({
146+
grantee: identity,
147+
actions: ['execute-api:ManageConnections'],
148+
resourceArns: [`${arn}/*/POST/@connections/*`],
149+
});
150+
}
130151
}

packages/@aws-cdk/aws-apigatewayv2/lib/websocket/stage.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Grant, IGrantable } from '@aws-cdk/aws-iam';
12
import { Stack } from '@aws-cdk/core';
23
import { Construct } from 'constructs';
34
import { CfnStage } from '../apigatewayv2.generated';
@@ -114,4 +115,23 @@ export class WebSocketStage extends StageBase implements IWebSocketStage {
114115
const urlPath = this.stageName;
115116
return `https://${this.api.apiId}.execute-api.${s.region}.${s.urlSuffix}/${urlPath}`;
116117
}
118+
119+
/**
120+
* Grant access to the API Gateway management API for this WebSocket API Stage to an IAM
121+
* principal (Role/Group/User).
122+
*
123+
* @param identity The principal
124+
*/
125+
public grantManagementApiAccess(identity: IGrantable): Grant {
126+
const arn = Stack.of(this.api).formatArn({
127+
service: 'execute-api',
128+
resource: this.api.apiId,
129+
});
130+
131+
return Grant.addToPrincipal({
132+
grantee: identity,
133+
actions: ['execute-api:ManageConnections'],
134+
resourceArns: [`${arn}/${this.stageName}/POST/@connections/*`],
135+
});
136+
}
117137
}

0 commit comments

Comments
 (0)