From 84d9d74711e68e010647ee856bdb6a904ddc042e Mon Sep 17 00:00:00 2001 From: AWS CDK Team Date: Tue, 9 Nov 2021 10:47:14 +0000 Subject: [PATCH 01/18] chore(release): 1.132.0 --- CHANGELOG.md | 17 +++++++++++++++++ version.v1.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 780107f78c21a..92798df54dd59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ 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. +## [1.132.0](https://github.com/aws/aws-cdk/compare/v1.131.0...v1.132.0) (2021-11-09) + + +### Features + +* **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) +* **stepfunctions-tasks:** add `AutoTerminationPolicy` to `EmrCreateCluster` ([#16976](https://github.com/aws/aws-cdk/issues/16976)) ([27ad7d8](https://github.com/aws/aws-cdk/commit/27ad7d86824b6378d470cda7304e7ae89ebbebf4)) +* the assertions module is now stable! ([#17395](https://github.com/aws/aws-cdk/issues/17395)) ([ede5e22](https://github.com/aws/aws-cdk/commit/ede5e22da2e59218534c17c33a21cab98a3001a9)) +* **cfnspec:** cloudformation spec v47.0.0 ([#17392](https://github.com/aws/aws-cdk/issues/17392)) ([7100d43](https://github.com/aws/aws-cdk/commit/7100d43ba7b9e9ce74fb64b33403aa8eaee63255)) +* **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) + + +### Bug Fixes + +* **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)) +* **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) + ## [1.131.0](https://github.com/aws/aws-cdk/compare/v1.130.0...v1.131.0) (2021-11-07) diff --git a/version.v1.json b/version.v1.json index 1d5c1405e9991..e3f080f0508a7 100644 --- a/version.v1.json +++ b/version.v1.json @@ -1,3 +1,3 @@ { - "version": "1.131.0" + "version": "1.132.0" } \ No newline at end of file From 334ef245deba55b340218321136da8884cdf82e6 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 9 Nov 2021 15:34:58 +0100 Subject: [PATCH 02/18] chore: activate 'rosetta infuse' feature (#17417) `jsii-rosetta infuse` will modify all the assemblies in-place to add examples to types that don't have examples yet. Re-roll 3 of this feature. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- pack.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pack.sh b/pack.sh index 81eecafabe187..7bf4984e33d4d 100755 --- a/pack.sh +++ b/pack.sh @@ -41,6 +41,11 @@ function lerna_scopes() { echo "Extracting code samples" >&2 scripts/run-rosetta.sh $TMPDIR/jsii.txt +echo "Infusing examples back into assemblies" >&2 +$ROSETTA infuse \ + samples.tabl.json \ + $(cat $TMPDIR/jsii.txt) + # Jsii packaging (all at once using jsii-pacmak) echo "Packaging jsii modules" >&2 $PACMAK \ From 69f5f3a8a4447cba5ae28ab8d9ea58d15332e465 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 9 Nov 2021 17:11:52 +0100 Subject: [PATCH 03/18] chore(cli): update help string for `qualifier` (#17424) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/bin/cdk.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/bin/cdk.ts b/packages/aws-cdk/bin/cdk.ts index a938b00f3c02f..3f90dfc8ff3e2 100644 --- a/packages/aws-cdk/bin/cdk.ts +++ b/packages/aws-cdk/bin/cdk.ts @@ -77,7 +77,7 @@ async function parseCommandLineArguments() { .option('bootstrap-bucket-name', { type: 'string', alias: ['b', 'toolkit-bucket-name'], desc: 'The name of the CDK toolkit bucket; bucket will be created and must not exist', default: undefined }) .option('bootstrap-kms-key-id', { type: 'string', desc: 'AWS KMS master key ID used for the SSE-KMS encryption', default: undefined, conflicts: 'bootstrap-customer-key' }) .option('bootstrap-customer-key', { type: 'boolean', desc: 'Create a Customer Master Key (CMK) for the bootstrap bucket (you will be charged but can customize permissions, modern bootstrapping only)', default: undefined, conflicts: 'bootstrap-kms-key-id' }) - .option('qualifier', { type: 'string', desc: 'Unique string to distinguish multiple bootstrap stacks', default: undefined }) + .option('qualifier', { type: 'string', desc: 'String which must be unique for each bootstrap stack. You must configure it on your CDK app if you change this from the default.', default: undefined }) .option('public-access-block-configuration', { type: 'boolean', desc: 'Block public access configuration on CDK toolkit bucket (enabled by default) ', default: undefined }) .option('tags', { type: 'array', alias: 't', desc: 'Tags to add for the stack (KEY=VALUE)', nargs: 1, requiresArg: true, default: [] }) .option('execute', { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true }) From bc10e6ffb6164c212336ada745923e91adb8fe05 Mon Sep 17 00:00:00 2001 From: Roger Chi Date: Tue, 9 Nov 2021 11:56:04 -0500 Subject: [PATCH 04/18] feat(stepfunctions-tasks): Support `DynamoAttributeValue.listFromJsonPath` (#17376) Add `DynamoAttributeValue.listFromJsonPath(value: string)` to allow specifying a list/array from the state input as a parameter in a DynamoDB PutItem or UpdateItem optimized integration in stepfunctions-tasks. Closes #17375 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../lib/dynamodb/shared-types.ts | 10 ++++++++++ .../dynamodb/integ.call-dynamodb.expected.json | 2 +- .../test/dynamodb/integ.call-dynamodb.ts | 1 + .../test/dynamodb/shared-types.test.ts | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts index c07d1e8fc5e12..0921cf3b2521a 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts @@ -219,6 +219,16 @@ export class DynamoAttributeValue { return new DynamoAttributeValue({ L: value.map((val) => val.toObject()) }); } + /** + * Sets an attribute of type List. For example: "L": [ {"S": "Cookies"} , {"S": "Coffee"}, {"S", "Veggies"}] + * + * @param value Json path that specifies state input to be used + */ + public static listFromJsonPath(value: string) { + validateJsonPath(value); + return new DynamoAttributeValue({ L: value }); + } + /** * Sets an attribute of type Null. For example: "NULL": true */ diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.expected.json index 094221d1ba6bb..a8b7510287767 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.expected.json @@ -193,7 +193,7 @@ { "Ref": "AWS::Partition" }, - ":states:::dynamodb:putItem\",\"Parameters\":{\"Item\":{\"MessageId\":{\"S\":\"1234\"},\"Text\":{\"S.$\":\"$.bar\"},\"TotalCount\":{\"N\":\"18\"},\"Activated\":{\"BOOL.$\":\"$.foo\"}},\"TableName\":\"", + ":states:::dynamodb:putItem\",\"Parameters\":{\"Item\":{\"MessageId\":{\"S\":\"1234\"},\"Text\":{\"S.$\":\"$.bar\"},\"TotalCount\":{\"N\":\"18\"},\"Activated\":{\"BOOL.$\":\"$.foo\"},\"List\":{\"L.$\":\"$.list\"}},\"TableName\":\"", { "Ref": "Messages804FA4EB" }, diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.ts index e78bba4f6721e..18be323c22db3 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/integ.call-dynamodb.ts @@ -37,6 +37,7 @@ class CallDynamoDBStack extends cdk.Stack { Text: tasks.DynamoAttributeValue.fromString(sfn.JsonPath.stringAt('$.bar')), TotalCount: tasks.DynamoAttributeValue.fromNumber(firstNumber), Activated: tasks.DynamoAttributeValue.booleanFromJsonPath(sfn.JsonPath.stringAt('$.foo')), + List: tasks.DynamoAttributeValue.listFromJsonPath(sfn.JsonPath.stringAt('$.list')), }, table, }); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/shared-types.test.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/shared-types.test.ts index f0810de3e3949..a882fb9f99b2b 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/shared-types.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/dynamodb/shared-types.test.ts @@ -222,6 +222,22 @@ describe('DynamoAttributeValue', () => { }); }); + test('from list with json path', () => { + // GIVEN + const m = '$.path'; + // WHEN + const attribute = tasks.DynamoAttributeValue.listFromJsonPath( + sfn.JsonPath.stringAt(m), + ); + + // THEN + expect(sfn.FieldUtils.renderObject(attribute)).toEqual({ + attributeValue: { + 'L.$': m, + }, + }); + }); + test('from null', () => { // WHEN const attribute = tasks.DynamoAttributeValue.fromNull(true); From 3154a58bfc5ae4b845994c7a0ab45771f5af4cd0 Mon Sep 17 00:00:00 2001 From: JohnLux4 <38677408+eastNine@users.noreply.github.com> Date: Wed, 10 Nov 2021 02:53:31 +0900 Subject: [PATCH 05/18] fix(autoscaling): add timezone property to Scheduled Action (#17330) Add timezone property to ScheduledAction. example: ```typescript import * as asg from '@aws-cdk/aws-autoscaling'; new asg.ScheduledAction(this, 'test', { autoScalingGroup: 'test', desiredCapacity: 1, minCapacity: 1, maxCapacity: 2, schedule: { expressionString: '0 3 * * *' }, timeZone: 'Asia/Seoul' }); ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-autoscaling/lib/scheduled-action.ts | 12 +++++++++++ .../test/scheduled-action.test.ts | 21 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts b/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts index 70a269bde9239..fa5d431bcf47b 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts @@ -8,6 +8,17 @@ import { Schedule } from './schedule'; * Properties for a scheduled scaling action */ export interface BasicScheduledActionProps { + /** + * Specifies the time zone for a cron expression. If a time zone is not provided, UTC is used by default. + * + * Valid values are the canonical names of the IANA time zones, derived from the IANA Time Zone Database (such as Etc/GMT+9 or Pacific/Tahiti). + * + * For more information, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. + * + * @default - UTC + * + */ + readonly timeZone?: string; /** * When to perform this action. * @@ -94,6 +105,7 @@ export class ScheduledAction extends Resource { maxSize: props.maxCapacity, desiredCapacity: props.desiredCapacity, recurrence: props.schedule.expressionString, + timeZone: props.timeZone, }); } } diff --git a/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts b/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts index 3afbd887b45ae..e7aeb92a81b6d 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts @@ -46,6 +46,27 @@ describe('scheduled action', () => { }); + test('have timezone property', () => { + // GIVEN + const stack = new cdk.Stack(); + const asg = makeAutoScalingGroup(stack); + + // WHEN + asg.scaleOnSchedule('ScaleOutAtMiddaySeoul', { + schedule: autoscaling.Schedule.cron({ hour: '12', minute: '0' }), + minCapacity: 12, + timeZone: 'Asia/Seoul', + }); + + // THEN + expect(stack).to(haveResource('AWS::AutoScaling::ScheduledAction', { + MinSize: 12, + Recurrence: '0 12 * * *', + TimeZone: 'Asia/Seoul', + })); + + }); + test('autoscaling group has recommended updatepolicy for scheduled actions', () => { // GIVEN const stack = new cdk.Stack(); From bde44e7a767b88762ecb1370e605e6e5dfc85b52 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 9 Nov 2021 18:31:00 +0000 Subject: [PATCH 06/18] feat(assertions): support assertions over nested stacks (#16972) Add support for nested stacks ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- package.json | 4 + packages/@aws-cdk/assertions/NOTICE | 88 ++++++++++++++++++- packages/@aws-cdk/assertions/lib/template.ts | 6 ++ packages/@aws-cdk/assertions/package.json | 7 +- .../@aws-cdk/assertions/test/template.test.ts | 44 ++++++++-- 5 files changed, 138 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 6f8bbee09c04f..aea497b0788f1 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,10 @@ "nohoist": [ "**/jszip", "**/jszip/**", + "@aws-cdk/assertions-alpha/fs-extra", + "@aws-cdk/assertions-alpha/fs-extra/**", + "@aws-cdk/assertions/fs-extra", + "@aws-cdk/assertions/fs-extra/**", "@aws-cdk/aws-amplify-alpha/yaml", "@aws-cdk/aws-amplify-alpha/yaml/**", "@aws-cdk/aws-amplify/yaml", diff --git a/packages/@aws-cdk/assertions/NOTICE b/packages/@aws-cdk/assertions/NOTICE index ac712780ec5ca..9e3fd34dbe209 100644 --- a/packages/@aws-cdk/assertions/NOTICE +++ b/packages/@aws-cdk/assertions/NOTICE @@ -1,2 +1,88 @@ AWS Cloud Development Kit (AWS CDK) -Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. \ No newline at end of file +Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +------------------------------------------------------------------------------- + +The AWS CDK includes the following third-party software/licensing: + +** fs-extra - https://www.npmjs.com/package/fs-extra +Copyright (c) 2011-2017 JP Richardson + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +---------------- + +** at-least-node - https://www.npmjs.com/package/at-least-node +Copyright (c) 2020 Ryan Zimmerman + +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. + +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. + +---------------- + +** graceful-fs - https://www.npmjs.com/package/graceful-fs +Copyright (c) Isaac Z. Schlueter, Ben Noordhuis, and Contributors + +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. + +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. + +---------------- + +** jsonfile - https://www.npmjs.com/package/jsonfile +Copyright (c) 2012-2015, JP Richardson + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, + merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +---------------- + +** universalify - https://www.npmjs.com/package/universalify +Copyright (c) 2017, Ryan Zimmerman + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the 'Software'), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +---------------- \ No newline at end of file diff --git a/packages/@aws-cdk/assertions/lib/template.ts b/packages/@aws-cdk/assertions/lib/template.ts index 01e0d3376dc8c..dfc830cf8d822 100644 --- a/packages/@aws-cdk/assertions/lib/template.ts +++ b/packages/@aws-cdk/assertions/lib/template.ts @@ -1,4 +1,6 @@ +import * as path from 'path'; import { Stack, Stage } from '@aws-cdk/core'; +import * as fs from 'fs-extra'; import { Match } from './match'; import { Matcher } from './matcher'; import { findMappings, hasMapping } from './private/mappings'; @@ -179,5 +181,9 @@ function toTemplate(stack: Stack): any { throw new Error('unexpected: all stacks must be part of a Stage or an App'); } const assembly = root.synth(); + if (stack.nestedStackParent) { + // if this is a nested stack (it has a parent), then just read the template as a string + return JSON.parse(fs.readFileSync(path.join(assembly.directory, stack.templateFile)).toString('utf-8')); + } return assembly.getStackArtifact(stack.artifactId).template; } \ No newline at end of file diff --git a/packages/@aws-cdk/assertions/package.json b/packages/@aws-cdk/assertions/package.json index 2e814d423cacd..35e2842a2bd0c 100644 --- a/packages/@aws-cdk/assertions/package.json +++ b/packages/@aws-cdk/assertions/package.json @@ -64,6 +64,7 @@ "devDependencies": { "@aws-cdk/cdk-build-tools": "0.0.0", "@aws-cdk/pkglint": "0.0.0", + "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.2", "constructs": "^3.3.69", "jest": "^27.3.1", @@ -73,7 +74,8 @@ "@aws-cdk/cloud-assembly-schema": "0.0.0", "@aws-cdk/core": "0.0.0", "@aws-cdk/cx-api": "0.0.0", - "constructs": "^3.3.69" + "constructs": "^3.3.69", + "fs-extra": "^9.1.0" }, "peerDependencies": { "@aws-cdk/cloud-assembly-schema": "0.0.0", @@ -81,6 +83,9 @@ "@aws-cdk/cx-api": "0.0.0", "constructs": "^3.3.69" }, + "bundledDependencies": [ + "fs-extra" + ], "repository": { "url": "https://github.com/aws/aws-cdk.git", "type": "git", diff --git a/packages/@aws-cdk/assertions/test/template.test.ts b/packages/@aws-cdk/assertions/test/template.test.ts index 3384cda21207f..64141edf52e89 100644 --- a/packages/@aws-cdk/assertions/test/template.test.ts +++ b/packages/@aws-cdk/assertions/test/template.test.ts @@ -1,11 +1,10 @@ -import { App, CfnMapping, CfnOutput, CfnResource, Stack } from '@aws-cdk/core'; +import { App, CfnMapping, CfnOutput, CfnResource, NestedStack, Stack } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { Match, Template } from '../lib'; describe('Template', () => { - describe('asObject', () => { - test('fromString', () => { - const template = Template.fromString(`{ + test('fromString', () => { + const template = Template.fromString(`{ "Resources": { "Foo": { "Type": "Baz::Qux", @@ -14,30 +13,57 @@ describe('Template', () => { } }`); + expect(template.toJSON()).toEqual({ + Resources: { + Foo: { + Type: 'Baz::Qux', + Properties: { Fred: 'Waldo' }, + }, + }, + }); + }); + + describe('fromStack', () => { + test('default', () => { + const app = new App({ + context: { + '@aws-cdk/core:newStyleStackSynthesis': false, + }, + }); + const stack = new Stack(app); + new CfnResource(stack, 'Foo', { + type: 'Foo::Bar', + properties: { + Baz: 'Qux', + }, + }); + const template = Template.fromStack(stack); + expect(template.toJSON()).toEqual({ Resources: { Foo: { - Type: 'Baz::Qux', - Properties: { Fred: 'Waldo' }, + Type: 'Foo::Bar', + Properties: { Baz: 'Qux' }, }, }, }); }); - test('fromStack', () => { + test('nested', () => { const app = new App({ context: { '@aws-cdk/core:newStyleStackSynthesis': false, }, }); const stack = new Stack(app); - new CfnResource(stack, 'Foo', { + const nested = new NestedStack(stack, 'MyNestedStack'); + new CfnResource(nested, 'Foo', { type: 'Foo::Bar', properties: { Baz: 'Qux', }, }); - const template = Template.fromStack(stack); + const template = Template.fromStack(nested); expect(template.toJSON()).toEqual({ Resources: { From acd64f4f23840e51ba432934b9d1377c1ed46ef2 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 9 Nov 2021 20:11:57 +0100 Subject: [PATCH 07/18] docs: re-enable example 'strict' mode where possible (#17421) This will prevent regression in compilation status for the top 25 construct libraries, that we've gone through the effort of making compile. This also gets rid of the `@example` values in most of the construct libraries here. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/assertions/package.json | 2 +- packages/@aws-cdk/aws-apigateway/package.json | 9 +++- .../aws-apigatewayv2-authorizers/package.json | 9 +++- .../aws-apigatewayv2-integrations/README.md | 13 +++--- .../package.json | 9 +++- .../lib/scalable-target.ts | 8 ++-- .../lib/target-tracking-scaling-policy.ts | 2 +- .../aws-applicationautoscaling/package.json | 9 +++- .../aws-appmesh/lib/virtual-service.ts | 2 +- packages/@aws-cdk/aws-appmesh/package.json | 9 +++- packages/@aws-cdk/aws-appsync/package.json | 9 +++- .../@aws-cdk/aws-autoscaling/package.json | 9 +++- packages/@aws-cdk/aws-cloudwatch/package.json | 9 +++- packages/@aws-cdk/aws-codebuild/README.md | 2 +- .../aws-codebuild/lib/file-location.ts | 3 +- packages/@aws-cdk/aws-codebuild/package.json | 9 +++- .../aws-codepipeline-actions/README.md | 2 +- .../aws-codepipeline-actions/package.json | 9 +++- packages/@aws-cdk/aws-dynamodb/package.json | 9 +++- packages/@aws-cdk/aws-ec2/package.json | 9 +++- packages/@aws-cdk/aws-ecr/package.json | 9 +++- .../@aws-cdk/aws-ecs-patterns/package.json | 9 +++- packages/@aws-cdk/aws-ecs/package.json | 9 +++- .../lib/shared/base-load-balancer.ts | 21 ++++++--- .../lib/shared/base-target-group.ts | 2 +- .../aws-elasticloadbalancingv2/package.json | 9 +++- .../@aws-cdk/aws-events-targets/package.json | 9 +++- packages/@aws-cdk/aws-events/package.json | 9 +++- packages/@aws-cdk/aws-iam/package.json | 9 +++- packages/@aws-cdk/aws-kms/package.json | 9 +++- packages/@aws-cdk/aws-lambda/package.json | 9 +++- packages/@aws-cdk/aws-logs/README.md | 27 +++--------- packages/@aws-cdk/aws-logs/package.json | 9 +++- .../aws-logs/rosetta/default.ts-fixture | 1 + packages/@aws-cdk/aws-rds/package.json | 9 +++- .../aws-route53-patterns/package.json | 9 +++- .../@aws-cdk/aws-route53-targets/README.md | 21 +++++---- .../@aws-cdk/aws-route53-targets/package.json | 9 +++- packages/@aws-cdk/aws-route53/package.json | 9 +++- packages/@aws-cdk/aws-s3/lib/bucket.ts | 44 +++++++++++-------- packages/@aws-cdk/aws-s3/package.json | 9 +++- .../aws-sns-subscriptions/package.json | 9 +++- packages/@aws-cdk/aws-sns/package.json | 9 +++- packages/@aws-cdk/aws-sqs/package.json | 9 +++- packages/@aws-cdk/aws-ssm/package.json | 9 +++- .../lib/athena/get-query-execution.ts | 2 +- .../lib/athena/get-query-results.ts | 4 +- .../lib/athena/start-query-execution.ts | 3 +- .../lib/dynamodb/shared-types.ts | 6 +-- .../lib/evaluate-expression.ts | 2 +- .../lib/eventbridge/put-events.ts | 10 +++-- .../aws-stepfunctions-tasks/package.json | 9 +++- .../aws-stepfunctions/lib/states/wait.ts | 6 +-- .../@aws-cdk/aws-stepfunctions/package.json | 9 +++- packages/@aws-cdk/aws-synthetics/package.json | 9 +++- .../lib/blueprint/stack-deployment.ts | 2 +- packages/@aws-cdk/pipelines/package.json | 9 +++- 57 files changed, 375 insertions(+), 125 deletions(-) diff --git a/packages/@aws-cdk/assertions/package.json b/packages/@aws-cdk/assertions/package.json index 35e2842a2bd0c..1b515143d4d58 100644 --- a/packages/@aws-cdk/assertions/package.json +++ b/packages/@aws-cdk/assertions/package.json @@ -50,7 +50,7 @@ "metadata": { "jsii": { "rosetta": { - "strict": false + "strict": true } } } diff --git a/packages/@aws-cdk/aws-apigateway/package.json b/packages/@aws-cdk/aws-apigateway/package.json index 0901cd7438a7b..d20ad7f17d5f5 100644 --- a/packages/@aws-cdk/aws-apigateway/package.json +++ b/packages/@aws-cdk/aws-apigateway/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-apigatewayv2-authorizers/package.json b/packages/@aws-cdk/aws-apigatewayv2-authorizers/package.json index 67b23ee362f5a..8465cb5e8a9a5 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-authorizers/package.json +++ b/packages/@aws-cdk/aws-apigatewayv2-authorizers/package.json @@ -30,7 +30,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/README.md b/packages/@aws-cdk/aws-apigatewayv2-integrations/README.md index dc29843d00209..d284be9491e99 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/README.md +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/README.md @@ -172,7 +172,7 @@ The following example creates a new header - `header2` - as a copy of `header1` ```ts import { HttpAlbIntegration } from '@aws-cdk/aws-apigatewayv2-integrations'; -declare const lb: elbv2.NetworkLoadBalancer; +declare const lb: elbv2.ApplicationLoadBalancer; const listener = lb.addListener('listener', { port: 80 }); listener.addTargets('target', { port: 80, @@ -182,9 +182,8 @@ const httpEndpoint = new apigwv2.HttpApi(this, 'HttpProxyPrivateApi', { defaultIntegration: new HttpAlbIntegration({ listener, parameterMapping: new apigwv2.ParameterMapping() - .appendHeader('header2', apigwv2.MappingValue.header('header1')) + .appendHeader('header2', apigwv2.MappingValue.requestHeader('header1')) .removeHeader('header1'), - }), }), }); ``` @@ -194,7 +193,7 @@ To add mapping keys and values not yet supported by the CDK, use the `custom()` ```ts import { HttpAlbIntegration } from '@aws-cdk/aws-apigatewayv2-integrations'; -declare const lb: elbv2.NetworkLoadBalancer; +declare const lb: elbv2.ApplicationLoadBalancer; const listener = lb.addListener('listener', { port: 80 }); listener.addTargets('target', { port: 80, @@ -203,9 +202,7 @@ listener.addTargets('target', { const httpEndpoint = new apigwv2.HttpApi(this, 'HttpProxyPrivateApi', { defaultIntegration: new HttpAlbIntegration({ listener, - parameterMapping: new apigwv2.ParameterMapping() - .custom('myKey', 'myValue'), - }), + parameterMapping: new apigwv2.ParameterMapping().custom('myKey', 'myValue'), }), }); ``` @@ -217,7 +214,7 @@ WebSocket integrations connect a route to backend resources. The following integ ### Lambda WebSocket Integration -Lambda integrations enable integrating a WebSocket API route with a Lambda function. When a client connects/disconnects +Lambda integrations enable integrating a WebSocket API route with a Lambda function. When a client connects/disconnects or sends message specific to a route, the API Gateway service forwards the request to the Lambda function The API Gateway service will invoke the lambda function with an event payload of a specific format. diff --git a/packages/@aws-cdk/aws-apigatewayv2-integrations/package.json b/packages/@aws-cdk/aws-apigatewayv2-integrations/package.json index 10cde741e9d26..203793018a92a 100644 --- a/packages/@aws-cdk/aws-apigatewayv2-integrations/package.json +++ b/packages/@aws-cdk/aws-apigatewayv2-integrations/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts index ca5f973a8fa50..7937b331c018a 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/scalable-target.ts @@ -39,7 +39,8 @@ export interface ScalableTargetProps { * * This string consists of the resource type and unique identifier. * - * @example service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH + * Example value: `service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH` + * * @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_RegisterScalableTarget.html */ readonly resourceId: string; @@ -49,7 +50,7 @@ export interface ScalableTargetProps { * * Specify the service namespace, resource type, and scaling property. * - * @example ecs:service:DesiredCount + * Example value: `ecs:service:DesiredCount` * @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_ScalingPolicy.html */ readonly scalableDimension: string; @@ -82,7 +83,8 @@ export class ScalableTarget extends Resource implements IScalableTarget { /** * ID of the Scalable Target * - * @example service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH|ecs:service:DesiredCount|ecs + * Example value: `service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH|ecs:service:DesiredCount|ecs` + * * @attribute */ public readonly scalableTargetId: string; diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts index f7ccaff153ffe..de48ab5fd21e7 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts @@ -88,7 +88,7 @@ export interface BasicTargetTrackingScalingPolicyProps extends BaseTargetTrackin * * Only used for predefined metric ALBRequestCountPerTarget. * - * @example app///targetgroup// + * Example value: `app///targetgroup//` * * @default - No resource label. */ diff --git a/packages/@aws-cdk/aws-applicationautoscaling/package.json b/packages/@aws-cdk/aws-applicationautoscaling/package.json index ca025554d085f..17bfd09967f88 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/package.json +++ b/packages/@aws-cdk/aws-applicationautoscaling/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-appmesh/lib/virtual-service.ts b/packages/@aws-cdk/aws-appmesh/lib/virtual-service.ts index cb561eff19308..a75989bbbe66a 100644 --- a/packages/@aws-cdk/aws-appmesh/lib/virtual-service.ts +++ b/packages/@aws-cdk/aws-appmesh/lib/virtual-service.ts @@ -40,7 +40,7 @@ export interface VirtualServiceProps { * It is recommended this follows the fully-qualified domain name format, * such as "my-service.default.svc.cluster.local". * - * @example service.domain.local + * Example value: `service.domain.local` * @default - A name is automatically generated */ readonly virtualServiceName?: string; diff --git a/packages/@aws-cdk/aws-appmesh/package.json b/packages/@aws-cdk/aws-appmesh/package.json index a7024d16cbc9b..0bf1fc94a030d 100644 --- a/packages/@aws-cdk/aws-appmesh/package.json +++ b/packages/@aws-cdk/aws-appmesh/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-appsync/package.json b/packages/@aws-cdk/aws-appsync/package.json index f36a7ada3d7ec..814bfb98e9600 100644 --- a/packages/@aws-cdk/aws-appsync/package.json +++ b/packages/@aws-cdk/aws-appsync/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-autoscaling/package.json b/packages/@aws-cdk/aws-autoscaling/package.json index 0fd6ce84bf75c..dfdb08ad1ac2b 100644 --- a/packages/@aws-cdk/aws-autoscaling/package.json +++ b/packages/@aws-cdk/aws-autoscaling/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-cloudwatch/package.json b/packages/@aws-cdk/aws-cloudwatch/package.json index 5466e925c6663..b02f9e882b51a 100644 --- a/packages/@aws-cdk/aws-cloudwatch/package.json +++ b/packages/@aws-cdk/aws-cloudwatch/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-codebuild/README.md b/packages/@aws-cdk/aws-codebuild/README.md index 29d06892bc682..4bccbbc68cfa1 100644 --- a/packages/@aws-cdk/aws-codebuild/README.md +++ b/packages/@aws-cdk/aws-codebuild/README.md @@ -243,7 +243,7 @@ new codebuild.Project(this, 'Project', { }), // Enable Docker AND custom caching - cache: codebuild.Cache.local(codebuild.LocalCacheMode.DOCKER_LAYER, codebuild.LocalCacheMode.CUSTOM) + cache: codebuild.Cache.local(codebuild.LocalCacheMode.DOCKER_LAYER, codebuild.LocalCacheMode.CUSTOM), // BuildSpec with a 'cache' section necessary for 'CUSTOM' caching. This can // also come from 'buildspec.yml' in your source. diff --git a/packages/@aws-cdk/aws-codebuild/lib/file-location.ts b/packages/@aws-cdk/aws-codebuild/lib/file-location.ts index eabfd95570b06..b836fc92bc22a 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/file-location.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/file-location.ts @@ -71,7 +71,8 @@ export interface EfsFileSystemLocationProps { /** * A string that specifies the location of the file system, like Amazon EFS. - * @example 'fs-abcd1234.efs.us-west-2.amazonaws.com:/my-efs-mount-directory'. + * + * This value looks like `fs-abcd1234.efs.us-west-2.amazonaws.com:/my-efs-mount-directory`. */ readonly location: string; diff --git a/packages/@aws-cdk/aws-codebuild/package.json b/packages/@aws-cdk/aws-codebuild/package.json index 50ac7d24ef78a..05c5e55339acb 100644 --- a/packages/@aws-cdk/aws-codebuild/package.json +++ b/packages/@aws-cdk/aws-codebuild/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-codepipeline-actions/README.md b/packages/@aws-cdk/aws-codepipeline-actions/README.md index 05860cfe20233..7625ed08bfb8e 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/README.md +++ b/packages/@aws-cdk/aws-codepipeline-actions/README.md @@ -987,7 +987,7 @@ The Lambda Action supports custom user parameters that pipeline will pass to the Lambda function: ```ts -import * as lambda from '@aws-cdk/aws-lambda'; +declare const fn: lambda.Function; const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); const lambdaAction = new codepipeline_actions.LambdaInvokeAction({ diff --git a/packages/@aws-cdk/aws-codepipeline-actions/package.json b/packages/@aws-cdk/aws-codepipeline-actions/package.json index f1624f676dc9c..dc2c146e3ddd7 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/package.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-dynamodb/package.json b/packages/@aws-cdk/aws-dynamodb/package.json index f1fdf012ab0b8..d63167cf3d5de 100644 --- a/packages/@aws-cdk/aws-dynamodb/package.json +++ b/packages/@aws-cdk/aws-dynamodb/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-ec2/package.json b/packages/@aws-cdk/aws-ec2/package.json index f8664e445ec97..44347facefb48 100644 --- a/packages/@aws-cdk/aws-ec2/package.json +++ b/packages/@aws-cdk/aws-ec2/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-ecr/package.json b/packages/@aws-cdk/aws-ecr/package.json index 704de9272f366..c9039866abcc0 100644 --- a/packages/@aws-cdk/aws-ecr/package.json +++ b/packages/@aws-cdk/aws-ecr/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-ecs-patterns/package.json b/packages/@aws-cdk/aws-ecs-patterns/package.json index e399ff853d46b..96a5eccecc75f 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/package.json +++ b/packages/@aws-cdk/aws-ecs-patterns/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-ecs/package.json b/packages/@aws-cdk/aws-ecs/package.json index 7cdcc0b9b0934..dc6c57ffe9285 100644 --- a/packages/@aws-cdk/aws-ecs/package.json +++ b/packages/@aws-cdk/aws-ecs/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts index bcf51d4d81a78..85ae9d143f0e2 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts @@ -52,16 +52,18 @@ export interface ILoadBalancerV2 extends IResource { /** * The canonical hosted zone ID of this load balancer * + * Example value: `Z2P70J7EXAMPLE` + * * @attribute - * @example Z2P70J7EXAMPLE */ readonly loadBalancerCanonicalHostedZoneId: string; /** * The DNS name of this load balancer * + * Example value: `my-load-balancer-424835706.us-west-2.elb.amazonaws.com` + * * @attribute - * @example my-load-balancer-424835706.us-west-2.elb.amazonaws.com */ readonly loadBalancerDnsName: string; } @@ -141,40 +143,45 @@ export abstract class BaseLoadBalancer extends Resource { /** * The canonical hosted zone ID of this load balancer * + * Example value: `Z2P70J7EXAMPLE` + * * @attribute - * @example Z2P70J7EXAMPLE */ public readonly loadBalancerCanonicalHostedZoneId: string; /** * The DNS name of this load balancer * + * Example value: `my-load-balancer-424835706.us-west-2.elb.amazonaws.com` + * * @attribute - * @example my-load-balancer-424835706.us-west-2.elb.amazonaws.com */ public readonly loadBalancerDnsName: string; /** * The full name of this load balancer * + * Example value: `app/my-load-balancer/50dc6c495c0c9188` + * * @attribute - * @example app/my-load-balancer/50dc6c495c0c9188 */ public readonly loadBalancerFullName: string; /** * The name of this load balancer * + * Example value: `my-load-balancer` + * * @attribute - * @example my-load-balancer */ public readonly loadBalancerName: string; /** * The ARN of this load balancer * + * Example value: `arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/50dc6c495c0c9188` + * * @attribute - * @example arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/50dc6c495c0c9188 */ public readonly loadBalancerArn: string; diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts index 29a9cb707556e..69d925bc933e9 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts @@ -186,7 +186,7 @@ export abstract class TargetGroupBase extends CoreConstruct implements ITargetGr * This identifier is emitted as a dimensions of the metrics of this target * group. * - * @example app/my-load-balancer/123456789 + * Example value: `app/my-load-balancer/123456789` */ public abstract readonly firstLoadBalancerFullName: string; diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json index f7f5546a41b05..d2a9b352b4163 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-events-targets/package.json b/packages/@aws-cdk/aws-events-targets/package.json index e937e5c40ac4b..c59f621de9d2b 100644 --- a/packages/@aws-cdk/aws-events-targets/package.json +++ b/packages/@aws-cdk/aws-events-targets/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-events/package.json b/packages/@aws-cdk/aws-events/package.json index fb10cafd5c60b..7159bada50ee2 100644 --- a/packages/@aws-cdk/aws-events/package.json +++ b/packages/@aws-cdk/aws-events/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-iam/package.json b/packages/@aws-cdk/aws-iam/package.json index 7fda5ccefad3d..e448eaf64cec0 100644 --- a/packages/@aws-cdk/aws-iam/package.json +++ b/packages/@aws-cdk/aws-iam/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-kms/package.json b/packages/@aws-cdk/aws-kms/package.json index 66a47be7c03da..e38c467b3b4f7 100644 --- a/packages/@aws-cdk/aws-kms/package.json +++ b/packages/@aws-cdk/aws-kms/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-lambda/package.json b/packages/@aws-cdk/aws-lambda/package.json index b966e65d20c98..6afda74f971fc 100644 --- a/packages/@aws-cdk/aws-lambda/package.json +++ b/packages/@aws-cdk/aws-lambda/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-logs/README.md b/packages/@aws-cdk/aws-logs/README.md index 631bc382365e0..804b5c56c4eb3 100644 --- a/packages/@aws-cdk/aws-logs/README.md +++ b/packages/@aws-cdk/aws-logs/README.md @@ -51,14 +51,11 @@ publish their log group to a specific region, such as AWS Chatbot creating a log ## Resource Policy CloudWatch Resource Policies allow other AWS services or IAM Principals to put log events into the log groups. -A resource policy is automatically created when `addToResourcePolicy` is called on the LogGroup for the first time. - -`ResourcePolicy` can also be created manually. +A resource policy is automatically created when `addToResourcePolicy` is called on the LogGroup for the first time: ```ts -const logGroup = new LogGroup(this, 'LogGroup'); -const resourcePolicy = new ResourcePolicy(this, 'ResourcePolicy'); -resourcePolicy.document.addStatements(new iam.PolicyStatement({ +const logGroup = new logs.LogGroup(this, 'LogGroup'); +logGroup.addToResourcePolicy(new iam.PolicyStatement({ actions: ['logs:CreateLogStream', 'logs:PutLogEvents'], principals: [new iam.ServicePrincipal('es.amazonaws.com')], resources: [logGroup.logGroupArn], @@ -68,22 +65,8 @@ resourcePolicy.document.addStatements(new iam.PolicyStatement({ Or more conveniently, write permissions to the log group can be granted as follows which gives same result as in the above example. ```ts -const logGroup = new LogGroup(this, 'LogGroup'); -logGroup.grantWrite(iam.ServicePrincipal('es.amazonaws.com')); -``` - -Optionally name and policy statements can also be passed on `ResourcePolicy` construction. - -```ts -const policyStatement = new new iam.PolicyStatement({ - resources: ["*"], - actions: ['logs:PutLogEvents'], - principals: [new iam.ArnPrincipal('arn:aws:iam::123456789012:user/user-name')], -}); -const resourcePolicy = new ResourcePolicy(this, 'ResourcePolicy', { - policyName: 'myResourcePolicy', - policyStatements: [policyStatement], -}); +const logGroup = new logs.LogGroup(this, 'LogGroup'); +logGroup.grantWrite(new iam.ServicePrincipal('es.amazonaws.com')); ``` ## Encrypting Log Groups diff --git a/packages/@aws-cdk/aws-logs/package.json b/packages/@aws-cdk/aws-logs/package.json index 5c1d328a6f6bb..9169d12ac72fe 100644 --- a/packages/@aws-cdk/aws-logs/package.json +++ b/packages/@aws-cdk/aws-logs/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-logs/rosetta/default.ts-fixture b/packages/@aws-cdk/aws-logs/rosetta/default.ts-fixture index 27c338ce30a32..6c34f60674f19 100644 --- a/packages/@aws-cdk/aws-logs/rosetta/default.ts-fixture +++ b/packages/@aws-cdk/aws-logs/rosetta/default.ts-fixture @@ -2,6 +2,7 @@ import { Construct } from 'constructs'; import { Stack } from '@aws-cdk/core'; import * as logs from '@aws-cdk/aws-logs'; +import * as iam from '@aws-cdk/aws-iam'; import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as lambda from '@aws-cdk/aws-lambda'; diff --git a/packages/@aws-cdk/aws-rds/package.json b/packages/@aws-cdk/aws-rds/package.json index b1bf50b500a40..a9c66bfb3f081 100644 --- a/packages/@aws-cdk/aws-rds/package.json +++ b/packages/@aws-cdk/aws-rds/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-route53-patterns/package.json b/packages/@aws-cdk/aws-route53-patterns/package.json index 7f3d2c396ede3..d8c12460322a6 100644 --- a/packages/@aws-cdk/aws-route53-patterns/package.json +++ b/packages/@aws-cdk/aws-route53-patterns/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-route53-targets/README.md b/packages/@aws-cdk/aws-route53-targets/README.md index 9d53630628ddd..73269abb6d6ed 100644 --- a/packages/@aws-cdk/aws-route53-targets/README.md +++ b/packages/@aws-cdk/aws-route53-targets/README.md @@ -58,7 +58,7 @@ This library contains Route53 Alias Record targets for: ```ts import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; - + declare const zone: route53.HostedZone; declare const lb: elbv2.ApplicationLoadBalancer; @@ -73,7 +73,7 @@ This library contains Route53 Alias Record targets for: ```ts import * as elb from '@aws-cdk/aws-elasticloadbalancing'; - + declare const zone: route53.HostedZone; declare const lb: elb.LoadBalancer; @@ -129,7 +129,7 @@ See [the Developer Guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGu ```ts import * as s3 from '@aws-cdk/aws-s3'; - + const recordName = 'www'; const domainName = 'example.com'; @@ -176,11 +176,14 @@ See [the Developer Guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGu **Important:** Only supports Elastic Beanstalk environments created after 2016 that have a regional endpoint. - ```ts - new route53.ARecord(this, 'AliasRecord', { - zone, - target: route53.RecordTarget.fromAlias(new alias.ElasticBeanstalkEnvironmentEndpointTarget(ebsEnvironmentUrl)), - }); - ``` +```ts +declare const zone: route53.HostedZone; +declare const ebsEnvironmentUrl: string; + +new route53.ARecord(this, 'AliasRecord', { + zone, + target: route53.RecordTarget.fromAlias(new targets.ElasticBeanstalkEnvironmentEndpointTarget(ebsEnvironmentUrl)), +}); +``` See the documentation of `@aws-cdk/aws-route53` for more information. diff --git a/packages/@aws-cdk/aws-route53-targets/package.json b/packages/@aws-cdk/aws-route53-targets/package.json index cd191bfc3173e..a65e4a0372abf 100644 --- a/packages/@aws-cdk/aws-route53-targets/package.json +++ b/packages/@aws-cdk/aws-route53-targets/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-route53/package.json b/packages/@aws-cdk/aws-route53/package.json index 35c3abefcc477..aabd22c95363b 100644 --- a/packages/@aws-cdk/aws-route53/package.json +++ b/packages/@aws-cdk/aws-route53/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-s3/lib/bucket.ts b/packages/@aws-cdk/aws-s3/lib/bucket.ts index 157aa31a3ed5f..ce8dafd5a69aa 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket.ts @@ -105,9 +105,10 @@ export interface IBucket extends IResource { /** * The https URL of an S3 object. For example: - * @example https://s3.us-west-1.amazonaws.com/onlybucket - * @example https://s3.us-west-1.amazonaws.com/bucket/key - * @example https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey + * + * - `https://s3.us-west-1.amazonaws.com/onlybucket` + * - `https://s3.us-west-1.amazonaws.com/bucket/key` + * - `https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey` * @param key The S3 key of the object. If not specified, the URL of the * bucket is returned. * @returns an ObjectS3Url token @@ -117,10 +118,11 @@ export interface IBucket extends IResource { /** * The virtual hosted-style URL of an S3 object. Specify `regional: false` at * the options for non-regional URL. For example: - * @example https://only-bucket.s3.us-west-1.amazonaws.com - * @example https://bucket.s3.us-west-1.amazonaws.com/key - * @example https://bucket.s3.amazonaws.com/key - * @example https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey + * + * - `https://only-bucket.s3.us-west-1.amazonaws.com` + * - `https://bucket.s3.us-west-1.amazonaws.com/key` + * - `https://bucket.s3.amazonaws.com/key` + * - `https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey` * @param key The S3 key of the object. If not specified, the URL of the * bucket is returned. * @param options Options for generating URL. @@ -130,8 +132,8 @@ export interface IBucket extends IResource { /** * The S3 URL of an S3 object. For example: - * @example s3://onlybucket - * @example s3://bucket/key + * - `s3://onlybucket` + * - `s3://bucket/key` * @param key The S3 key of the object. If not specified, the S3 URL of the * bucket is returned. * @returns an ObjectS3Url token @@ -603,9 +605,11 @@ export abstract class BucketBase extends Resource implements IBucket { /** * The https URL of an S3 object. Specify `regional: false` at the options * for non-regional URLs. For example: - * @example https://s3.us-west-1.amazonaws.com/onlybucket - * @example https://s3.us-west-1.amazonaws.com/bucket/key - * @example https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey + * + * - `https://s3.us-west-1.amazonaws.com/onlybucket` + * - `https://s3.us-west-1.amazonaws.com/bucket/key` + * - `https://s3.cn-north-1.amazonaws.com.cn/china-bucket/mykey` + * * @param key The S3 key of the object. If not specified, the URL of the * bucket is returned. * @returns an ObjectS3Url token @@ -622,10 +626,12 @@ export abstract class BucketBase extends Resource implements IBucket { /** * The virtual hosted-style URL of an S3 object. Specify `regional: false` at * the options for non-regional URL. For example: - * @example https://only-bucket.s3.us-west-1.amazonaws.com - * @example https://bucket.s3.us-west-1.amazonaws.com/key - * @example https://bucket.s3.amazonaws.com/key - * @example https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey + * + * - `https://only-bucket.s3.us-west-1.amazonaws.com` + * - `https://bucket.s3.us-west-1.amazonaws.com/key` + * - `https://bucket.s3.amazonaws.com/key` + * - `https://china-bucket.s3.cn-north-1.amazonaws.com.cn/mykey` + * * @param key The S3 key of the object. If not specified, the URL of the * bucket is returned. * @param options Options for generating URL. @@ -642,8 +648,10 @@ export abstract class BucketBase extends Resource implements IBucket { /** * The S3 URL of an S3 object. For example: - * @example s3://onlybucket - * @example s3://bucket/key + * + * - `s3://onlybucket` + * - `s3://bucket/key` + * * @param key The S3 key of the object. If not specified, the S3 URL of the * bucket is returned. * @returns an ObjectS3Url token diff --git a/packages/@aws-cdk/aws-s3/package.json b/packages/@aws-cdk/aws-s3/package.json index e3feff8d0fe6c..f8153d202545d 100644 --- a/packages/@aws-cdk/aws-s3/package.json +++ b/packages/@aws-cdk/aws-s3/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-sns-subscriptions/package.json b/packages/@aws-cdk/aws-sns-subscriptions/package.json index ba1cfe852a8aa..6f8a4f5a2b9cc 100644 --- a/packages/@aws-cdk/aws-sns-subscriptions/package.json +++ b/packages/@aws-cdk/aws-sns-subscriptions/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-sns/package.json b/packages/@aws-cdk/aws-sns/package.json index 2250bcb72ba1b..b5f4039c63744 100644 --- a/packages/@aws-cdk/aws-sns/package.json +++ b/packages/@aws-cdk/aws-sns/package.json @@ -31,7 +31,14 @@ "excludeTypescript": [ "examples" ], - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-sqs/package.json b/packages/@aws-cdk/aws-sqs/package.json index 874d8caf10d72..af74b209b3931 100644 --- a/packages/@aws-cdk/aws-sqs/package.json +++ b/packages/@aws-cdk/aws-sqs/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-ssm/package.json b/packages/@aws-cdk/aws-ssm/package.json index 55ad40f1dfd04..cdf17bfb69c1c 100644 --- a/packages/@aws-cdk/aws-ssm/package.json +++ b/packages/@aws-cdk/aws-ssm/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-execution.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-execution.ts index 6a9eaab73eb4b..23e4079b77921 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-execution.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-execution.ts @@ -10,7 +10,7 @@ export interface AthenaGetQueryExecutionProps extends sfn.TaskStateBaseProps { /** * Query that will be retrieved * - * @example 'adfsaf-23trf23-f23rt23' + * Example value: `adfsaf-23trf23-f23rt23` */ readonly queryExecutionId: string; } diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-results.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-results.ts index 07ec38efa97e1..700b43fc2a599 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-results.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/get-query-results.ts @@ -10,8 +10,8 @@ export interface AthenaGetQueryResultsProps extends sfn.TaskStateBaseProps { /** * Query that will be retrieved * - * @example 'adfsaf-23trf23-f23rt23' - */ + * Example value: `adfsaf-23trf23-f23rt23` + */ readonly queryExecutionId: string; /** diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/start-query-execution.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/start-query-execution.ts index f23bd66fc5591..ba3f68b95abb1 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/start-query-execution.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/athena/start-query-execution.ts @@ -212,8 +212,9 @@ export interface ResultConfiguration { /** * S3 path of query results * + * Example value: `s3://query-results-bucket/folder/` + * * @default - Query Result Location set in Athena settings for this workgroup - * @example s3://query-results-bucket/folder/ */ readonly outputLocation?: s3.Location; diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts index 0921cf3b2521a..bed1b16a86f70 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/dynamodb/shared-types.ts @@ -119,10 +119,10 @@ export class DynamoProjectionExpression { export class DynamoAttributeValue { /** * Sets an attribute of type String. For example: "S": "Hello" - * Strings may be literal values or as JsonPath. + * Strings may be literal values or as JsonPath. Example values: * - * @example `DynamoAttributeValue.fromString('someValue') - * @example `DynamoAttributeValue.fromString(JsonPath.stringAt('$.bar')) + * - `DynamoAttributeValue.fromString('someValue')` + * - `DynamoAttributeValue.fromString(JsonPath.stringAt('$.bar'))` */ public static fromString(value: string) { return new DynamoAttributeValue({ S: value }); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/evaluate-expression.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/evaluate-expression.ts index 7fb010119373b..5b90ce066c70d 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/evaluate-expression.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/evaluate-expression.ts @@ -12,7 +12,7 @@ export interface EvaluateExpressionProps extends sfn.TaskStateBaseProps { /** * The expression to evaluate. The expression may contain state paths. * - * @example '$.a + $.b' + * Example value: `'$.a + $.b'` */ readonly expression: string; diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/eventbridge/put-events.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/eventbridge/put-events.ts index 457bdfa6d0011..2c08c1ac41966 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/eventbridge/put-events.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/eventbridge/put-events.ts @@ -16,9 +16,10 @@ export interface EventBridgePutEventsEntry { * * Can either be provided as an object or as a JSON-serialized string * @example - * sfn.TaskInput.fromText('{"instance-id": "i-1234567890abcdef0", "state": "terminated"}') - * sfn.TaskInput.fromObject({ Message: 'Hello from Step Functions' }) - * sfn.TaskInput.fromJsonPathAt('$.EventDetail') + * + * sfn.TaskInput.fromText('{"instance-id": "i-1234567890abcdef0", "state": "terminated"}'); + * sfn.TaskInput.fromObject({ Message: 'Hello from Step Functions' }); + * sfn.TaskInput.fromJsonPathAt('$.EventDetail'); */ readonly detail: sfn.TaskInput; @@ -40,7 +41,8 @@ export interface EventBridgePutEventsEntry { /** * The service or application that caused this event to be generated * - * @example 'com.example.service' + * Example value: `com.example.service` + * * @see https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html */ readonly source: string; diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json index 2ff381bd3f9d0..daa88936b437c 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-stepfunctions/lib/states/wait.ts b/packages/@aws-cdk/aws-stepfunctions/lib/states/wait.ts index 8386b3ce334b1..f0fd18d22c090 100644 --- a/packages/@aws-cdk/aws-stepfunctions/lib/states/wait.ts +++ b/packages/@aws-cdk/aws-stepfunctions/lib/states/wait.ts @@ -18,21 +18,21 @@ export class WaitTime { /** * Wait until the given ISO8601 timestamp * - * @example 2016-03-14T01:59:00Z + * Example value: `2016-03-14T01:59:00Z` */ public static timestamp(timestamp: string) { return new WaitTime({ Timestamp: timestamp }); } /** * Wait for a number of seconds stored in the state object. * - * @example $.waitSeconds + * Example value: `$.waitSeconds` */ public static secondsPath(path: string) { return new WaitTime({ SecondsPath: path }); } /** * Wait until a timestamp found in the state object. * - * @example $.waitTimestamp + * Example value: `$.waitTimestamp` */ public static timestampPath(path: string) { return new WaitTime({ TimestampPath: path }); } diff --git a/packages/@aws-cdk/aws-stepfunctions/package.json b/packages/@aws-cdk/aws-stepfunctions/package.json index 701d06a238562..40cea293bc09f 100644 --- a/packages/@aws-cdk/aws-stepfunctions/package.json +++ b/packages/@aws-cdk/aws-stepfunctions/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/aws-synthetics/package.json b/packages/@aws-cdk/aws-synthetics/package.json index 76e2fa4520b1e..745f97fc21261 100644 --- a/packages/@aws-cdk/aws-synthetics/package.json +++ b/packages/@aws-cdk/aws-synthetics/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/pipelines/lib/blueprint/stack-deployment.ts b/packages/@aws-cdk/pipelines/lib/blueprint/stack-deployment.ts index 488551f4eefb7..b3e88cbfe026e 100644 --- a/packages/@aws-cdk/pipelines/lib/blueprint/stack-deployment.ts +++ b/packages/@aws-cdk/pipelines/lib/blueprint/stack-deployment.ts @@ -183,7 +183,7 @@ export class StackDeployment { * This is `undefined` if the stack template is not published. Use the * `DefaultStackSynthesizer` to ensure it is. * - * @example https://bucket.s3.amazonaws.com/object/key + * Example value: `https://bucket.s3.amazonaws.com/object/key` */ public readonly templateUrl?: string; diff --git a/packages/@aws-cdk/pipelines/package.json b/packages/@aws-cdk/pipelines/package.json index b3d838723ed75..ec3538c30b4c9 100644 --- a/packages/@aws-cdk/pipelines/package.json +++ b/packages/@aws-cdk/pipelines/package.json @@ -126,7 +126,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "awscdkio": { "announce": false From 69372962ee79c75ff5ff9cdd15026563d79fcb33 Mon Sep 17 00:00:00 2001 From: Tatsuya Yamamoto Date: Wed, 10 Nov 2021 04:51:26 +0900 Subject: [PATCH 08/18] chore(iot-actions): simplify cloudwatch-logs-action test (#17385) This PR refactor the test that I committed earlier based on the above comment. - https://github.com/aws/aws-cdk/pull/17307#discussion_r742181458 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../cloudwatch-logs-action.test.ts | 52 +++++-------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts b/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts index 4e25f43367c31..3b6ecd2d57fbc 100644 --- a/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts +++ b/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts @@ -11,7 +11,7 @@ test('Default cloudwatch logs action', () => { const topicRule = new iot.TopicRule(stack, 'MyTopicRule', { sql: iot.IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id FROM 'device/+/data'"), }); - const logGroup = new logs.LogGroup(stack, 'MyLogGroup'); + const logGroup = logs.LogGroup.fromLogGroupArn(stack, 'my-log-group', 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group'); // WHEN topicRule.addAction( @@ -24,7 +24,7 @@ test('Default cloudwatch logs action', () => { Actions: [ { CloudwatchLogs: { - LogGroupName: { Ref: 'MyLogGroup5C0DAD85' }, + LogGroupName: 'my-log-group', RoleArn: { 'Fn::GetAtt': [ 'MyTopicRuleTopicRuleActionRoleCE2D05DA', @@ -58,16 +58,12 @@ test('Default cloudwatch logs action', () => { { Action: ['logs:CreateLogStream', 'logs:PutLogEvents'], Effect: 'Allow', - Resource: { - 'Fn::GetAtt': ['MyLogGroup5C0DAD85', 'Arn'], - }, + Resource: 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group:*', }, { Action: 'logs:DescribeLogStreams', Effect: 'Allow', - Resource: { - 'Fn::GetAtt': ['MyLogGroup5C0DAD85', 'Arn'], - }, + Resource: 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group:*', }, ], Version: '2012-10-17', @@ -85,7 +81,7 @@ test('can set role', () => { const topicRule = new iot.TopicRule(stack, 'MyTopicRule', { sql: iot.IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id FROM 'device/+/data'"), }); - const logGroup = new logs.LogGroup(stack, 'MyLogGroup'); + const logGroup = logs.LogGroup.fromLogGroupArn(stack, 'my-log-group', 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group'); const role = iam.Role.fromRoleArn(stack, 'MyRole', 'arn:aws:iam::123456789012:role/ForTest'); // WHEN @@ -101,48 +97,26 @@ test('can set role', () => { Actions: [ { CloudwatchLogs: { - LogGroupName: { Ref: 'MyLogGroup5C0DAD85' }, + LogGroupName: 'my-log-group', RoleArn: 'arn:aws:iam::123456789012:role/ForTest', }, }, ], }, }); -}); - -test('The specified role is added a policy needed for sending data to logs', () => { - // GIVEN - const stack = new cdk.Stack(); - const topicRule = new iot.TopicRule(stack, 'MyTopicRule', { - sql: iot.IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id FROM 'device/+/data'"), - }); - const logGroup = new logs.LogGroup(stack, 'MyLogGroup'); - const role = iam.Role.fromRoleArn(stack, 'MyRole', 'arn:aws:iam::123456789012:role/ForTest'); - - // WHEN - topicRule.addAction( - new actions.CloudWatchLogsAction(logGroup, { - role, - }), - ); - // THEN Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { PolicyDocument: { Statement: [ { Action: ['logs:CreateLogStream', 'logs:PutLogEvents'], Effect: 'Allow', - Resource: { - 'Fn::GetAtt': ['MyLogGroup5C0DAD85', 'Arn'], - }, + Resource: 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group:*', }, { Action: 'logs:DescribeLogStreams', Effect: 'Allow', - Resource: { - 'Fn::GetAtt': ['MyLogGroup5C0DAD85', 'Arn'], - }, + Resource: 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group:*', }, ], Version: '2012-10-17', @@ -152,16 +126,14 @@ test('The specified role is added a policy needed for sending data to logs', () }); }); - test('When multiple actions are omitted role property, the actions use same one role', () => { - // GIVEN // GIVEN const stack = new cdk.Stack(); const topicRule = new iot.TopicRule(stack, 'MyTopicRule', { sql: iot.IotSql.fromStringAsVer20160323("SELECT topic(2) as device_id FROM 'device/+/data'"), }); - const logGroup1 = new logs.LogGroup(stack, 'MyLogGroup1'); - const logGroup2 = new logs.LogGroup(stack, 'MyLogGroup2'); + const logGroup1 = logs.LogGroup.fromLogGroupArn(stack, 'my-log-group1', 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group1'); + const logGroup2 = logs.LogGroup.fromLogGroupArn(stack, 'my-log-group2', 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group2'); // WHEN topicRule.addAction(new actions.CloudWatchLogsAction(logGroup1)); @@ -173,7 +145,7 @@ test('When multiple actions are omitted role property, the actions use same one Actions: [ { CloudwatchLogs: { - LogGroupName: { Ref: 'MyLogGroup14A6E382A' }, + LogGroupName: 'my-log-group1', RoleArn: { 'Fn::GetAtt': [ 'MyTopicRuleTopicRuleActionRoleCE2D05DA', @@ -184,7 +156,7 @@ test('When multiple actions are omitted role property, the actions use same one }, { CloudwatchLogs: { - LogGroupName: { Ref: 'MyLogGroup279D6359D' }, + LogGroupName: 'my-log-group2', RoleArn: { 'Fn::GetAtt': [ 'MyTopicRuleTopicRuleActionRoleCE2D05DA', From a39146840a10472c8afee71bf1a1cfc3cacb5f72 Mon Sep 17 00:00:00 2001 From: Ryan Parker Date: Tue, 9 Nov 2021 12:30:07 -0800 Subject: [PATCH 09/18] fix(aws-logs): include new `policy.ts` exports in `index.ts` exports (#17403) ## Summary This PR modifies the aws-logs `index.ts` file to also forward the exports from `policy.ts` ([a newly created file](https://github.com/aws/aws-cdk/pull/17015) that implements the `ResourcePolicy` class). Fixes: https://github.com/aws/aws-cdk/issues/17402 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-logs/lib/index.ts | 1 + packages/@aws-cdk/aws-logs/lib/policy.ts | 12 +++-- .../@aws-cdk/aws-logs/test/policy.test.ts | 52 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 packages/@aws-cdk/aws-logs/test/policy.test.ts diff --git a/packages/@aws-cdk/aws-logs/lib/index.ts b/packages/@aws-cdk/aws-logs/lib/index.ts index 5054715ffe52b..416a9c9a9b257 100644 --- a/packages/@aws-cdk/aws-logs/lib/index.ts +++ b/packages/@aws-cdk/aws-logs/lib/index.ts @@ -5,6 +5,7 @@ export * from './metric-filter'; export * from './pattern'; export * from './subscription-filter'; export * from './log-retention'; +export * from './policy'; // AWS::Logs CloudFormation Resources: export * from './logs.generated'; diff --git a/packages/@aws-cdk/aws-logs/lib/policy.ts b/packages/@aws-cdk/aws-logs/lib/policy.ts index 974f517d48b25..de3af44f1ae2f 100644 --- a/packages/@aws-cdk/aws-logs/lib/policy.ts +++ b/packages/@aws-cdk/aws-logs/lib/policy.ts @@ -11,7 +11,7 @@ export interface ResourcePolicyProps { * Name of the log group resource policy * @default - Uses a unique id based on the construct path */ - readonly policyName?: string; + readonly resourcePolicyName?: string; /** * Initial statements to add to the resource policy @@ -31,15 +31,19 @@ export class ResourcePolicy extends Resource { public readonly document = new PolicyDocument(); constructor(scope: Construct, id: string, props?: ResourcePolicyProps) { - super(scope, id); - new CfnResourcePolicy(this, 'Resource', { + super(scope, id, { + physicalName: props?.resourcePolicyName, + }); + + new CfnResourcePolicy(this, 'ResourcePolicy', { policyName: Lazy.string({ - produce: () => props?.policyName ?? Names.uniqueId(this), + produce: () => props?.resourcePolicyName ?? Names.uniqueId(this), }), policyDocument: Lazy.string({ produce: () => JSON.stringify(this.document), }), }); + if (props?.policyStatements) { this.document.addStatements(...props.policyStatements); } diff --git a/packages/@aws-cdk/aws-logs/test/policy.test.ts b/packages/@aws-cdk/aws-logs/test/policy.test.ts new file mode 100644 index 0000000000000..4b2684a9957b1 --- /dev/null +++ b/packages/@aws-cdk/aws-logs/test/policy.test.ts @@ -0,0 +1,52 @@ +import '@aws-cdk/assert-internal/jest'; +import { PolicyStatement, ServicePrincipal } from '@aws-cdk/aws-iam'; +import { Stack } from '@aws-cdk/core'; +import { LogGroup, ResourcePolicy } from '../lib'; + +describe('resource policy', () => { + test('ResourcePolicy is added to stack, when .addToResourcePolicy() is provided a valid Statement', () => { + // GIVEN + const stack = new Stack(); + const logGroup = new LogGroup(stack, 'LogGroup'); + + // WHEN + logGroup.addToResourcePolicy(new PolicyStatement({ + actions: ['logs:CreateLogStream'], + resources: ['*'], + })); + + // THEN + expect(stack).toHaveResource('AWS::Logs::ResourcePolicy', { + PolicyName: 'LogGroupPolicy643B329C', + PolicyDocument: JSON.stringify({ + Statement: [ + { + Action: 'logs:CreateLogStream', + Effect: 'Allow', + Resource: '*', + }, + ], + Version: '2012-10-17', + }), + }); + }); + + test('ResourcePolicy is added to stack, when created manually/directly', () => { + // GIVEN + const stack = new Stack(); + const logGroup = new LogGroup(stack, 'LogGroup'); + + // WHEN + const resourcePolicy = new ResourcePolicy(stack, 'ResourcePolicy'); + resourcePolicy.document.addStatements(new PolicyStatement({ + actions: ['logs:CreateLogStream', 'logs:PutLogEvents'], + principals: [new ServicePrincipal('es.amazonaws.com')], + resources: [logGroup.logGroupArn], + })); + + // THEN + expect(stack).toHaveResource('AWS::Logs::ResourcePolicy', { + PolicyName: 'ResourcePolicy', + }); + }); +}); From ec5b102e560e241b21c63773817114fc44f7898a Mon Sep 17 00:00:00 2001 From: Ryan Parker Date: Tue, 9 Nov 2021 13:10:16 -0800 Subject: [PATCH 10/18] feat(lambda): singleton function: access runtime, log group and configure layers and environment (#17372) ## Summary This PR adds the following to `SingletonFunction`: - `runtime` - property - `logGroup` - property - `addLayers()` - method - `addEnvironment()` - method Fixes: https://github.com/aws/aws-cdk/issues/17369 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-lambda/lib/singleton-lambda.ts | 48 +++++++++- .../aws-lambda/test/singleton-lambda.test.ts | 87 +++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-lambda/lib/singleton-lambda.ts b/packages/@aws-cdk/aws-lambda/lib/singleton-lambda.ts index 431b9bf6a71d9..c096730b1e8eb 100644 --- a/packages/@aws-cdk/aws-lambda/lib/singleton-lambda.ts +++ b/packages/@aws-cdk/aws-lambda/lib/singleton-lambda.ts @@ -1,11 +1,14 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; +import * as logs from '@aws-cdk/aws-logs'; import * as cdk from '@aws-cdk/core'; import { Construct } from 'constructs'; -import { Function as LambdaFunction, FunctionProps } from './function'; +import { Function as LambdaFunction, FunctionProps, EnvironmentOptions } from './function'; import { FunctionBase } from './function-base'; import { Version } from './lambda-version'; +import { ILayerVersion } from './layers'; import { Permission } from './permission'; +import { Runtime } from './runtime'; /** * Properties for a newly created singleton Lambda @@ -47,6 +50,12 @@ export class SingletonFunction extends FunctionBase { public readonly functionArn: string; public readonly role?: iam.IRole; public readonly permissionsNode: cdk.ConstructNode; + + /** + * The runtime environment for the Lambda function. + */ + public readonly runtime: Runtime; + protected readonly canCreatePermissions: boolean; private lambdaFunction: LambdaFunction; @@ -59,6 +68,7 @@ export class SingletonFunction extends FunctionBase { this.functionArn = this.lambdaFunction.functionArn; this.functionName = this.lambdaFunction.functionName; this.role = this.lambdaFunction.role; + this.runtime = this.lambdaFunction.runtime; this.grantPrincipal = this.lambdaFunction.grantPrincipal; this.canCreatePermissions = true; // Doesn't matter, addPermission is overriden anyway @@ -78,6 +88,20 @@ export class SingletonFunction extends FunctionBase { return this.lambdaFunction.connections; } + /** + * The LogGroup where the Lambda function's logs are made available. + * + * If either `logRetention` is set or this property is called, a CloudFormation custom resource is added to the stack that + * pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention + * period (never expire, by default). + * + * Further, if the log group already exists and the `logRetention` is not set, the custom resource will reset the log retention + * to never expire even if it was configured with a different value. + */ + public get logGroup(): logs.ILogGroup { + return this.lambdaFunction.logGroup; + } + /** * Returns a `lambda.Version` which represents the current version of this * singleton Lambda function. A new version will be created every time the @@ -90,6 +114,28 @@ export class SingletonFunction extends FunctionBase { return this.lambdaFunction.currentVersion; } + /** + * Adds an environment variable to this Lambda function. + * If this is a ref to a Lambda function, this operation results in a no-op. + * @param key The environment variable key. + * @param value The environment variable's value. + * @param options Environment variable options. + */ + public addEnvironment(key: string, value: string, options?: EnvironmentOptions) { + return this.lambdaFunction.addEnvironment(key, value, options); + } + + /** + * Adds one or more Lambda Layers to this Lambda function. + * + * @param layers the layers to be added. + * + * @throws if there are already 5 layers on this function, or the layer is incompatible with this function's runtime. + */ + public addLayers(...layers: ILayerVersion[]) { + return this.lambdaFunction.addLayers(...layers); + } + public addPermission(name: string, permission: Permission) { return this.lambdaFunction.addPermission(name, permission); } diff --git a/packages/@aws-cdk/aws-lambda/test/singleton-lambda.test.ts b/packages/@aws-cdk/aws-lambda/test/singleton-lambda.test.ts index 3bf78253d5ed6..4200b7a18a6e5 100644 --- a/packages/@aws-cdk/aws-lambda/test/singleton-lambda.test.ts +++ b/packages/@aws-cdk/aws-lambda/test/singleton-lambda.test.ts @@ -2,6 +2,7 @@ import '@aws-cdk/assert-internal/jest'; import { ResourcePart } from '@aws-cdk/assert-internal'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; +import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; import * as lambda from '../lib'; @@ -109,6 +110,57 @@ describe('singleton lambda', () => { }, ResourcePart.CompleteDefinition); }); + test('Environment is added to Lambda, when .addEnvironment() is provided one key pair', () => { + // GIVEN + const stack = new cdk.Stack(); + const singleton = new lambda.SingletonFunction(stack, 'Singleton', { + uuid: '84c0de93-353f-4217-9b0b-45b6c993251a', + code: new lambda.InlineCode('def hello(): pass'), + runtime: lambda.Runtime.PYTHON_2_7, + handler: 'index.hello', + timeout: cdk.Duration.minutes(5), + }); + + // WHEN + singleton.addEnvironment('KEY', 'value'); + + // THEN + expect(stack).toHaveResource('AWS::Lambda::Function', { + Environment: { + Variables: { + KEY: 'value', + }, + }, + }); + }); + + test('Layer is added to Lambda, when .addLayers() is provided a valid layer', () => { + // GIVEN + const stack = new cdk.Stack(); + const singleton = new lambda.SingletonFunction(stack, 'Singleton', { + uuid: '84c0de93-353f-4217-9b0b-45b6c993251a', + code: new lambda.InlineCode('def hello(): pass'), + runtime: lambda.Runtime.PYTHON_2_7, + handler: 'index.hello', + timeout: cdk.Duration.minutes(5), + }); + const bucket = new s3.Bucket(stack, 'Bucket'); + const layer = new lambda.LayerVersion(stack, 'myLayer', { + code: new lambda.S3Code(bucket, 'ObjectKey'), + compatibleRuntimes: [lambda.Runtime.PYTHON_2_7], + }); + + // WHEN + singleton.addLayers(layer); + + // THEN + expect(stack).toHaveResource('AWS::Lambda::Function', { + Layers: [{ + Ref: 'myLayerBA1B098A', + }], + }); + }); + test('grantInvoke works correctly', () => { // GIVEN const stack = new cdk.Stack(); @@ -154,6 +206,41 @@ describe('singleton lambda', () => { .toThrow(/contains environment variables .* and is not compatible with Lambda@Edge/); }); + test('logGroup is correctly returned', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const singleton = new lambda.SingletonFunction(stack, 'Singleton', { + uuid: '84c0de93-353f-4217-9b0b-45b6c993251a', + code: new lambda.InlineCode('def hello(): pass'), + runtime: lambda.Runtime.PYTHON_2_7, + handler: 'index.hello', + timeout: cdk.Duration.minutes(5), + }); + + // THEN + expect(singleton.logGroup.logGroupName).toBeDefined(); + expect(singleton.logGroup.logGroupArn).toBeDefined(); + }); + + test('runtime is correctly returned', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const singleton = new lambda.SingletonFunction(stack, 'Singleton', { + uuid: '84c0de93-353f-4217-9b0b-45b6c993251a', + code: new lambda.InlineCode('def hello(): pass'), + runtime: lambda.Runtime.PYTHON_2_7, + handler: 'index.hello', + timeout: cdk.Duration.minutes(5), + }); + + // THEN + expect(singleton.runtime).toStrictEqual(lambda.Runtime.PYTHON_2_7); + }); + test('current version of a singleton function', () => { // GIVEN const stack = new cdk.Stack(); From 9c77e941252ad16a2744577b6333ee5054302a30 Mon Sep 17 00:00:00 2001 From: Ryan Parker Date: Tue, 9 Nov 2021 13:49:17 -0800 Subject: [PATCH 11/18] fix(aws-codebuild): add @aws-cdk/asserts to package deps (#17435) ## Summary This PR adds `@aws-cdk/asserts` to the dependency list of `aws-codebuild`. Fixes: https://github.com/aws/aws-cdk/issues/17416 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-codebuild/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@aws-cdk/aws-codebuild/package.json b/packages/@aws-cdk/aws-codebuild/package.json index 05c5e55339acb..3d1609d9665b4 100644 --- a/packages/@aws-cdk/aws-codebuild/package.json +++ b/packages/@aws-cdk/aws-codebuild/package.json @@ -95,6 +95,7 @@ "jest": "^27.3.1" }, "dependencies": { + "@aws-cdk/assets": "0.0.0", "@aws-cdk/aws-cloudwatch": "0.0.0", "@aws-cdk/aws-codecommit": "0.0.0", "@aws-cdk/aws-codestarnotifications": "0.0.0", From b307b6996ed13b1f2dedeb41d29409183becb969 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 9 Nov 2021 21:28:14 -0500 Subject: [PATCH 12/18] feat(servicecatalog): support local launch role name in launch role constraint (#17371) Service Catalog Launch Role Constraints support the ability to reference a role by name. Many customers use Service Catalog in a hub and spoke model, sharing portfolios to many accounts. This feature allows the launch role to be account agnostic, as the arn is tied to a single account. As a result, a launch role constraint can be created once with the role name and shared rather than sharing the portfolio and creating a launch role constraint in each spoke account. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* Co-authored-by: Aidan Crank --- .../@aws-cdk/aws-servicecatalog/README.md | 30 ++++- .../aws-servicecatalog/lib/portfolio.ts | 42 ++++++- .../lib/private/association-manager.ts | 67 +++++++---- .../lib/private/validation.ts | 12 ++ .../aws-servicecatalog/test/portfolio.test.ts | 106 +++++++++++++++++- 5 files changed, 234 insertions(+), 23 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalog/README.md b/packages/@aws-cdk/aws-servicecatalog/README.md index 2d7694d3e84b6..bbc82e13e2d7b 100644 --- a/packages/@aws-cdk/aws-servicecatalog/README.md +++ b/packages/@aws-cdk/aws-servicecatalog/README.md @@ -307,8 +307,36 @@ const launchRole = new iam.Role(this, 'LaunchRole', { portfolio.setLaunchRole(product, launchRole); ``` +You can also set the launch role using just the name of a role which is locally deployed in end user accounts. +This is useful for when roles and users are separately managed outside of the CDK. +The given role must exist in both the account that creates the launch role constraint, +as well as in any end user accounts that wish to provision a product with the launch role. + +You can do this by passing in the role with an explicitly set name: + +```ts fixture=portfolio-product +import * as iam from '@aws-cdk/aws-iam'; + +const launchRole = new iam.Role(this, 'LaunchRole', { + roleName: 'MyRole', + assumedBy: new iam.ServicePrincipal('servicecatalog.amazonaws.com'), +}); + +portfolio.setLocalLaunchRole(product, launchRole); +``` + +Or you can simply pass in a role name and CDK will create a role with that name that trusts service catalog in the account: + +```ts fixture=portfolio-product +import * as iam from '@aws-cdk/aws-iam'; + +const roleName = 'MyRole'; + +const launchRole: iam.IRole = portfolio.setLocalLaunchRoleName(product, roleName); +``` + See [Launch Constraint](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/constraints-launch.html) documentation -to understand permissions roles need. +to understand the permissions roles need. ### Deploy with StackSets diff --git a/packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts b/packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts index 3056a48e19777..36d267d022519 100644 --- a/packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts +++ b/packages/@aws-cdk/aws-servicecatalog/lib/portfolio.ts @@ -112,6 +112,9 @@ export interface IPortfolio extends cdk.IResource { /** * Force users to assume a certain role when launching a product. + * This sets the launch role using the role arn which is tied to the account this role exists in. + * This is useful if you will be provisioning products from the account where this role exists. + * If you intend to share the portfolio across accounts, use a local launch role. * * @param product A service catalog product. * @param launchRole The IAM role a user must assume when provisioning the product. @@ -120,7 +123,30 @@ export interface IPortfolio extends cdk.IResource { setLaunchRole(product: IProduct, launchRole: iam.IRole, options?: CommonConstraintOptions): void; /** - * Configure deployment options using AWS Cloudformaiton StackSets + * Force users to assume a certain role when launching a product. + * The role will be referenced by name in the local account instead of a static role arn. + * A role with this name will automatically be created and assumable by Service Catalog in this account. + * This is useful when sharing the portfolio with multiple accounts. + * + * @param product A service catalog product. + * @param launchRoleName The name of the IAM role a user must assume when provisioning the product. A role with this name must exist in the account where the portolio is created and the accounts it is shared with. + * @param options options for the constraint. + */ + setLocalLaunchRoleName(product: IProduct, launchRoleName: string, options?: CommonConstraintOptions): iam.IRole; + + /** + * Force users to assume a certain role when launching a product. + * The role name will be referenced by in the local account and must be set explicitly. + * This is useful when sharing the portfolio with multiple accounts. + * + * @param product A service catalog product. + * @param launchRole The IAM role a user must assume when provisioning the product. A role with this name must exist in the account where the portolio is created and the accounts it is shared with. The role name must be set explicitly. + * @param options options for the constraint. + */ + setLocalLaunchRole(product: IProduct, launchRole: iam.IRole, options?: CommonConstraintOptions): void; + + /** + * Configure deployment options using AWS Cloudformation StackSets * * @param product A service catalog product. * @param options Configuration options for the constraint. @@ -179,6 +205,20 @@ abstract class PortfolioBase extends cdk.Resource implements IPortfolio { AssociationManager.setLaunchRole(this, product, launchRole, options); } + public setLocalLaunchRoleName(product: IProduct, launchRoleName: string, options: CommonConstraintOptions = {}): iam.IRole { + const launchRole: iam.IRole = new iam.Role(this, `LaunchRole${launchRoleName}`, { + roleName: launchRoleName, + assumedBy: new iam.ServicePrincipal('servicecatalog.amazonaws.com'), + }); + AssociationManager.setLocalLaunchRoleName(this, product, launchRole.roleName, options); + return launchRole; + } + + public setLocalLaunchRole(product: IProduct, launchRole: iam.IRole, options: CommonConstraintOptions = {}): void { + InputValidator.validateRoleNameSetForLocalLaunchRole(launchRole); + AssociationManager.setLocalLaunchRoleName(this, product, launchRole.roleName, options); + } + public deployWithStackSets(product: IProduct, options: StackSetsConstraintOptions) { AssociationManager.deployWithStackSets(this, product, options); } diff --git a/packages/@aws-cdk/aws-servicecatalog/lib/private/association-manager.ts b/packages/@aws-cdk/aws-servicecatalog/lib/private/association-manager.ts index bf5a68a8e70d3..b92fb2483ad54 100644 --- a/packages/@aws-cdk/aws-servicecatalog/lib/private/association-manager.ts +++ b/packages/@aws-cdk/aws-servicecatalog/lib/private/association-manager.ts @@ -100,27 +100,15 @@ export class AssociationManager { } public static setLaunchRole(portfolio: IPortfolio, product: IProduct, launchRole: iam.IRole, options: CommonConstraintOptions): void { - const association = this.associateProductWithPortfolio(portfolio, product, options); - // Check if a stackset deployment constraint has already been configured. - if (portfolio.node.tryFindChild(this.stackSetConstraintLogicalId(association.associationKey))) { - throw new Error(`Cannot set launch role when a StackSet rule is already defined for association ${this.prettyPrintAssociation(portfolio, product)}`); - } - - const constructId = this.launchRoleConstraintLogicalId(association.associationKey); - if (!portfolio.node.tryFindChild(constructId)) { - const constraint = new CfnLaunchRoleConstraint(portfolio as unknown as cdk.Resource, constructId, { - acceptLanguage: options.messageLanguage, - description: options.description, - portfolioId: portfolio.portfolioId, - productId: product.productId, - roleArn: launchRole.roleArn, - }); + this.setLaunchRoleConstraint(portfolio, product, options, { + roleArn: launchRole.roleArn, + }); + } - // Add dependsOn to force proper order in deployment. - constraint.addDependsOn(association.cfnPortfolioProductAssociation); - } else { - throw new Error(`Cannot set multiple launch roles for association ${this.prettyPrintAssociation(portfolio, product)}`); - } + public static setLocalLaunchRoleName(portfolio: IPortfolio, product: IProduct, launchRoleName: string, options: CommonConstraintOptions): void { + this.setLaunchRoleConstraint(portfolio, product, options, { + localRoleName: launchRoleName, + }); } public static deployWithStackSets(portfolio: IPortfolio, product: IProduct, options: StackSetsConstraintOptions) { @@ -179,6 +167,34 @@ export class AssociationManager { }; } + private static setLaunchRoleConstraint( + portfolio: IPortfolio, product: IProduct, options: CommonConstraintOptions, + roleOptions: LaunchRoleConstraintRoleOptions, + ): void { + const association = this.associateProductWithPortfolio(portfolio, product, options); + // Check if a stackset deployment constraint has already been configured. + if (portfolio.node.tryFindChild(this.stackSetConstraintLogicalId(association.associationKey))) { + throw new Error(`Cannot set launch role when a StackSet rule is already defined for association ${this.prettyPrintAssociation(portfolio, product)}`); + } + + const constructId = this.launchRoleConstraintLogicalId(association.associationKey); + if (!portfolio.node.tryFindChild(constructId)) { + const constraint = new CfnLaunchRoleConstraint(portfolio as unknown as cdk.Resource, constructId, { + acceptLanguage: options.messageLanguage, + description: options.description, + portfolioId: portfolio.portfolioId, + productId: product.productId, + roleArn: roleOptions.roleArn, + localRoleName: roleOptions.localRoleName, + }); + + // Add dependsOn to force proper order in deployment. + constraint.addDependsOn(association.cfnPortfolioProductAssociation); + } else { + throw new Error(`Cannot set multiple launch roles for association ${this.prettyPrintAssociation(portfolio, product)}`); + } + } + private static stackSetConstraintLogicalId(associationKey: string): string { return `StackSetConstraint${associationKey}`; } @@ -213,3 +229,14 @@ export class AssociationManager { }; } +interface LaunchRoleArnOption { + readonly roleArn: string, + readonly localRoleName?: never, +} + +interface LaunchRoleNameOption { + readonly localRoleName: string, + readonly roleArn?: never, +} + +type LaunchRoleConstraintRoleOptions = LaunchRoleArnOption | LaunchRoleNameOption; diff --git a/packages/@aws-cdk/aws-servicecatalog/lib/private/validation.ts b/packages/@aws-cdk/aws-servicecatalog/lib/private/validation.ts index 3beaa42552eff..cd70006fbe373 100644 --- a/packages/@aws-cdk/aws-servicecatalog/lib/private/validation.ts +++ b/packages/@aws-cdk/aws-servicecatalog/lib/private/validation.ts @@ -1,3 +1,4 @@ +import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; /** @@ -36,6 +37,17 @@ export class InputValidator { this.validateRegex(resourceName, inputName, /^[\w\d.%+\-]+@[a-z\d.\-]+\.[a-z]{2,4}$/i, inputString); } + /** + * Validates that a role being used as a local launch role has the role name set + */ + public static validateRoleNameSetForLocalLaunchRole(role: iam.IRole): void { + if (role.node.defaultChild) { + if (cdk.Token.isUnresolved((role.node.defaultChild as iam.CfnRole).roleName)) { + throw new Error(`Role ${role.node.id} used for Local Launch Role must have roleName explicitly set`); + } + } + } + private static truncateString(string: string, maxLength: number): string { if (string.length > maxLength) { return string.substring(0, maxLength) + '[truncated]'; diff --git a/packages/@aws-cdk/aws-servicecatalog/test/portfolio.test.ts b/packages/@aws-cdk/aws-servicecatalog/test/portfolio.test.ts index 8f9a27a96a940..43a283c157f80 100644 --- a/packages/@aws-cdk/aws-servicecatalog/test/portfolio.test.ts +++ b/packages/@aws-cdk/aws-servicecatalog/test/portfolio.test.ts @@ -568,6 +568,7 @@ describe('portfolio associations and product constraints', () => { assumedBy: new iam.AccountRootPrincipal(), }); launchRole = new iam.Role(stack, 'LaunchRole', { + roleName: 'LaunchRole', assumedBy: new iam.ServicePrincipal('servicecatalog.amazonaws.com'), }); }), @@ -591,6 +592,59 @@ describe('portfolio associations and product constraints', () => { }); }), + test('set a launch role constraint using local role name', () => { + portfolio.addProduct(product); + + portfolio.setLocalLaunchRoleName(product, 'LocalLaunchRole', { + description: 'set launch role description', + messageLanguage: servicecatalog.MessageLanguage.EN, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalog::LaunchRoleConstraint', { + PortfolioId: { Ref: 'MyPortfolio59CCA9C9' }, + ProductId: { Ref: 'MyProduct49A3C587' }, + Description: 'set launch role description', + AcceptLanguage: 'en', + LocalRoleName: { Ref: 'MyPortfolioLaunchRoleLocalLaunchRoleB2E6E22A' }, + }); + }), + + test('set a launch role constraint using local role', () => { + portfolio.addProduct(product); + + portfolio.setLocalLaunchRole(product, launchRole, { + description: 'set launch role description', + messageLanguage: servicecatalog.MessageLanguage.EN, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalog::LaunchRoleConstraint', { + PortfolioId: { Ref: 'MyPortfolio59CCA9C9' }, + ProductId: { Ref: 'MyProduct49A3C587' }, + Description: 'set launch role description', + AcceptLanguage: 'en', + LocalRoleName: { Ref: 'LaunchRole2CFB2E44' }, + }); + }), + + test('set a launch role constraint using imported local role', () => { + portfolio.addProduct(product); + + const importedLaunchRole = iam.Role.fromRoleArn(portfolio.stack, 'ImportedLaunchRole', 'arn:aws:iam::123456789012:role/ImportedLaunchRole'); + + portfolio.setLocalLaunchRole(product, importedLaunchRole, { + description: 'set launch role description', + messageLanguage: servicecatalog.MessageLanguage.EN, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalog::LaunchRoleConstraint', { + PortfolioId: { Ref: 'MyPortfolio59CCA9C9' }, + ProductId: { Ref: 'MyProduct49A3C587' }, + Description: 'set launch role description', + AcceptLanguage: 'en', + LocalRoleName: 'ImportedLaunchRole', + }); + }), + test('set launch role constraint still adds without explicit association', () => { portfolio.setLaunchRole(product, launchRole); @@ -606,7 +660,57 @@ describe('portfolio associations and product constraints', () => { expect(() => { portfolio.setLaunchRole(product, otherLaunchRole); - }).toThrowError(/Cannot set multiple launch roles for association/); + }).toThrow(/Cannot set multiple launch roles for association/); + }), + + test('local launch role must have roleName explicitly set', () => { + const otherLaunchRole = new iam.Role(stack, 'otherLaunchRole', { + assumedBy: new iam.ServicePrincipal('servicecatalog.amazonaws.com'), + }); + + expect(() => { + portfolio.setLocalLaunchRole(product, otherLaunchRole); + }).toThrow(/Role otherLaunchRole used for Local Launch Role must have roleName explicitly set/); + }), + + test('fails to add multiple set launch roles - local launch role first', () => { + portfolio.setLocalLaunchRoleName(product, 'LaunchRole'); + + expect(() => { + portfolio.setLaunchRole(product, launchRole); + }).toThrow(/Cannot set multiple launch roles for association/); + }), + + test('fails to add multiple set local launch roles - local launch role first', () => { + portfolio.setLocalLaunchRoleName(product, 'LaunchRole'); + + expect(() => { + portfolio.setLocalLaunchRole(product, launchRole); + }).toThrow(/Cannot set multiple launch roles for association/); + }), + + test('fails to add multiple set local launch roles - local launch role name first', () => { + portfolio.setLocalLaunchRole(product, launchRole); + + expect(() => { + portfolio.setLocalLaunchRoleName(product, 'LaunchRole'); + }).toThrow(/Cannot set multiple launch roles for association/); + }), + + test('fails to add multiple set launch roles - local launch role second', () => { + portfolio.setLaunchRole(product, launchRole); + + expect(() => { + portfolio.setLocalLaunchRole(product, launchRole); + }).toThrow(/Cannot set multiple launch roles for association/); + }), + + test('fails to add multiple set launch roles - local launch role second', () => { + portfolio.setLaunchRole(product, launchRole); + + expect(() => { + portfolio.setLocalLaunchRoleName(product, 'LaunchRole'); + }).toThrow(/Cannot set multiple launch roles for association/); }), test('fails to set launch role if stackset rule is already defined', () => { From 6aec58d564d390b7600f469203fe0326b55e1672 Mon Sep 17 00:00:00 2001 From: kaizen3031593 <36202692+kaizen3031593@users.noreply.github.com> Date: Wed, 10 Nov 2021 04:20:47 -0500 Subject: [PATCH 13/18] chore(monocdk): ignore rosetta folder (#17439) `rosetta` folder is erroneously tracked by git. This PR adds `rosetta` to `.gitignore` and removes the folder from the repo. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/monocdk/.gitignore | 4 +- ...README-custom-resource-provider.ts-fixture | 18 ------- .../rosetta/basic-constructs.ts-fixture | 22 --------- .../rosetta/basic-portfolio.ts-fixture | 16 ------ packages/monocdk/rosetta/basic.ts-fixture | 12 ----- .../monocdk/rosetta/client-vpn.ts-fixture | 17 ------- packages/monocdk/rosetta/cluster.ts-fixture | 20 -------- packages/monocdk/rosetta/default.ts-fixture | 29 ----------- packages/monocdk/rosetta/init.ts-fixture | 3 -- .../rosetta/migrate-opensearch.ts-fixture | 16 ------ .../rosetta/portfolio-product.ts-fixture | 28 ----------- .../monocdk/rosetta/with-bucket.ts-fixture | 13 ----- .../monocdk/rosetta/with-channel.ts-fixture | 15 ------ .../monocdk/rosetta/with-cluster.ts-fixture | 19 ------- .../rosetta/with-delivery-stream.ts-fixture | 12 ----- .../rosetta/with-destination.ts-fixture | 12 ----- .../with-filesystem-instance.ts-fixture | 30 ------------ .../rosetta/with-lambda-trigger.ts-fixture | 26 ---------- .../monocdk/rosetta/with-objects.ts-fixture | 49 ------------------- packages/monocdk/rosetta/with-plan.ts-fixture | 16 ------ packages/monocdk/rosetta/with-vpc.ts-fixture | 13 ----- .../withRepoAndKinesisStream.ts-fixture | 23 --------- .../rosetta/withRepoAndSqsQueue.ts-fixture | 23 --------- .../rosetta/withRepoAndTopic.ts-fixture | 23 --------- 24 files changed, 3 insertions(+), 456 deletions(-) delete mode 100644 packages/monocdk/rosetta/README-custom-resource-provider.ts-fixture delete mode 100644 packages/monocdk/rosetta/basic-constructs.ts-fixture delete mode 100644 packages/monocdk/rosetta/basic-portfolio.ts-fixture delete mode 100644 packages/monocdk/rosetta/basic.ts-fixture delete mode 100644 packages/monocdk/rosetta/client-vpn.ts-fixture delete mode 100644 packages/monocdk/rosetta/cluster.ts-fixture delete mode 100644 packages/monocdk/rosetta/default.ts-fixture delete mode 100644 packages/monocdk/rosetta/init.ts-fixture delete mode 100644 packages/monocdk/rosetta/migrate-opensearch.ts-fixture delete mode 100644 packages/monocdk/rosetta/portfolio-product.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-bucket.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-channel.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-cluster.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-delivery-stream.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-destination.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-filesystem-instance.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-lambda-trigger.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-objects.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-plan.ts-fixture delete mode 100644 packages/monocdk/rosetta/with-vpc.ts-fixture delete mode 100644 packages/monocdk/rosetta/withRepoAndKinesisStream.ts-fixture delete mode 100644 packages/monocdk/rosetta/withRepoAndSqsQueue.ts-fixture delete mode 100644 packages/monocdk/rosetta/withRepoAndTopic.ts-fixture diff --git a/packages/monocdk/.gitignore b/packages/monocdk/.gitignore index 129f2f8e0bc37..e03d056122b0f 100644 --- a/packages/monocdk/.gitignore +++ b/packages/monocdk/.gitignore @@ -16,4 +16,6 @@ dist # Ignore barrel import entry points /*.ts -junit.xml \ No newline at end of file +junit.xml + +rosetta \ No newline at end of file diff --git a/packages/monocdk/rosetta/README-custom-resource-provider.ts-fixture b/packages/monocdk/rosetta/README-custom-resource-provider.ts-fixture deleted file mode 100644 index ae4b1befd4b20..0000000000000 --- a/packages/monocdk/rosetta/README-custom-resource-provider.ts-fixture +++ /dev/null @@ -1,18 +0,0 @@ -import { CfnOutput, Construct, Token } from '@aws-cdk/core'; - -declare interface SumProps { - readonly lhs: number; - readonly rhs: number; -} -declare class Sum extends Construct { - public readonly result: number; - constructor(scope: Construct, id: string, props: SumProps); -} - -class fixture$construct extends Construct { - public constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/monocdk/rosetta/basic-constructs.ts-fixture b/packages/monocdk/rosetta/basic-constructs.ts-fixture deleted file mode 100644 index 19ffd84abf486..0000000000000 --- a/packages/monocdk/rosetta/basic-constructs.ts-fixture +++ /dev/null @@ -1,22 +0,0 @@ -// Fixture with packages imported, but nothing else -import * as cdk from '@aws-cdk/core'; -import * as appreg from '@aws-cdk/aws-servicecatalogappregistry'; - -class Fixture extends cdk.Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const application = new appreg.Application(stack, 'MyApplication', { - applicationName: 'MyApplication', - }); - - const attributeGroup = new appreg.AttributeGroup(stack, 'MyAttributeGroup', { - attributeGroupName: 'testAttributeGroup', - attributes: { - key: 'value', - }, - }); - - /// here - } -} diff --git a/packages/monocdk/rosetta/basic-portfolio.ts-fixture b/packages/monocdk/rosetta/basic-portfolio.ts-fixture deleted file mode 100644 index 3029872ea1f0d..0000000000000 --- a/packages/monocdk/rosetta/basic-portfolio.ts-fixture +++ /dev/null @@ -1,16 +0,0 @@ -// Fixture with packages imported, but nothing else -import * as cdk from '@aws-cdk/core'; -import * as servicecatalog from '@aws-cdk/aws-servicecatalog'; - -class Fixture extends cdk.Stack { - constructor(scope: cdk.Construct, id: string) { - super(scope, id); - - const portfolio = new servicecatalog.Portfolio(this, "MyFirstPortfolio", { - displayName: "MyFirstPortfolio", - providerName: "MyTeam", - }); - - /// here - } -} diff --git a/packages/monocdk/rosetta/basic.ts-fixture b/packages/monocdk/rosetta/basic.ts-fixture deleted file mode 100644 index 0cc6d1104d521..0000000000000 --- a/packages/monocdk/rosetta/basic.ts-fixture +++ /dev/null @@ -1,12 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Construct } from 'constructs'; -import { Stack, Duration } from '@aws-cdk/core'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} - diff --git a/packages/monocdk/rosetta/client-vpn.ts-fixture b/packages/monocdk/rosetta/client-vpn.ts-fixture deleted file mode 100644 index 34c83a31ced35..0000000000000 --- a/packages/monocdk/rosetta/client-vpn.ts-fixture +++ /dev/null @@ -1,17 +0,0 @@ -// Fixture with packages imported and a VPC created -import { Construct, Stack } from '@aws-cdk/core'; -import iam = require('@aws-cdk/aws-iam'); -import ec2 = require('@aws-cdk/aws-ec2'); - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const vpc = new ec2.Vpc(this, 'VPC'); - const samlProvider = new iam.SamlProvider(this, 'Provider', { - metadataDocument: iam.SamlMetadataDocument.fromXml('xml'), - }) - - /// here - } -} diff --git a/packages/monocdk/rosetta/cluster.ts-fixture b/packages/monocdk/rosetta/cluster.ts-fixture deleted file mode 100644 index 82d98ca3e381e..0000000000000 --- a/packages/monocdk/rosetta/cluster.ts-fixture +++ /dev/null @@ -1,20 +0,0 @@ -// Fixture with cluster already created -import { Construct, SecretValue, Stack } from '@aws-cdk/core'; -import { Vpc } from '@aws-cdk/aws-ec2'; -import { Cluster, Table, TableAction, User } from '@aws-cdk/aws-redshift'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const vpc = new Vpc(this, 'Vpc'); - const cluster = new Cluster(this, 'Cluster', { - vpc, - masterUser: { - masterUsername: 'admin', - }, - }); - - /// here - } -} diff --git a/packages/monocdk/rosetta/default.ts-fixture b/packages/monocdk/rosetta/default.ts-fixture deleted file mode 100644 index 61a973840f007..0000000000000 --- a/packages/monocdk/rosetta/default.ts-fixture +++ /dev/null @@ -1,29 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Construct, CfnOutput, Stage, Stack, StackProps, StageProps } from '@aws-cdk/core'; -import cdk = require('@aws-cdk/core'); -import codepipeline = require('@aws-cdk/aws-codepipeline'); -import cpactions = require('@aws-cdk/aws-codepipeline-actions'); -import codebuild = require('@aws-cdk/aws-codebuild'); -import codecommit = require('@aws-cdk/aws-codecommit'); -import dynamodb = require('@aws-cdk/aws-dynamodb'); -import ecr = require('@aws-cdk/aws-ecr'); -import ec2 = require('@aws-cdk/aws-ec2'); -import iam = require('@aws-cdk/aws-iam'); -import pipelines = require('@aws-cdk/pipelines'); -import secretsmanager = require('@aws-cdk/aws-secretsmanager'); -import sns = require('@aws-cdk/aws-sns'); -import subscriptions = require('@aws-cdk/aws-sns-subscriptions'); -import s3 = require('@aws-cdk/aws-s3'); - -class MyApplicationStage extends Stage { - constructor(scope: Construct, id: string, props?: StageProps) { - super(scope, id, props); - } -} - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - /// here - } -} diff --git a/packages/monocdk/rosetta/init.ts-fixture b/packages/monocdk/rosetta/init.ts-fixture deleted file mode 100644 index ce18625a2744b..0000000000000 --- a/packages/monocdk/rosetta/init.ts-fixture +++ /dev/null @@ -1,3 +0,0 @@ -import { Template } from '@aws-cdk/assertions'; - -/// here \ No newline at end of file diff --git a/packages/monocdk/rosetta/migrate-opensearch.ts-fixture b/packages/monocdk/rosetta/migrate-opensearch.ts-fixture deleted file mode 100644 index bb93c1d40f369..0000000000000 --- a/packages/monocdk/rosetta/migrate-opensearch.ts-fixture +++ /dev/null @@ -1,16 +0,0 @@ -import * as cdk from '@aws-cdk/core'; -import * as es from '@aws-cdk/aws-elasticsearch'; -import * as iam from '@aws-cdk/aws-iam'; -import * as opensearch from '@aws-cdk/aws-opensearchservice'; - -declare const role: iam.IRole; -declare const elasticsearchVersion: es.ElasticsearchVersion; -declare const openSearchVersion: opensearch.EngineVersion; - -class Fixture extends cdk.Construct { - constructor(scope: cdk.Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/monocdk/rosetta/portfolio-product.ts-fixture b/packages/monocdk/rosetta/portfolio-product.ts-fixture deleted file mode 100644 index 20a1db30bf3ee..0000000000000 --- a/packages/monocdk/rosetta/portfolio-product.ts-fixture +++ /dev/null @@ -1,28 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Construct, Stack } from '@aws-cdk/core'; -import * as servicecatalog from '@aws-cdk/aws-servicecatalog'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const portfolio = new servicecatalog.Portfolio(this, "MyFirstPortfolio", { - displayName: "MyFirstPortfolio", - providerName: "MyTeam", - }); - - const product = new servicecatalog.CloudFormationProduct(this, 'MyFirstProduct', { - productName: "My Product", - owner: "Product Owner", - productVersions: [ - { - productVersionName: "v1", - cloudFormationTemplate: servicecatalog.CloudFormationTemplate.fromUrl( - 'https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/services/ServiceCatalog/Product.yaml'), - }, - ] - }); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-bucket.ts-fixture b/packages/monocdk/rosetta/with-bucket.ts-fixture deleted file mode 100644 index d0851cff49639..0000000000000 --- a/packages/monocdk/rosetta/with-bucket.ts-fixture +++ /dev/null @@ -1,13 +0,0 @@ -// Fixture with a bucket already created -import { Construct, Stack } from '@aws-cdk/core'; -import { DeliveryStream, DestinationBindOptions, DestinationConfig, IDestination } from '@aws-cdk/aws-kinesisfirehose'; -import * as s3 from '@aws-cdk/aws-s3'; -declare const bucket: s3.Bucket; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-channel.ts-fixture b/packages/monocdk/rosetta/with-channel.ts-fixture deleted file mode 100644 index 44da118b81afa..0000000000000 --- a/packages/monocdk/rosetta/with-channel.ts-fixture +++ /dev/null @@ -1,15 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Duration, Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as ivs from '@aws-cdk/aws-ivs'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const myChannelArn = 'arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh'; - const myChannel = ivs.Channel.fromChannelArn(this, 'Channel', myChannelArn); - - /// here - } -} \ No newline at end of file diff --git a/packages/monocdk/rosetta/with-cluster.ts-fixture b/packages/monocdk/rosetta/with-cluster.ts-fixture deleted file mode 100644 index c638d8b4d04fa..0000000000000 --- a/packages/monocdk/rosetta/with-cluster.ts-fixture +++ /dev/null @@ -1,19 +0,0 @@ -import { Duration, Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as ec2 from '@aws-cdk/aws-ec2'; -import * as neptune from '@aws-cdk/aws-neptune'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2 }); - - const cluster = new neptune.DatabaseCluster(this, 'Database', { - vpc, - instanceType: neptune.InstanceType.R5_LARGE, - }); - - /// here - } -} \ No newline at end of file diff --git a/packages/monocdk/rosetta/with-delivery-stream.ts-fixture b/packages/monocdk/rosetta/with-delivery-stream.ts-fixture deleted file mode 100644 index c7b75b20d2c1b..0000000000000 --- a/packages/monocdk/rosetta/with-delivery-stream.ts-fixture +++ /dev/null @@ -1,12 +0,0 @@ -// Fixture with a delivery stream already created -import { Construct, Stack } from '@aws-cdk/core'; -import { DeliveryStream, DestinationBindOptions, DestinationConfig, IDestination } from '@aws-cdk/aws-kinesisfirehose'; -declare const deliveryStream: DeliveryStream; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-destination.ts-fixture b/packages/monocdk/rosetta/with-destination.ts-fixture deleted file mode 100644 index 37d78bf7a43d3..0000000000000 --- a/packages/monocdk/rosetta/with-destination.ts-fixture +++ /dev/null @@ -1,12 +0,0 @@ -// Fixture with a destination already created -import { Construct, Stack } from '@aws-cdk/core'; -import { DeliveryStream, DestinationBindOptions, DestinationConfig, IDestination } from '@aws-cdk/aws-kinesisfirehose'; -declare const destination: IDestination; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-filesystem-instance.ts-fixture b/packages/monocdk/rosetta/with-filesystem-instance.ts-fixture deleted file mode 100644 index 092b572afa726..0000000000000 --- a/packages/monocdk/rosetta/with-filesystem-instance.ts-fixture +++ /dev/null @@ -1,30 +0,0 @@ -// Fixture with file system and an EC2 instance created in a VPC -import { Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as efs from '@aws-cdk/aws-efs'; -import * as ec2 from '@aws-cdk/aws-ec2'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const vpc = new ec2.Vpc(this, 'VPC'); - - const fileSystem = new efs.FileSystem(this, 'FileSystem', { - vpc, - }); - - const instance = new ec2.Instance(this, 'instance', { - instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.LARGE), - machineImage: new ec2.AmazonLinuxImage({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2 - }), - vpc, - vpcSubnets: { - subnetType: ec2.SubnetType.PUBLIC, - } - }); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-lambda-trigger.ts-fixture b/packages/monocdk/rosetta/with-lambda-trigger.ts-fixture deleted file mode 100644 index de9aa90eedfc2..0000000000000 --- a/packages/monocdk/rosetta/with-lambda-trigger.ts-fixture +++ /dev/null @@ -1,26 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as cognito from '@aws-cdk/aws-cognito'; -import * as iam from '@aws-cdk/aws-iam'; -import * as lambda from '@aws-cdk/aws-lambda'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const postAuthFn = new lambda.Function(this, 'postAuthFn', { - code: lambda.Code.fromInline('post authentication'), - runtime: lambda.Runtime.NODEJS_12_X, - handler: 'index.handler', - }); - - const userpool = new cognito.UserPool(this, 'myuserpool', { - lambdaTriggers: { - postAuthentication: postAuthFn, - }, - }); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-objects.ts-fixture b/packages/monocdk/rosetta/with-objects.ts-fixture deleted file mode 100644 index 1251aad728423..0000000000000 --- a/packages/monocdk/rosetta/with-objects.ts-fixture +++ /dev/null @@ -1,49 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Construct, Stack } from '@aws-cdk/core'; -import appsync = require('@aws-cdk/aws-appsync'); -const pluralize = require('pluralize'); - -const args = { - after: appsync.GraphqlType.string(), - first: appsync.GraphqlType.int(), - before: appsync.GraphqlType.string(), - last: appsync.GraphqlType.int(), -}; - -const Node = new appsync.InterfaceType('Node', { - definition: { id: appsync.GraphqlType.string() } -}); - -const FilmNode = new appsync.ObjectType('FilmNode', { - interfaceTypes: [Node], - definition: { filmName: appsync.GraphqlType.string() } -}); - -function generateEdgeAndConnection(base: appsync.ObjectType) { - const edge = new appsync.ObjectType(`${base.name}Edge`, { - definition: { node: base.attribute(), cursor: appsync.GraphqlType.string() } - }); - const connection = new appsync.ObjectType(`${base.name}Connection`, { - definition: { - edges: edge.attribute({ isList: true }), - [pluralize(base.name)]: base.attribute({ isList: true }), - totalCount: appsync.GraphqlType.int(), - } - }); - return { edge: edge, connection: connection }; -} - -const demo = new appsync.ObjectType('Demo', { - definition: { - id: appsync.GraphqlType.string({ isRequired: true }), - version: appsync.GraphqlType.string({ isRequired: true }), - }, -}); - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-plan.ts-fixture b/packages/monocdk/rosetta/with-plan.ts-fixture deleted file mode 100644 index 8dbfd6ac72c89..0000000000000 --- a/packages/monocdk/rosetta/with-plan.ts-fixture +++ /dev/null @@ -1,16 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Duration, RemovalPolicy, Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; -import * as backup from '@aws-cdk/aws-backup'; -import * as dynamodb from '@aws-cdk/aws-dynamodb'; -import * as events from '@aws-cdk/aws-events'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const plan = backup.BackupPlan.dailyWeeklyMonthly5YearRetention(this, 'Plan'); - - /// here - } -} diff --git a/packages/monocdk/rosetta/with-vpc.ts-fixture b/packages/monocdk/rosetta/with-vpc.ts-fixture deleted file mode 100644 index dd8e539f8cf9f..0000000000000 --- a/packages/monocdk/rosetta/with-vpc.ts-fixture +++ /dev/null @@ -1,13 +0,0 @@ -// Fixture with packages imported and a VPC created -import { Construct, Stack } from '@aws-cdk/core'; -import ec2 = require('@aws-cdk/aws-ec2'); - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const vpc = new ec2.Vpc(this, 'VPC'); - - /// here - } -} diff --git a/packages/monocdk/rosetta/withRepoAndKinesisStream.ts-fixture b/packages/monocdk/rosetta/withRepoAndKinesisStream.ts-fixture deleted file mode 100644 index 115e1ece7e254..0000000000000 --- a/packages/monocdk/rosetta/withRepoAndKinesisStream.ts-fixture +++ /dev/null @@ -1,23 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Duration, RemovalPolicy, Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; - -import * as targets from '@aws-cdk/aws-events-targets'; -import * as events from '@aws-cdk/aws-events'; -import * as kinesis from '@aws-cdk/aws-kinesis'; -import * as codecommit from '@aws-cdk/aws-codecommit'; -import * as cdk from '@aws-cdk/core'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const repository = new codecommit.Repository(this, 'MyRepo', { - repositoryName: 'aws-cdk-events', - }); - - const stream = new kinesis.Stream(this, 'MyStream'); - - /// here - } -} diff --git a/packages/monocdk/rosetta/withRepoAndSqsQueue.ts-fixture b/packages/monocdk/rosetta/withRepoAndSqsQueue.ts-fixture deleted file mode 100644 index 98d029d8d8283..0000000000000 --- a/packages/monocdk/rosetta/withRepoAndSqsQueue.ts-fixture +++ /dev/null @@ -1,23 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Duration, RemovalPolicy, Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; - -import * as targets from '@aws-cdk/aws-events-targets'; -import * as events from '@aws-cdk/aws-events'; -import * as sqs from '@aws-cdk/aws-sqs'; -import * as codecommit from '@aws-cdk/aws-codecommit'; -import * as cdk from '@aws-cdk/core'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const repository = new codecommit.Repository(this, 'MyRepo', { - repositoryName: 'aws-cdk-events', - }); - - const queue = new sqs.Queue(this, 'MyQueue'); - - /// here - } -} diff --git a/packages/monocdk/rosetta/withRepoAndTopic.ts-fixture b/packages/monocdk/rosetta/withRepoAndTopic.ts-fixture deleted file mode 100644 index 30c1f29cc331b..0000000000000 --- a/packages/monocdk/rosetta/withRepoAndTopic.ts-fixture +++ /dev/null @@ -1,23 +0,0 @@ -// Fixture with packages imported, but nothing else -import { Duration, RemovalPolicy, Stack } from '@aws-cdk/core'; -import { Construct } from 'constructs'; - -import * as targets from '@aws-cdk/aws-events-targets'; -import * as events from '@aws-cdk/aws-events'; -import * as sns from '@aws-cdk/aws-sns'; -import * as codecommit from '@aws-cdk/aws-codecommit'; -import * as cdk from '@aws-cdk/core'; - -class Fixture extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); - - const repository = new codecommit.Repository(this, 'MyRepo', { - repositoryName: 'aws-cdk-events', - }); - - const topic = new sns.Topic(this, 'MyTopic'); - - /// here - } -} From e374cadaefb9ac95756b5a4642dbe4494671ce13 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Wed, 10 Nov 2021 14:41:18 +0100 Subject: [PATCH 14/18] chore(core): make examples compile (#17432) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/core/README.md | 12 +++++++- packages/@aws-cdk/core/lib/assets.ts | 4 +-- packages/@aws-cdk/core/lib/bundling.ts | 6 ++-- .../@aws-cdk/core/lib/construct-compat.ts | 2 +- .../custom-resource-provider.ts | 29 ++++++++++++++----- packages/@aws-cdk/core/lib/nested-stack.ts | 4 +-- packages/@aws-cdk/core/lib/removal-policy.ts | 6 ++-- packages/@aws-cdk/core/lib/stack.ts | 10 ++++--- packages/@aws-cdk/core/package.json | 9 +++++- .../@aws-cdk/core/rosetta/default.ts-fixture | 17 +++++++++-- packages/aws-cdk-lib/README.md | 12 +++++++- 11 files changed, 85 insertions(+), 26 deletions(-) diff --git a/packages/@aws-cdk/core/README.md b/packages/@aws-cdk/core/README.md index 611467116459e..d6b58901838c2 100644 --- a/packages/@aws-cdk/core/README.md +++ b/packages/@aws-cdk/core/README.md @@ -237,6 +237,8 @@ this purpose. use the region and account of the stack you're calling it on: ```ts +declare const stack: Stack; + // Builds "arn::lambda:::function:MyFunction" stack.formatArn({ service: 'lambda', @@ -252,6 +254,8 @@ but in case of a deploy-time value be aware that the result will be another deploy-time value which cannot be inspected in the CDK application. ```ts +declare const stack: Stack; + // Extracts the function name out of an AWS Lambda Function ARN const arnComponents = stack.parseArn(arn, ':'); const functionName = arnComponents.resourceName; @@ -383,7 +387,11 @@ examples ensures that only a single SNS topic is defined: function getOrCreate(scope: Construct): sns.Topic { const stack = Stack.of(scope); const uniqueid = 'GloballyUniqueIdForSingleton'; // For example, a UUID from `uuidgen` - return stack.node.tryFindChild(uniqueid) as sns.Topic ?? new sns.Topic(stack, uniqueid); + const existing = stack.node.tryFindChild(uniqueid); + if (existing) { + return existing as sns.Topic; + } + return new sns.Topic(stack, uniqueid); } ``` @@ -816,6 +824,8 @@ since the top-level key is an unresolved token. The call to `findInMap` will ret `{ "Fn::FindInMap": [ "RegionTable", { "Ref": "AWS::Region" }, "regionName" ] }`. ```ts +declare const regionTable: CfnMapping; + regionTable.findInMap(Aws.REGION, 'regionName'); ``` diff --git a/packages/@aws-cdk/core/lib/assets.ts b/packages/@aws-cdk/core/lib/assets.ts index 7cd9b9c973f9f..3732cc4fc19b8 100644 --- a/packages/@aws-cdk/core/lib/assets.ts +++ b/packages/@aws-cdk/core/lib/assets.ts @@ -247,14 +247,14 @@ export interface FileAssetLocation { /** * The HTTP URL of this asset on Amazon S3. * - * @example https://s3-us-east-1.amazonaws.com/mybucket/myobject + * Example value: `https://s3-us-east-1.amazonaws.com/mybucket/myobject` */ readonly httpUrl: string; /** * The S3 URL of this asset on Amazon S3. * - * @example s3://mybucket/myobject + * Example value: `s3://mybucket/myobject` */ readonly s3ObjectUrl: string; diff --git a/packages/@aws-cdk/core/lib/bundling.ts b/packages/@aws-cdk/core/lib/bundling.ts index 1ce4633354511..f83a6bc6e6237 100644 --- a/packages/@aws-cdk/core/lib/bundling.ts +++ b/packages/@aws-cdk/core/lib/bundling.ts @@ -16,7 +16,7 @@ export interface BundlingOptions { /** * The entrypoint to run in the Docker container. * - * @example ['/bin/sh', '-c'] + * Example value: `['/bin/sh', '-c']` * * @see https://docs.docker.com/engine/reference/builder/#entrypoint * @@ -27,7 +27,7 @@ export interface BundlingOptions { /** * The command to run in the Docker container. * - * @example ['npm', 'install'] + * Example value: `['npm', 'install']` * * @see https://docs.docker.com/engine/reference/run/ * @@ -447,7 +447,7 @@ export interface DockerBuildOptions { /** * Set platform if server is multi-platform capable. _Requires Docker Engine API v1.38+_. * - * @example 'linux/amd64' + * Example value: `linux/amd64` * * @default - no platform specified */ diff --git a/packages/@aws-cdk/core/lib/construct-compat.ts b/packages/@aws-cdk/core/lib/construct-compat.ts index cc5921fb73465..da969b9b6c02a 100644 --- a/packages/@aws-cdk/core/lib/construct-compat.ts +++ b/packages/@aws-cdk/core/lib/construct-compat.ts @@ -343,7 +343,7 @@ export class ConstructNode { * will be excluded from the calculation. In those cases constructs in the * same tree may have the same addreess. * - * @example c83a2846e506bcc5f10682b564084bca2d275709ee + * Example value: `c83a2846e506bcc5f10682b564084bca2d275709ee` */ public get addr(): string { return this._actualNode.addr; } diff --git a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts index 06f257fa18ff3..832cf6774704b 100644 --- a/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts +++ b/packages/@aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts @@ -36,12 +36,23 @@ export interface CustomResourceProviderProps { * A set of IAM policy statements to include in the inline policy of the * provider's lambda function. * + * **Please note**: these are direct IAM JSON policy blobs, *not* `iam.PolicyStatement` + * objects like you will see in the rest of the CDK. + * * @default - no additional inline policy * * @example - * - * [{ Effect: 'Allow', Action: 's3:PutObject*', Resource: '*' }] - * + * const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyCustomResourceType', { + * codeDirectory: `${__dirname}/my-handler`, + * runtime: CustomResourceProviderRuntime.NODEJS_12_X, + * policyStatements: [ + * { + * Effect: 'Allow', + * Action: 's3:PutObject*', + * Resource: '*', + * } + * ], + * }); */ readonly policyStatements?: any[]; @@ -144,11 +155,15 @@ export class CustomResourceProvider extends CoreConstruct { * `serviceToken` when defining a custom resource. * * @example - * new CustomResource(this, 'MyCustomResource', { - * // ... - * serviceToken: myProvider.serviceToken, // <--- here - * }) + * declare const myProvider: CustomResourceProvider; * + * new CustomResource(this, 'MyCustomResource', { + * serviceToken: myProvider.serviceToken, + * properties: { + * myPropertyOne: 'one', + * myPropertyTwo: 'two', + * }, + * }); */ public readonly serviceToken: string; diff --git a/packages/@aws-cdk/core/lib/nested-stack.ts b/packages/@aws-cdk/core/lib/nested-stack.ts index fd8c47f6a0731..82a123fb9243b 100644 --- a/packages/@aws-cdk/core/lib/nested-stack.ts +++ b/packages/@aws-cdk/core/lib/nested-stack.ts @@ -155,8 +155,8 @@ export class NestedStack extends Stack { * - If this is referenced from the parent stack, it will return a token that parses the name from the stack ID. * - If this is referenced from the context of the nested stack, it will return `{ "Ref": "AWS::StackName" }` * + * Example value: `mystack-mynestedstack-sggfrhxhum7w` * @attribute - * @example mystack-mynestedstack-sggfrhxhum7w */ public get stackName() { return this._contextualStackName; @@ -169,8 +169,8 @@ export class NestedStack extends Stack { * - If this is referenced from the parent stack, it will return `{ "Ref": "LogicalIdOfNestedStackResource" }`. * - If this is referenced from the context of the nested stack, it will return `{ "Ref": "AWS::StackId" }` * + * Example value: `arn:aws:cloudformation:us-east-2:123456789012:stack/mystack-mynestedstack-sggfrhxhum7w/f449b250-b969-11e0-a185-5081d0136786` * @attribute - * @example "arn:aws:cloudformation:us-east-2:123456789012:stack/mystack-mynestedstack-sggfrhxhum7w/f449b250-b969-11e0-a185-5081d0136786" */ public get stackId() { return this._contextualStackId; diff --git a/packages/@aws-cdk/core/lib/removal-policy.ts b/packages/@aws-cdk/core/lib/removal-policy.ts index d815967fa2bf0..f5249949f99ab 100644 --- a/packages/@aws-cdk/core/lib/removal-policy.ts +++ b/packages/@aws-cdk/core/lib/removal-policy.ts @@ -19,8 +19,10 @@ * as shown in the following example: * * ```ts - * const cfnBucket = bucket.node.findChild('Resource') as cdk.CfnResource; - * cfnBucket.applyRemovalPolicy(cdk.RemovalPolicy.DESTROY); + * declare const bucket: s3.Bucket; + * + * const cfnBucket = bucket.node.findChild('Resource') as CfnResource; + * cfnBucket.applyRemovalPolicy(RemovalPolicy.DESTROY); * ``` */ export enum RemovalPolicy { diff --git a/packages/@aws-cdk/core/lib/stack.ts b/packages/@aws-cdk/core/lib/stack.ts index ee80e56334101..6645805519b81 100644 --- a/packages/@aws-cdk/core/lib/stack.ts +++ b/packages/@aws-cdk/core/lib/stack.ts @@ -280,7 +280,7 @@ export class Stack extends CoreConstruct implements ITaggable { * The name of the CloudFormation template file emitted to the output * directory during synthesis. * - * @example 'MyStack.template.json' + * Example value: `MyStack.template.json` */ public readonly templateFile: string; @@ -711,11 +711,13 @@ export class Stack extends CoreConstruct implements ITaggable { * * Duplicate values are removed when stack is synthesized. * - * @example stack.addTransform('AWS::Serverless-2016-10-31') - * * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html - * * @param transform The transform to add + * + * @example + * declare const stack: Stack; + * + * stack.addTransform('AWS::Serverless-2016-10-31') */ public addTransform(transform: string) { if (!this.templateOptions.transforms) { diff --git a/packages/@aws-cdk/core/package.json b/packages/@aws-cdk/core/package.json index a14759ad2d345..730a7057cd1af 100644 --- a/packages/@aws-cdk/core/package.json +++ b/packages/@aws-cdk/core/package.json @@ -28,7 +28,14 @@ ] } }, - "projectReferences": true + "projectReferences": true, + "metadata": { + "jsii": { + "rosetta": { + "strict": true + } + } + } }, "repository": { "type": "git", diff --git a/packages/@aws-cdk/core/rosetta/default.ts-fixture b/packages/@aws-cdk/core/rosetta/default.ts-fixture index 558cc09b1c049..26a25736acb17 100644 --- a/packages/@aws-cdk/core/rosetta/default.ts-fixture +++ b/packages/@aws-cdk/core/rosetta/default.ts-fixture @@ -27,6 +27,7 @@ import { Duration, Fn, IConstruct, + RemovalPolicy, SecretValue, Size, SizeRoundingBehavior, @@ -47,15 +48,27 @@ declare const functionProps: lambda.FunctionProps; declare const isCompleteHandler: lambda.Function; declare const myBucket: s3.IBucket; declare const myFunction: lambda.IFunction; -declare const myProvider: CustomResourceProvider; declare const myTopic: sns.ITopic; declare const onEventHandler: lambda.Function; declare const resourceProps: CfnResourceProps; -declare const stack: Stack; declare class MyStack extends Stack {} declare class YourStack extends Stack {} +class StackThatProvidesABucket extends Stack { + public readonly bucket!: s3.IBucket; +} + +interface StackThatExpectsABucketProps extends StackProps { + readonly bucket: s3.IBucket; +} + +class StackThatExpectsABucket extends Stack { + constructor(scope: Construct, id: string, props: StackThatExpectsABucketProps) { + super(scope, id, props); + } +} + class fixture$construct extends Construct { public constructor(scope: Construct, id: string) { super(scope, id); diff --git a/packages/aws-cdk-lib/README.md b/packages/aws-cdk-lib/README.md index 254a58738b26d..1de8bb1a9fb41 100644 --- a/packages/aws-cdk-lib/README.md +++ b/packages/aws-cdk-lib/README.md @@ -270,6 +270,8 @@ this purpose. use the region and account of the stack you're calling it on: ```ts +declare const stack: Stack; + // Builds "arn::lambda:::function:MyFunction" stack.formatArn({ service: 'lambda', @@ -285,6 +287,8 @@ but in case of a deploy-time value be aware that the result will be another deploy-time value which cannot be inspected in the CDK application. ```ts +declare const stack: Stack; + // Extracts the function name out of an AWS Lambda Function ARN const arnComponents = stack.parseArn(arn, ':'); const functionName = arnComponents.resourceName; @@ -416,7 +420,11 @@ examples ensures that only a single SNS topic is defined: function getOrCreate(scope: Construct): sns.Topic { const stack = Stack.of(scope); const uniqueid = 'GloballyUniqueIdForSingleton'; // For example, a UUID from `uuidgen` - return stack.node.tryFindChild(uniqueid) as sns.Topic ?? new sns.Topic(stack, uniqueid); + const existing = stack.node.tryFindChild(uniqueid); + if (existing) { + return existing as sns.Topic; + } + return new sns.Topic(stack, uniqueid); } ``` @@ -849,6 +857,8 @@ since the top-level key is an unresolved token. The call to `findInMap` will ret `{ "Fn::FindInMap": [ "RegionTable", { "Ref": "AWS::Region" }, "regionName" ] }`. ```ts +declare const regionTable: CfnMapping; + regionTable.findInMap(Aws.REGION, 'regionName'); ``` From 1afc56cd2bd0f77b6b7a3f41d95b6a7a732b14cc Mon Sep 17 00:00:00 2001 From: AWS CDK Automation <43080478+aws-cdk-automation@users.noreply.github.com> Date: Wed, 10 Nov 2021 20:03:54 +0530 Subject: [PATCH 15/18] chore: npm-check-updates && yarn upgrade (#17453) Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date. --- packages/@aws-cdk/assets/package.json | 2 +- .../package.json | 2 +- .../aws-global-table-coordinator/package.json | 2 +- packages/@aws-cdk/core/package.json | 2 +- packages/aws-cdk/package.json | 2 +- packages/awslint/package.json | 2 +- tools/@aws-cdk/cdk-build-tools/package.json | 2 +- tools/@aws-cdk/pkglint/package.json | 2 +- yarn.lock | 78 +++++++++---------- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/packages/@aws-cdk/assets/package.json b/packages/@aws-cdk/assets/package.json index 53d52c49cb4b4..c099d2edc4c02 100644 --- a/packages/@aws-cdk/assets/package.json +++ b/packages/@aws-cdk/assets/package.json @@ -78,7 +78,7 @@ "aws-cdk": "0.0.0", "jest": "^27.3.1", "sinon": "^9.2.4", - "ts-mock-imports": "^1.3.7" + "ts-mock-imports": "^1.3.8" }, "dependencies": { "@aws-cdk/core": "0.0.0", diff --git a/packages/@aws-cdk/aws-certificatemanager/lambda-packages/dns_validated_certificate_handler/package.json b/packages/@aws-cdk/aws-certificatemanager/lambda-packages/dns_validated_certificate_handler/package.json index 7574746f68fcb..f9bba8be5463a 100644 --- a/packages/@aws-cdk/aws-certificatemanager/lambda-packages/dns_validated_certificate_handler/package.json +++ b/packages/@aws-cdk/aws-certificatemanager/lambda-packages/dns_validated_certificate_handler/package.json @@ -36,7 +36,7 @@ "aws-sdk-mock": "^5.4.0", "eslint": "^7.32.0", "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.3.1", "eslint-plugin-standard": "^4.1.0", diff --git a/packages/@aws-cdk/aws-dynamodb-global/lambda-packages/aws-global-table-coordinator/package.json b/packages/@aws-cdk/aws-dynamodb-global/lambda-packages/aws-global-table-coordinator/package.json index c3f061a93ca14..e6d555f5ae442 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/lambda-packages/aws-global-table-coordinator/package.json +++ b/packages/@aws-cdk/aws-dynamodb-global/lambda-packages/aws-global-table-coordinator/package.json @@ -33,7 +33,7 @@ "aws-sdk-mock": "^5.4.0", "eslint": "^7.32.0", "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.3.1", "eslint-plugin-standard": "^4.1.0", diff --git a/packages/@aws-cdk/core/package.json b/packages/@aws-cdk/core/package.json index 730a7057cd1af..abedd17448a1b 100644 --- a/packages/@aws-cdk/core/package.json +++ b/packages/@aws-cdk/core/package.json @@ -189,7 +189,7 @@ "jest": "^27.3.1", "lodash": "^4.17.21", "sinon": "^9.2.4", - "ts-mock-imports": "^1.3.7" + "ts-mock-imports": "^1.3.8" }, "dependencies": { "@aws-cdk/cloud-assembly-schema": "0.0.0", diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index 33300a5663da3..043445db7801c 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -63,7 +63,7 @@ "@aws-cdk/pkglint": "0.0.0", "sinon": "^9.2.4", "ts-jest": "^27.0.7", - "ts-mock-imports": "^1.3.7", + "ts-mock-imports": "^1.3.8", "xml-js": "^1.6.11" }, "dependencies": { diff --git a/packages/awslint/package.json b/packages/awslint/package.json index 4ee4e93482402..d06849b47485a 100644 --- a/packages/awslint/package.json +++ b/packages/awslint/package.json @@ -37,7 +37,7 @@ "eslint-import-resolver-node": "^0.3.6", "eslint-import-resolver-typescript": "^2.5.0", "@aws-cdk/eslint-plugin": "0.0.0", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-jest": "^24.7.0", "jest": "^27.3.1" }, diff --git a/tools/@aws-cdk/cdk-build-tools/package.json b/tools/@aws-cdk/cdk-build-tools/package.json index d1e47434baced..5c5fdb620d894 100644 --- a/tools/@aws-cdk/cdk-build-tools/package.json +++ b/tools/@aws-cdk/cdk-build-tools/package.json @@ -51,7 +51,7 @@ "eslint": "^7.32.0", "eslint-import-resolver-node": "^0.3.6", "eslint-import-resolver-typescript": "^2.5.0", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-jest": "^24.7.0", "fs-extra": "^9.1.0", "jest": "^27.3.1", diff --git a/tools/@aws-cdk/pkglint/package.json b/tools/@aws-cdk/pkglint/package.json index c9725365adfc6..7bb152feb4287 100644 --- a/tools/@aws-cdk/pkglint/package.json +++ b/tools/@aws-cdk/pkglint/package.json @@ -47,7 +47,7 @@ "@typescript-eslint/parser": "^4.33.0", "eslint-import-resolver-node": "^0.3.6", "eslint-import-resolver-typescript": "^2.5.0", - "eslint-plugin-import": "^2.25.2", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-jest": "^24.7.0", "eslint": "^7.32.0", "jest": "^27.3.1", diff --git a/yarn.lock b/yarn.lock index 0f851ebe5ab5b..f4312ed26d658 100644 --- a/yarn.lock +++ b/yarn.lock @@ -75,13 +75,13 @@ source-map "^0.5.0" "@babel/helper-compilation-targets@^7.16.0": - version "7.16.0" - resolved "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.0.tgz#01d615762e796c17952c29e3ede9d6de07d235a8" - integrity sha512-S7iaOT1SYlqK0sQaCi21RX4+13hmdmnxIEAnQUB/eh7GeAnRjOUgTYpLkUOiRXzD+yog1JxP0qyAQZ7ZxVxLVg== + version "7.16.3" + resolved "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.3.tgz#5b480cd13f68363df6ec4dc8ac8e2da11363cbf0" + integrity sha512-vKsoSQAyBmxS35JUOOt+07cLc6Nk/2ljLIHwmq2/NM6hdioUaqEXq/S+nXvbvXbZkNDlWOymPanJGOc4CBjSJA== dependencies: "@babel/compat-data" "^7.16.0" "@babel/helper-validator-option" "^7.14.5" - browserslist "^4.16.6" + browserslist "^4.17.5" semver "^6.3.0" "@babel/helper-function-name@^7.16.0": @@ -182,12 +182,12 @@ integrity sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow== "@babel/helpers@^7.16.0": - version "7.16.0" - resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.16.0.tgz#875519c979c232f41adfbd43a3b0398c2e388183" - integrity sha512-dVRM0StFMdKlkt7cVcGgwD8UMaBfWJHl3A83Yfs8GQ3MO0LHIIIMvK7Fa0RGOGUQ10qikLaX6D7o5htcQWgTMQ== + version "7.16.3" + resolved "https://registry.npmjs.org/@babel/helpers/-/helpers-7.16.3.tgz#27fc64f40b996e7074dc73128c3e5c3e7f55c43c" + integrity sha512-Xn8IhDlBPhvYTvgewPKawhADichOsbkZuzN7qz2BusOM0brChsyXMDJvldWaYMMUNiCQdQzNEioXTp3sC8Nt8w== dependencies: "@babel/template" "^7.16.0" - "@babel/traverse" "^7.16.0" + "@babel/traverse" "^7.16.3" "@babel/types" "^7.16.0" "@babel/highlight@^7.10.4", "@babel/highlight@^7.16.0": @@ -199,10 +199,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.0", "@babel/parser@^7.7.2": - version "7.16.2" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.16.2.tgz#3723cd5c8d8773eef96ce57ea1d9b7faaccd12ac" - integrity sha512-RUVpT0G2h6rOZwqLDTrKk7ksNv7YpAilTnYe1/Q+eDjxEceRMKVWbCsX7t8h6C1qCFi/1Y8WZjcEPBAFG27GPw== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.0", "@babel/parser@^7.16.3", "@babel/parser@^7.7.2": + version "7.16.3" + resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.16.3.tgz#271bafcb811080905a119222edbc17909c82261d" + integrity sha512-dcNwU1O4sx57ClvLBVFbEgx0UZWfd0JQX5X6fxFRCLHelFBGXFfSz6Y0FAq2PEwUqlqLkdVjVr4VASEOuUnLJw== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -304,17 +304,17 @@ "@babel/parser" "^7.16.0" "@babel/types" "^7.16.0" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.16.0", "@babel/traverse@^7.7.2": - version "7.16.0" - resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.0.tgz#965df6c6bfc0a958c1e739284d3c9fa4a6e3c45b" - integrity sha512-qQ84jIs1aRQxaGaxSysII9TuDaguZ5yVrEuC0BN2vcPlalwfLovVmCjbFDPECPXcYM/wLvNFfp8uDOliLxIoUQ== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.16.0", "@babel/traverse@^7.16.3", "@babel/traverse@^7.7.2": + version "7.16.3" + resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.16.3.tgz#f63e8a938cc1b780f66d9ed3c54f532ca2d14787" + integrity sha512-eolumr1vVMjqevCpwVO99yN/LoGL0EyHiLO5I043aYQvwOJ9eR5UsZSClHVCzfhBduMAsSzgA/6AyqPjNayJag== dependencies: "@babel/code-frame" "^7.16.0" "@babel/generator" "^7.16.0" "@babel/helper-function-name" "^7.16.0" "@babel/helper-hoist-variables" "^7.16.0" "@babel/helper-split-export-declaration" "^7.16.0" - "@babel/parser" "^7.16.0" + "@babel/parser" "^7.16.3" "@babel/types" "^7.16.0" debug "^4.1.0" globals "^11.1.0" @@ -2293,9 +2293,9 @@ aws-sdk-mock@^5.4.0: traverse "^0.6.6" aws-sdk@^2.596.0, aws-sdk@^2.848.0, aws-sdk@^2.928.0, aws-sdk@^2.979.0: - version "2.1024.0" - resolved "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1024.0.tgz#c69ae613a546e56643c921d4aae36d7f8d6f44bc" - integrity sha512-FgGvRtxTzgU7iBXG/+hCGqdE2U2gF/NqVDQsTBjrLIbOMiNNheL8uzxcmIKKZ49lFlWwVkM0HNmpEmA5hiLinw== + version "2.1025.0" + resolved "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1025.0.tgz#566f62efc80d6d4cc6e893774a2f15ac774a93fc" + integrity sha512-1AR2xIHcbIWj5y3fh9JHd2fLgiGqpn9Ww+8y9kZDnrsIousJkR6L+QkG0mRhChu/AjpFVQ44fiTBoE4J88Dqyw== dependencies: buffer "4.9.2" events "1.1.1" @@ -2446,7 +2446,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browserslist@^4.16.6: +browserslist@^4.17.5: version "4.17.6" resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.17.6.tgz#c76be33e7786b497f66cad25a73756c8b938985d" integrity sha512-uPgz3vyRTlEiCv4ee9KlsKgo2V6qPk7Jsn0KAn2OBqbqKo3iNcPEC1Ti6J4dwnz+aIRfEEEuOzC9IBk8tXUomw== @@ -3506,9 +3506,9 @@ ecc-jsbn@~0.1.1: safer-buffer "^2.1.0" electron-to-chromium@^1.3.886: - version "1.3.892" - resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.892.tgz#0e3f5bb1de577e2e5a6dffd5a4b278c4a735cd39" - integrity sha512-YDW4yIjdfMnbRoBjRZ/aNQYmT6JgQFLwmTSDRJMQdrY4MByEzppdXp3rnJ0g4LBWcsYTUvwKKClYN1ofZ0COOQ== + version "1.3.893" + resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.893.tgz#9d804c68953b05ede35409dba0d73dd54c077b4d" + integrity sha512-ChtwF7qB03INq1SyMpue08wc6cve+ktj2UC/Y7se9vB+JryfzziJeYwsgb8jLaCA5GMkHCdn5M62PfSMWhifZg== emittery@^0.8.1: version "0.8.1" @@ -3808,7 +3808,7 @@ eslint-import-resolver-typescript@^2.5.0: resolve "^1.20.0" tsconfig-paths "^3.9.0" -eslint-module-utils@^2.7.0: +eslint-module-utils@^2.7.1: version "2.7.1" resolved "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.1.tgz#b435001c9f8dd4ab7f6d0efcae4b9696d4c24b7c" integrity sha512-fjoetBXQZq2tSTWZ9yWVl2KuFrTZZH3V+9iD1V1RfpDgxzJR+mPd/KZmMiA8gbPqdBzpNiEHOuT7IYEWxrH0zQ== @@ -3825,19 +3825,19 @@ eslint-plugin-es@^3.0.0: eslint-utils "^2.0.0" regexpp "^3.0.0" -eslint-plugin-import@^2.25.2: - version "2.25.2" - resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.2.tgz#b3b9160efddb702fc1636659e71ba1d10adbe9e9" - integrity sha512-qCwQr9TYfoBHOFcVGKY9C9unq05uOxxdklmBXLVvcwo68y5Hta6/GzCZEMx2zQiu0woKNEER0LE7ZgaOfBU14g== +eslint-plugin-import@^2.25.3: + version "2.25.3" + resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.3.tgz#a554b5f66e08fb4f6dc99221866e57cfff824766" + integrity sha512-RzAVbby+72IB3iOEL8clzPLzL3wpDrlwjsTBAQXgyp5SeTqqY+0bFubwuo+y/HLhNZcXV4XqTBO4LGsfyHIDXg== dependencies: array-includes "^3.1.4" array.prototype.flat "^1.2.5" debug "^2.6.9" doctrine "^2.1.0" eslint-import-resolver-node "^0.3.6" - eslint-module-utils "^2.7.0" + eslint-module-utils "^2.7.1" has "^1.0.3" - is-core-module "^2.7.0" + is-core-module "^2.8.0" is-glob "^4.0.3" minimatch "^3.0.4" object.values "^1.1.5" @@ -4246,9 +4246,9 @@ flatted@^2.0.1: integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== flatted@^3.1.0: - version "3.2.2" - resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561" - integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA== + version "3.2.4" + resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2" + integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw== follow-redirects@^1.11.0, follow-redirects@^1.14.0: version "1.14.5" @@ -4940,7 +4940,7 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.2.0, is-core-module@^2.5.0, is-core-module@^2.7.0: +is-core-module@^2.2.0, is-core-module@^2.5.0, is-core-module@^2.8.0: version "2.8.0" resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz#0321336c3d0925e497fd97f5d95cb114a5ccd548" integrity sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw== @@ -8713,10 +8713,10 @@ ts-jest@^27.0.7: semver "7.x" yargs-parser "20.x" -ts-mock-imports@^1.3.7: - version "1.3.7" - resolved "https://registry.npmjs.org/ts-mock-imports/-/ts-mock-imports-1.3.7.tgz#8c3210a641f40fd5cadbd1c9c88574b51df59bde" - integrity sha512-zy4B3QSGaOhjaX9j0h9YKwM1oHG4Kd1KIUJBeXlXIQrFnATNLgh4+NyRcaAHsPeqwe3TWeRtHXkNXPxySEKk3w== +ts-mock-imports@^1.3.8: + version "1.3.8" + resolved "https://registry.npmjs.org/ts-mock-imports/-/ts-mock-imports-1.3.8.tgz#6b26887c651effe947ea91f928338d1899146fb9" + integrity sha512-A5n0iEg4zh2/qToo54XOa/wT31fAI0B8DHYU4RDcA6HIddZQPRkTsYri3Hl69+OSLjOKWjyP3/vYOIp3SAIZXg== ts-node@^10.2.1: version "10.4.0" From 1d30d829b62af066f51a4447a4b528a843e78e2e Mon Sep 17 00:00:00 2001 From: kaizen3031593 <36202692+kaizen3031593@users.noreply.github.com> Date: Wed, 10 Nov 2021 12:33:53 -0500 Subject: [PATCH 16/18] chore(ubergen): make rosetta fixtures submodule aware (#17438) Currently ubergen bundles all fixtures into the same `rosetta` folder. This means that all fixtures in files called `default.ts-fixture` replace each other as they are found and vie to be the last `default.ts-fixture` standing in the `rosetta` folder. This causes unintended compiliation failures for `yarn rosetta:extract --compile` in projects that rely on ubergen, since they will be copied into the wrong `default.ts-fixture`. The solution here in jsii is to find fixtures based on submodules: https://github.com/aws/jsii/pull/3131. This PR updates ubergen to construct the necessary subfolders in `rosetta` so that the expected submodule fixtures can be found. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- tools/@aws-cdk/ubergen/bin/ubergen.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/@aws-cdk/ubergen/bin/ubergen.ts b/tools/@aws-cdk/ubergen/bin/ubergen.ts index 772e6b358b403..c32a6a431de17 100644 --- a/tools/@aws-cdk/ubergen/bin/ubergen.ts +++ b/tools/@aws-cdk/ubergen/bin/ubergen.ts @@ -254,8 +254,9 @@ async function combineRosettaFixtures(libraries: readonly LibraryReference[]) { for (const library of libraries) { const packageRosettaDir = path.join(library.root, 'rosetta'); + const uberRosettaTargetDir = library.shortName === 'core' ? uberRosettaDir : path.join(uberRosettaDir, library.shortName.replace(/-/g, '_')); if (await fs.pathExists(packageRosettaDir)) { - await fs.copy(packageRosettaDir, uberRosettaDir, { + await fs.copy(packageRosettaDir, uberRosettaTargetDir, { overwrite: true, recursive: true, }); From af61b7f2fec17d4f817e78db21d09d471d8e2baf Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Wed, 10 Nov 2021 21:15:36 +0100 Subject: [PATCH 17/18] fix(cli): skip bundling for the 'watch' command (#17455) Add `watch` to the list of commands that require bundling. Closes #17391 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/lib/settings.ts | 4 +++- packages/aws-cdk/test/settings.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/settings.ts b/packages/aws-cdk/lib/settings.ts index 6182ecc26e0c3..38723bffc0bc3 100644 --- a/packages/aws-cdk/lib/settings.ts +++ b/packages/aws-cdk/lib/settings.ts @@ -30,6 +30,7 @@ export enum Command { METADATA = 'metadata', INIT = 'init', VERSION = 'version', + WATCH = 'watch', } const BUNDLING_COMMANDS = [ @@ -37,6 +38,7 @@ const BUNDLING_COMMANDS = [ Command.DIFF, Command.SYNTH, Command.SYNTHESIZE, + Command.WATCH, ]; export type Arguments = { @@ -251,7 +253,7 @@ export class Settings { // Determine bundling stacks let bundlingStacks: string[]; if (BUNDLING_COMMANDS.includes(argv._[0])) { - // If we deploy, diff or synth a list of stacks exclusively we skip + // If we deploy, diff, synth or watch a list of stacks exclusively we skip // bundling for all other stacks. bundlingStacks = argv.exclusively ? argv.STACKS ?? ['*'] diff --git a/packages/aws-cdk/test/settings.test.ts b/packages/aws-cdk/test/settings.test.ts index 0f283b386006b..aef16e6bac946 100644 --- a/packages/aws-cdk/test/settings.test.ts +++ b/packages/aws-cdk/test/settings.test.ts @@ -100,6 +100,16 @@ test('bundling stacks defaults to * for deploy', () => { expect(settings.get(['bundlingStacks'])).toEqual(['*']); }); +test('bundling stacks defaults to * for watch', () => { + // GIVEN + const settings = Settings.fromCommandLineArguments({ + _: [Command.WATCH], + }); + + // THEN + expect(settings.get(['bundlingStacks'])).toEqual(['*']); +}); + test('bundling stacks with deploy exclusively', () => { // GIVEN const settings = Settings.fromCommandLineArguments({ @@ -112,6 +122,18 @@ test('bundling stacks with deploy exclusively', () => { expect(settings.get(['bundlingStacks'])).toEqual(['cool-stack']); }); +test('bundling stacks with watch exclusively', () => { + // GIVEN + const settings = Settings.fromCommandLineArguments({ + _: [Command.WATCH], + exclusively: true, + STACKS: ['cool-stack'], + }); + + // THEN + expect(settings.get(['bundlingStacks'])).toEqual(['cool-stack']); +}); + test('should include outputs-file in settings', () => { // GIVEN const settings = Settings.fromCommandLineArguments({ From 3570b172510c395fd1308c552442e11abc9c4124 Mon Sep 17 00:00:00 2001 From: Tatsuya Yamamoto Date: Thu, 11 Nov 2021 06:00:50 +0900 Subject: [PATCH 18/18] chore(iot-actions): clarify the test difference (#17451) This PR refactor the test that I committed earlier, and is based on the following comment. - https://github.com/aws/aws-cdk/pull/17307#discussion_r745890426 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../cloudwatch-logs-action.test.ts | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts b/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts index 3b6ecd2d57fbc..4499cdd35d6f1 100644 --- a/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts +++ b/packages/@aws-cdk/aws-iot-actions/test/cloudwatch-logs/cloudwatch-logs-action.test.ts @@ -1,4 +1,4 @@ -import { Template } from '@aws-cdk/assertions'; +import { Template, Match } from '@aws-cdk/assertions'; import * as iam from '@aws-cdk/aws-iam'; import * as iot from '@aws-cdk/aws-iot'; import * as logs from '@aws-cdk/aws-logs'; @@ -95,32 +95,12 @@ test('can set role', () => { Template.fromStack(stack).hasResourceProperties('AWS::IoT::TopicRule', { TopicRulePayload: { Actions: [ - { - CloudwatchLogs: { - LogGroupName: 'my-log-group', - RoleArn: 'arn:aws:iam::123456789012:role/ForTest', - }, - }, + Match.objectLike({ CloudwatchLogs: { RoleArn: 'arn:aws:iam::123456789012:role/ForTest' } }), ], }, }); Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { - PolicyDocument: { - Statement: [ - { - Action: ['logs:CreateLogStream', 'logs:PutLogEvents'], - Effect: 'Allow', - Resource: 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group:*', - }, - { - Action: 'logs:DescribeLogStreams', - Effect: 'Allow', - Resource: 'arn:aws:logs:us-east-1:123456789012:log-group:my-log-group:*', - }, - ], - Version: '2012-10-17', - }, PolicyName: 'MyRolePolicy64AB00A5', Roles: ['ForTest'], });