diff --git a/CHANGELOG.md b/CHANGELOG.md index 147f2343582a3..0167a2fb4caa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,106 @@ 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.21.0](https://github.com/aws/aws-cdk/compare/v1.20.0...v1.21.0) (2020-01-15) + + +### Features + +* **assert:** cdk assert: implement 'haveOutput' assertion ([#5366](https://github.com/aws/aws-cdk/issues/5366)) ([ee6decb](https://github.com/aws/aws-cdk/commit/ee6decbb4f2b90454777632f8750eae8674b1be2)), closes [#1906](https://github.com/aws/aws-cdk/issues/1906) +* **cli:** run cdk from inner directories ([#5772](https://github.com/aws/aws-cdk/issues/5772)) ([a54630d](https://github.com/aws/aws-cdk/commit/a54630db99716e1a7a19e4320fa4c55a42e5ea68)) +* **codepipeline:** add CannedACL and CacheControl to S3 deploy action ([#5698](https://github.com/aws/aws-cdk/issues/5698)) ([b3e7978](https://github.com/aws/aws-cdk/commit/b3e7978dff2ce20d8e0327db13186922205a1b4c)) +* **codepipeline:** add support for externalEntityLink in the manual approval action ([#5558](https://github.com/aws/aws-cdk/issues/5558)) ([be2e3e3](https://github.com/aws/aws-cdk/commit/be2e3e305eee5d90552c08512a4d476db74b91d0)) +* **codepipeline:** Pipeline Variables ([#5604](https://github.com/aws/aws-cdk/issues/5604)) ([34d3e7d](https://github.com/aws/aws-cdk/commit/34d3e7de39dc197510013f6e4f91170b4c2e29f7)), closes [#5219](https://github.com/aws/aws-cdk/issues/5219) +* **ec2:** `VpcEndpointService` construct ([#5498](https://github.com/aws/aws-cdk/issues/5498)) ([a2713f3](https://github.com/aws/aws-cdk/commit/a2713f35d65bd26fb9ff878c6daed072ffed5f15)) +* recommend matching commands ([#5668](https://github.com/aws/aws-cdk/issues/5668)) ([6108b91](https://github.com/aws/aws-cdk/commit/6108b91d6d3c087a61ac9b3990030a5a52a08808)) +* **elbv2:** default config for internal load balancer will fall back to Isolated subnets ([#5696](https://github.com/aws/aws-cdk/pull/5696)) ([8b9c1fc](https://github.com/aws/aws-cdk/commit/8b9c1fc652673083ffd92f58a97931c1bbb834c9)) +* **iam:** `Role.withoutPolicyUpdates()` ([#5569](https://github.com/aws/aws-cdk/issues/5569)) ([ea4ca3e](https://github.com/aws/aws-cdk/commit/ea4ca3ea251e54921c39ee79f321cae2701837ad)), closes [#2985](https://github.com/aws/aws-cdk/issues/2985) [#4465](https://github.com/aws/aws-cdk/issues/4465) [#4501](https://github.com/aws/aws-cdk/issues/4501) +* **iam:** support importing service roles ([#5701](https://github.com/aws/aws-cdk/issues/5701)) ([0f02dad](https://github.com/aws/aws-cdk/commit/0f02dad9ffa9d01912f29edc0c8d91869a6c4824)), closes [#2651](https://github.com/aws/aws-cdk/issues/2651) +* **s3:** server access logs ([#5072](https://github.com/aws/aws-cdk/issues/5072)) ([c9b074b](https://github.com/aws/aws-cdk/commit/c9b074b28b26a537fb81b9a4a431df6412964c59)) + + +### Bug Fixes + +* **acm:** `DnsValidatedCertificate` in non-aws partitions ([#5771](https://github.com/aws/aws-cdk/issues/5771)) ([e3305d8](https://github.com/aws/aws-cdk/commit/e3305d8d09b3fd87a0609606c3638332c4eeef33)) +* **apigateway:** authorizer name is not optional ([#5731](https://github.com/aws/aws-cdk/issues/5731)) ([21c425e](https://github.com/aws/aws-cdk/commit/21c425e066dec3ec44daedfa980f9e4d96488755)), closes [#5678](https://github.com/aws/aws-cdk/issues/5678) +* **apigateway:** unable to associate RestApi as a route53 target for late bound domains ([#5555](https://github.com/aws/aws-cdk/issues/5555)) ([c02741e](https://github.com/aws/aws-cdk/commit/c02741ed53ecc834acfb5c3c4d5fc0deab6f2726)) +* **cli:** Fix various init templates & their tests ([#5693](https://github.com/aws/aws-cdk/issues/5693)) ([a85da79](https://github.com/aws/aws-cdk/commit/a85da79c0da05f57af84d388efe7775502cf0039)) +* **cli:** proxy support is broken ([#5803](https://github.com/aws/aws-cdk/issues/5803)) ([3a63f57](https://github.com/aws/aws-cdk/commit/3a63f57b3f36f914ac086d9bfe08274f0ddec574)), closes [#5743](https://github.com/aws/aws-cdk/issues/5743) [#5791](https://github.com/aws/aws-cdk/issues/5791) +* **cloudformation:** nested stack example in readme is broken ([#5729](https://github.com/aws/aws-cdk/issues/5729)) ([c53356a](https://github.com/aws/aws-cdk/commit/c53356a3cc4c4a96d326d73bfa28d791100391bc)), closes [#5686](https://github.com/aws/aws-cdk/issues/5686) +* **cloudwatch:** cross-account metrics in env-agnostic stack ([#5775](https://github.com/aws/aws-cdk/issues/5775)) ([5292bd5](https://github.com/aws/aws-cdk/commit/5292bd56ad4f7c2bf68767861c5e252b13282f34)), closes [aws/aws-cdk#5628](https://github.com/aws/aws-cdk/issues/5628) +* **codepipeline:** Action.onStateChange() has wrong detail type ([#5721](https://github.com/aws/aws-cdk/issues/5721)) ([8686dd5](https://github.com/aws/aws-cdk/commit/8686dd5bae583df08f2b25a8133c7e9296f7a643)), closes [#3614](https://github.com/aws/aws-cdk/issues/3614) +* **custom-resources:** missing physical resource id for delete calls ([#5805](https://github.com/aws/aws-cdk/issues/5805)) ([9b7236a](https://github.com/aws/aws-cdk/commit/9b7236abb4b08c2d080858059dc2b531031da6fe)), closes [#5796](https://github.com/aws/aws-cdk/issues/5796) +* **ecr-assets:** unable to use one Dockerfile to build multiple images ([#5705](https://github.com/aws/aws-cdk/issues/5705)) ([ff3f27f](https://github.com/aws/aws-cdk/commit/ff3f27fe56dc2300032c307cf09f50a3cd7a997e)), closes [#5683](https://github.com/aws/aws-cdk/issues/5683) +* **ecs:** cannot separate `Cluster` and `Ec2Service` behind ALB ([#5813](https://github.com/aws/aws-cdk/issues/5813)) ([eb3c517](https://github.com/aws/aws-cdk/commit/eb3c5170e1c3f5243ee437ab7627dd84d68d5740)) +* **glue:** empty string in Table.s3prefix is not undefined ([#5783](https://github.com/aws/aws-cdk/issues/5783)) ([18e15de](https://github.com/aws/aws-cdk/commit/18e15de64dfcadd9b5cacef54ed5d93a9a91189a)), closes [#5763](https://github.com/aws/aws-cdk/issues/5763) +* **iam:** can't use `OrganizationPrincipal` for assuming Role ([#5746](https://github.com/aws/aws-cdk/issues/5746)) ([6c3d4c4](https://github.com/aws/aws-cdk/commit/6c3d4c40b7f4cef1c3d484bf9b3409ee6f33cc27)), closes [#5732](https://github.com/aws/aws-cdk/issues/5732) +* **rds:** pass the ARN of master instead of its ID in DatabaseInstanceReadReplica ([#5702](https://github.com/aws/aws-cdk/issues/5702)) ([d323c0c](https://github.com/aws/aws-cdk/commit/d323c0c13aaf475f59615a41969bb60cbb678be8)), closes [#5530](https://github.com/aws/aws-cdk/issues/5530) + +## [1.20.0](https://github.com/aws/aws-cdk/compare/v1.19.0...v1.20.0) (2020-01-07) + + +### ⚠ BREAKING CHANGES + +* **autoscaling:** AutoScalingGroups without `desiredCapacity` are now +initially scaled to their minimum capacity (instead of their maximum +capaciety). +* **rds:** `addRotationSingleUser(id: string, options: SecretRotationOptions)` is now `addRotationSingleUser(automaticallyAfter?: Duration)` +* **glue:** InputFormat. TEXT_INPUT_FORMAT has been renamed to TEXT. OutputFormat. HIVE_IGNORE_KEY_TEXT_OUTPUT_FORMAT has been renamed to HIVE_IGNORE_KEY_TEXT + +### Features + +* **apigateway:** lambda token authorizer ([#5197](https://github.com/aws/aws-cdk/issues/5197)) ([5c16744](https://github.com/aws/aws-cdk/commit/5c167448f16ea368efc8192abc26e281f976ec7f)), closes [#5584](https://github.com/aws/aws-cdk/issues/5584) +* **aws-stepfunctions:** support StateMachineType ([#5398](https://github.com/aws/aws-cdk/issues/5398)) ([ea095f0](https://github.com/aws/aws-cdk/commit/ea095f0198ebe1efd2f20621cac111b71ee68bd7)), closes [#5397](https://github.com/aws/aws-cdk/issues/5397) +* **cli:** support custom CA certificate bundles ([ac748c1](https://github.com/aws/aws-cdk/commit/ac748c1786e68774f5d0ea9cfbec439034166c40)), closes [#5294](https://github.com/aws/aws-cdk/issues/5294) +* **cloudformation:** update cloudformation spec to v10.2.0 ([#5542](https://github.com/aws/aws-cdk/issues/5542)) ([cb65da3](https://github.com/aws/aws-cdk/commit/cb65da3cd31425265aadd2f2e806a45b244fab8b)) +* **cloudwatch:** make Metric objects region-aware ([212687c](https://github.com/aws/aws-cdk/commit/212687c1427b4e0e6dde11c69139e5036a1ce087)) +* **cloudwatch:** support for metric math ([#5582](https://github.com/aws/aws-cdk/issues/5582)) ([a7f189e](https://github.com/aws/aws-cdk/commit/a7f189e980fdc21b44b8d20fcb491d798ffb682e)), closes [#1077](https://github.com/aws/aws-cdk/issues/1077) [#5449](https://github.com/aws/aws-cdk/issues/5449) [#5261](https://github.com/aws/aws-cdk/issues/5261) [#4716](https://github.com/aws/aws-cdk/issues/4716) +* **codebuild:** add 2X_Large compute type option ([#5429](https://github.com/aws/aws-cdk/issues/5429)) ([1291ef6](https://github.com/aws/aws-cdk/commit/1291ef6b4eb7b8333247b243bcf37bdcb8aaa07f)), closes [#5401](https://github.com/aws/aws-cdk/issues/5401) +* **core:** add support for the ref intrinsic function ([#5468](https://github.com/aws/aws-cdk/issues/5468)) ([#5470](https://github.com/aws/aws-cdk/issues/5470)) ([cad5bc1](https://github.com/aws/aws-cdk/commit/cad5bc148bfdd088c1307932b919899a98fd860a)) +* **custom-resource:** Allow custom ResourceTypes on CustomResources ([#5248](https://github.com/aws/aws-cdk/issues/5248)) ([c605ceb](https://github.com/aws/aws-cdk/commit/c605ceb40a49528505669bac61403673b38da5ba)) +* **custom-resources:** getDataString for AwsCustomResource ([#5578](https://github.com/aws/aws-cdk/issues/5578)) ([faa368d](https://github.com/aws/aws-cdk/commit/faa368dfa7d6706669a9eaca2279cb86d2dd42c7)), closes [#5570](https://github.com/aws/aws-cdk/issues/5570) +* **custom-resources:** ignore DELETE after failed CREATE ([#5525](https://github.com/aws/aws-cdk/issues/5525)) ([9ab989e](https://github.com/aws/aws-cdk/commit/9ab989e4aba7b4fdeee062097dda01b25d41675d)), closes [#5524](https://github.com/aws/aws-cdk/issues/5524) +* **custom-resources:** use latest SDK in AwsCustomResource ([#5442](https://github.com/aws/aws-cdk/issues/5442)) ([a111cdd](https://github.com/aws/aws-cdk/commit/a111cdd97928280b206c3dcfc522e642106e3a70)), closes [#2689](https://github.com/aws/aws-cdk/issues/2689) [#5063](https://github.com/aws/aws-cdk/issues/5063) +* **dynamodb:** Implement importing existing dynamodb table. ([#5280](https://github.com/aws/aws-cdk/issues/5280)) ([8d9b58b](https://github.com/aws/aws-cdk/commit/8d9b58bbf58c0b7281dbce79720e471e533a18c0)), closes [#3895](https://github.com/aws/aws-cdk/issues/3895) +* **ec2:** add `privateIpAddress` to Instance ([a00906d](https://github.com/aws/aws-cdk/commit/a00906d22317103156acacc597623aafa660acbb)), closes [#4004](https://github.com/aws/aws-cdk/issues/4004) +* **ec2:** support block devices for `Instance` ([#5567](https://github.com/aws/aws-cdk/issues/5567)) ([1085a27](https://github.com/aws/aws-cdk/commit/1085a27d6d57621b47f415a3e2a11166702e8709)), closes [#4773](https://github.com/aws/aws-cdk/issues/4773) [#4781](https://github.com/aws/aws-cdk/issues/4781) +* **ecr-assets:** custom docker files ([#5652](https://github.com/aws/aws-cdk/issues/5652)) ([1b25a4b](https://github.com/aws/aws-cdk/commit/1b25a4b44e992f076d0bcf2d805880fdbebca34a)) +* **ecs-patterns:** higher-level constructs for ECS service with multiple target groups ([#5083](https://github.com/aws/aws-cdk/issues/5083)) ([c0a7192](https://github.com/aws/aws-cdk/commit/c0a7192c7a3b4a69a0415af679c684f7783c95c8)) +* **eks:** EKS-Optimized AMI with GPU support for G4 instance ([#5479](https://github.com/aws/aws-cdk/issues/5479)) ([7b34d56](https://github.com/aws/aws-cdk/commit/7b34d5635ecda5db337dfab32711443f57ad1518)) +* **eks:** helm chart support ([#5390](https://github.com/aws/aws-cdk/issues/5390)) ([394313e](https://github.com/aws/aws-cdk/commit/394313ee931e38bc20fc3dcb1cd2fd1b6f66822e)) +* **glue:** add support for more DataFormats ([#5246](https://github.com/aws/aws-cdk/issues/5246)) ([ca535d0](https://github.com/aws/aws-cdk/commit/ca535d0b1f1e993e3cc452e9ebc2a4a268032998)) +* **lambda:** configuration for async invocations ([#5299](https://github.com/aws/aws-cdk/issues/5299)) ([746ba32](https://github.com/aws/aws-cdk/commit/746ba3247a86a0cca60a1bb7897dd12848d904e9)) +* **logs:** import a LogGroup from its name ([#5580](https://github.com/aws/aws-cdk/issues/5580)) ([9cbbaea](https://github.com/aws/aws-cdk/commit/9cbbaeae66311921c2db459e91f2a6943628577e)) +* **rds:** more extensive secret rotation support ([#5281](https://github.com/aws/aws-cdk/issues/5281)) ([b700b77](https://github.com/aws/aws-cdk/commit/b700b778e74822e520867dbc5ff5524fb0c82eaf)), closes [#5194](https://github.com/aws/aws-cdk/issues/5194) +* **codebuild:** add Secrets Manager to CodeBuild environment variable types ([#5464](https://github.com/aws/aws-cdk/issues/5464)) ([ff1fa68](https://github.com/aws/aws-cdk/commit/ff1fa68408136f9677326f0d2d92a891396c0709)) + + +### Bug Fixes + +* **autoscaling:** every deployment resets capacity ([#5507](https://github.com/aws/aws-cdk/issues/5507)) ([0adf6c7](https://github.com/aws/aws-cdk/commit/0adf6c75c1f0aa4acc131915970a496326dc559f)), closes [#5215](https://github.com/aws/aws-cdk/issues/5215) [#5208](https://github.com/aws/aws-cdk/issues/5208) +* **aws-cdk:** upgrade canaries lambda node version ([#5674](https://github.com/aws/aws-cdk/issues/5674)) ([96b802b](https://github.com/aws/aws-cdk/commit/96b802b23f347a83617aa292e320cee20793b0c1)) +* **codebuild:** ARM images have the wrong type and compute kind ([#5541](https://github.com/aws/aws-cdk/issues/5541)) ([6999baf](https://github.com/aws/aws-cdk/commit/6999baf4c493ce618e66c3a4e4f6f4970540a5d1)), closes [#5517](https://github.com/aws/aws-cdk/issues/5517) +* **codebuild:** cannot use immutable roles for Project ([6103180](https://github.com/aws/aws-cdk/commit/6103180c5427bb887fe1734330b109579874649d)), closes [#1408](https://github.com/aws/aws-cdk/issues/1408) +* **codebuild:** rename CodeBuild VPC policy to be unique ([#5385](https://github.com/aws/aws-cdk/issues/5385)) ([16a1200](https://github.com/aws/aws-cdk/commit/16a1200b7132f72772a5d5230e137f793cd56d7a)) +* **core:** nested Fn.join with token fails ([#5679](https://github.com/aws/aws-cdk/issues/5679)) ([24ded60](https://github.com/aws/aws-cdk/commit/24ded60d82482b17bb08f98cba262f4f9bd23493)), closes [#5655](https://github.com/aws/aws-cdk/issues/5655) +* **cli:** java sample-app init template does not have a src/ directory ([#5546](https://github.com/aws/aws-cdk/issues/5546)) ([71947b5](https://github.com/aws/aws-cdk/commit/71947b5d7417e9ff26b59f16b6610fd176195662)) +* **core:** nested stacks does not report missing context [#5594](https://github.com/aws/aws-cdk/issues/5594) ([#5638](https://github.com/aws/aws-cdk/issues/5638)) ([9472e09](https://github.com/aws/aws-cdk/commit/9472e0956c9e2ebe657462afe581fab5675c55cd)) +* **core:** tags not working for cognito user pools ([#4225](https://github.com/aws/aws-cdk/issues/4225)) ([a67f0ef](https://github.com/aws/aws-cdk/commit/a67f0efb736f71ee8dd9c9ec31f8c867618849df)), closes [#3882](https://github.com/aws/aws-cdk/issues/3882) +* **custom-resources:** default timeout of 2 minutes for AwsCustomResource ([#5658](https://github.com/aws/aws-cdk/issues/5658)) ([e0c41d4](https://github.com/aws/aws-cdk/commit/e0c41d4246fc0588a298bb27efd743fc05439b36)) +* **ec2:** allow ingress to VPC interface endpoints ([#4938](https://github.com/aws/aws-cdk/issues/4938)) ([d5ed97a](https://github.com/aws/aws-cdk/commit/d5ed97a84d91e4eb7b13c11c4b0b826625f564d4)), closes [#4937](https://github.com/aws/aws-cdk/issues/4937) +* **eks:** aws-auth username not set by default ([#5649](https://github.com/aws/aws-cdk/issues/5649)) ([87befa6](https://github.com/aws/aws-cdk/commit/87befa6f725072cb0fa3712e8819f97ef3698602)), closes [#5263](https://github.com/aws/aws-cdk/issues/5263) +* **eks:** default capacity uses desiredCapacity which is an anti-pattern ([#5651](https://github.com/aws/aws-cdk/issues/5651)) ([a883fed](https://github.com/aws/aws-cdk/commit/a883fed02a520068221c91ea3755cf63dd493f4e)), closes [#5215](https://github.com/aws/aws-cdk/issues/5215) [#5507](https://github.com/aws/aws-cdk/issues/5507) [#5650](https://github.com/aws/aws-cdk/issues/5650) +* **eks:** failures when creating or updating clusters ([#5540](https://github.com/aws/aws-cdk/issues/5540)) ([a13cfe6](https://github.com/aws/aws-cdk/commit/a13cfe683412f81198f65aa7639d52100ce3aa17)), closes [#5544](https://github.com/aws/aws-cdk/issues/5544) [#4087](https://github.com/aws/aws-cdk/issues/4087) [#4695](https://github.com/aws/aws-cdk/issues/4695) [#5259](https://github.com/aws/aws-cdk/issues/5259) [#5501](https://github.com/aws/aws-cdk/issues/5501) +* **eks:** generated cluster name can exceed 100 characters ([#5597](https://github.com/aws/aws-cdk/issues/5597)) ([3256a41](https://github.com/aws/aws-cdk/commit/3256a41787c365a67b01bee193bd75e48645f7a0)), closes [#5596](https://github.com/aws/aws-cdk/issues/5596) +* **eks:** kubernetes cannot create external load balancers ([#5448](https://github.com/aws/aws-cdk/issues/5448)) ([384d22d](https://github.com/aws/aws-cdk/commit/384d22da7198c1885df019e3cf985c16c59a825b)), closes [#5443](https://github.com/aws/aws-cdk/issues/5443) +* **iam:** policy added to resource for immutable Role ([#5568](https://github.com/aws/aws-cdk/issues/5568)) ([950a5f7](https://github.com/aws/aws-cdk/commit/950a5f76185f7e1197f006535d2638c6e79db2d2)) +* **java:** resolve Java class naming error ([#5602](https://github.com/aws/aws-cdk/issues/5602)) ([e9ede13](https://github.com/aws/aws-cdk/commit/e9ede138b7681115f1fdf9e60b710fabd5bf14b4)) +* **rds:** do not allow aurora engines when using DatabaseInstance ([#5367](https://github.com/aws/aws-cdk/issues/5367)) ([03b3b7a](https://github.com/aws/aws-cdk/commit/03b3b7a9ea0f8449e60d46370e9e4daec81d7c54)), closes [#5345](https://github.com/aws/aws-cdk/issues/5345) +* **s3n:** s3n lambda destination works with function by arn ([#5599](https://github.com/aws/aws-cdk/issues/5599)) ([7ceee6d](https://github.com/aws/aws-cdk/commit/7ceee6dacc268a3e2daecbec254c59886d28add6)), closes [#5592](https://github.com/aws/aws-cdk/issues/5592) +* **stepfunctions:** permission race condition on state machine deletion ([#5466](https://github.com/aws/aws-cdk/issues/5466)) ([c3ac965](https://github.com/aws/aws-cdk/commit/c3ac965b5c4cb816e9ecc974b741dc7e29fb86b1)), closes [#5336](https://github.com/aws/aws-cdk/issues/5336) +* **tests:** flaky integration tests in release pipeline ([#5485](https://github.com/aws/aws-cdk/issues/5485)) ([01800cf](https://github.com/aws/aws-cdk/commit/01800cfd848b84a3d7646738128946ef58eebf60)) +* increase IAM wait timeout in integ test ([#5504](https://github.com/aws/aws-cdk/issues/5504)) ([f10b3e6](https://github.com/aws/aws-cdk/commit/f10b3e64feab9c9ccc78c9820dc99a8b6b0971ec)) + ## [1.19.0](https://github.com/aws/aws-cdk/compare/v1.18.0...v1.19.0) (2019-12-17) diff --git a/lerna.json b/lerna.json index 139d3202b1bf8..47c5cf69a3a3e 100644 --- a/lerna.json +++ b/lerna.json @@ -9,5 +9,5 @@ "tools/*" ], "rejectCycles": "true", - "version": "1.19.0" + "version": "1.21.0" } diff --git a/package.json b/package.json index 938fc89aefc26..72233f3f057c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aws-cdk", - "version": "1.19.0", + "version": "1.21.0", "private": true, "pkglint": { "include": "dependencies/node-version" diff --git a/packages/@aws-cdk/alexa-ask/package.json b/packages/@aws-cdk/alexa-ask/package.json index 87ba87f815189..ec2ceaa711636 100644 --- a/packages/@aws-cdk/alexa-ask/package.json +++ b/packages/@aws-cdk/alexa-ask/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/alexa-ask", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for Alexa::ASK", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/app-delivery/package.json b/packages/@aws-cdk/app-delivery/package.json index c369e6c6ad524..1351ffe28daea 100644 --- a/packages/@aws-cdk/app-delivery/package.json +++ b/packages/@aws-cdk/app-delivery/package.json @@ -1,7 +1,7 @@ { "name": "@aws-cdk/app-delivery", "description": "Continuous Integration / Continuous Delivery for CDK Applications", - "version": "1.19.0", + "version": "1.21.0", "main": "lib/index.js", "types": "lib/index.d.ts", "jsii": { @@ -40,24 +40,24 @@ "compat": "cdk-compat" }, "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-codepipeline-actions": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-codepipeline-actions": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "fast-check": "^1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "repository": { "type": "git", @@ -76,14 +76,14 @@ "cdk" ], "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-codepipeline-actions": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-codepipeline-actions": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -98,4 +98,4 @@ "docs-public-apis:@aws-cdk/app-delivery.PipelineDeployStackActionProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/assert/README.md b/packages/@aws-cdk/assert/README.md index d3db7d3a96c23..ff04c0e985828 100644 --- a/packages/@aws-cdk/assert/README.md +++ b/packages/@aws-cdk/assert/README.md @@ -79,3 +79,25 @@ expect(stack).to(haveResource('AWS::CertificateManager::Certificate', { // Note: some properties omitted here })); ``` +### Check existence of an output +`haveOutput` assertion can be used to check that a stack contains specific output. +Parameters to check against can be: +- `outputName` +- `outputValue` +- `exportName` + +If `outputValue` is provided, at least one of `outputName`, `exportName` should be provided as well + +Example +```ts +expect(synthStack).to(haveOutput({ + outputName: 'TestOutputName', + exportName: 'TestOutputExportName', + outputValue: { + 'Fn::GetAtt': [ + 'TestResource', + 'Arn' + ] + } +})); +``` diff --git a/packages/@aws-cdk/assert/jest.ts b/packages/@aws-cdk/assert/jest.ts index d5715364652a7..78fa8fab38d90 100644 --- a/packages/@aws-cdk/assert/jest.ts +++ b/packages/@aws-cdk/assert/jest.ts @@ -1,8 +1,11 @@ -import { Stack } from "@aws-cdk/core"; +import { Stack } from '@aws-cdk/core'; import * as cxapi from '@aws-cdk/cx-api'; -import { HaveResourceAssertion, ResourcePart } from "./lib/assertions/have-resource"; -import { MatchStyle, matchTemplate } from "./lib/assertions/match-template"; +import { JestFriendlyAssertion } from './lib/assertion'; +import { haveOutput, HaveOutputProperties } from './lib/assertions/have-output'; +import { HaveResourceAssertion, ResourcePart } from './lib/assertions/have-resource'; +import { MatchStyle, matchTemplate } from './lib/assertions/match-template'; import { expect as ourExpect } from './lib/expect'; +import { StackInspector } from './lib/inspector'; declare global { namespace jest { @@ -17,6 +20,8 @@ declare global { toHaveResourceLike(resourceType: string, properties?: any, comparison?: ResourcePart): R; + + toHaveOutput(props: HaveOutputProperties): R; } } } @@ -50,8 +55,9 @@ expect.extend({ comparison?: ResourcePart) { const assertion = new HaveResourceAssertion(resourceType, properties, comparison, false); - return assertHaveResource(assertion, actual); + return applyAssertion(assertion, actual); }, + toHaveResourceLike( actual: cxapi.CloudFormationStackArtifact | Stack, resourceType: string, @@ -59,11 +65,18 @@ expect.extend({ comparison?: ResourcePart) { const assertion = new HaveResourceAssertion(resourceType, properties, comparison, true); - return assertHaveResource(assertion, actual); + return applyAssertion(assertion, actual); + }, + + toHaveOutput( + actual: cxapi.CloudFormationStackArtifact | Stack, + props: HaveOutputProperties) { + + return applyAssertion(haveOutput(props), actual); } }); -function assertHaveResource(assertion: HaveResourceAssertion, actual: cxapi.CloudFormationStackArtifact | Stack) { +function applyAssertion(assertion: JestFriendlyAssertion, actual: cxapi.CloudFormationStackArtifact | Stack) { const inspector = ourExpect(actual); const pass = assertion.assertUsing(inspector); if (pass) { diff --git a/packages/@aws-cdk/assert/lib/assertion.ts b/packages/@aws-cdk/assert/lib/assertion.ts index d193a6856c27e..57ef3ca759e78 100644 --- a/packages/@aws-cdk/assert/lib/assertion.ts +++ b/packages/@aws-cdk/assert/lib/assertion.ts @@ -20,6 +20,13 @@ export abstract class Assertion { } } +export abstract class JestFriendlyAssertion extends Assertion { + /** + * Generates an error message that can be used by Jest. + */ + public abstract generateErrorMessage(): string; +} + import { AndAssertion } from "./assertions/and-assertion"; function and(left: Assertion, right: Assertion): Assertion { diff --git a/packages/@aws-cdk/assert/lib/assertions/have-output.ts b/packages/@aws-cdk/assert/lib/assertions/have-output.ts new file mode 100644 index 0000000000000..36f76b3e573a0 --- /dev/null +++ b/packages/@aws-cdk/assert/lib/assertions/have-output.ts @@ -0,0 +1,116 @@ +import { JestFriendlyAssertion } from '../assertion'; +import { StackInspector } from '../inspector'; + +class HaveOutputAssertion extends JestFriendlyAssertion { + private readonly inspected: InspectionFailure[] = []; + + constructor(private readonly outputName?: string, private readonly exportName?: any, private outputValue?: any) { + super(); + if (!this.outputName && !this.exportName) { + throw new Error('At least one of [outputName, exportName] should be provided'); + } + } + + public get description(): string { + const descriptionPartsArray = new Array(); + + if (this.outputName) { + descriptionPartsArray.push(`name '${this.outputName}'`); + } + if (this.exportName) { + descriptionPartsArray.push(`export name ${JSON.stringify(this.exportName)}`); + } + if (this.outputValue) { + descriptionPartsArray.push(`value ${JSON.stringify(this.outputValue)}`); + } + + return 'output with ' + descriptionPartsArray.join(', '); + } + + public assertUsing(inspector: StackInspector): boolean { + if (!('Outputs' in inspector.value)) { + return false; + } + + for (const [name, props] of Object.entries(inspector.value.Outputs as Record)) { + const mismatchedFields = new Array(); + + if (this.outputName && name !== this.outputName) { + mismatchedFields.push('name'); + } + + if (this.exportName && JSON.stringify(this.exportName) !== JSON.stringify(props.Export?.Name)) { + mismatchedFields.push('export name'); + } + + if (this.outputValue && JSON.stringify(this.outputValue) !== JSON.stringify(props.Value)) { + mismatchedFields.push('value'); + } + + if (mismatchedFields.length === 0) { + return true; + } + + this.inspected.push({ + output: { [name]: props }, + failureReason: `mismatched ${mismatchedFields.join(', ')}`, + }); + } + + return false; + } + + public generateErrorMessage() { + const lines = new Array(); + + lines.push(`None of ${this.inspected.length} outputs matches ${this.description}.`); + + for (const inspected of this.inspected) { + lines.push(`- ${inspected.failureReason} in:`); + lines.push(indent(4, JSON.stringify(inspected.output, null, 2))); + } + + return lines.join('\n'); + } +} + +/** + * Interface for haveOutput function properties + * NOTE that at least one of [outputName, exportName] should be provided + */ +export interface HaveOutputProperties { + /** + * Logical ID of the output + * @default - the logical ID of the output will not be checked + */ + outputName?: string; + /** + * Export name of the output, when it's exported for cross-stack referencing + * @default - the export name is not required and will not be checked + */ + exportName?: any; + /** + * Value of the output; + * @default - the value will not be checked + */ + outputValue?: any; +} + +interface InspectionFailure { + output: any; + failureReason: string; +} + +/** + * An assertion to check whether Output with particular properties is present in a stack + * @param props properties of the Output that is being asserted against. + * Check ``HaveOutputProperties`` interface to get full list of available parameters + */ +export function haveOutput(props: HaveOutputProperties): JestFriendlyAssertion { + return new HaveOutputAssertion(props.outputName, props.exportName, props.outputValue); +} + +function indent(n: number, s: string) { + const prefix = ' '.repeat(n); + return prefix + s.replace(/\n/g, '\n' + prefix); +} diff --git a/packages/@aws-cdk/assert/lib/assertions/have-resource.ts b/packages/@aws-cdk/assert/lib/assertions/have-resource.ts index d6653f3b64ce6..ce94e152ab5ac 100644 --- a/packages/@aws-cdk/assert/lib/assertions/have-resource.ts +++ b/packages/@aws-cdk/assert/lib/assertions/have-resource.ts @@ -1,4 +1,4 @@ -import { Assertion } from "../assertion"; +import { Assertion, JestFriendlyAssertion } from "../assertion"; import { StackInspector } from "../inspector"; /** @@ -30,8 +30,8 @@ export function haveResourceLike(resourceType: string, type PropertyPredicate = (props: any, inspection: InspectionFailure) => boolean; -export class HaveResourceAssertion extends Assertion { - private inspected: InspectionFailure[] = []; +export class HaveResourceAssertion extends JestFriendlyAssertion { + private readonly inspected: InspectionFailure[] = []; private readonly part: ResourcePart; private readonly predicate: PropertyPredicate; diff --git a/packages/@aws-cdk/assert/lib/index.ts b/packages/@aws-cdk/assert/lib/index.ts index b79d93592affc..ff3516dc2f6fd 100644 --- a/packages/@aws-cdk/assert/lib/index.ts +++ b/packages/@aws-cdk/assert/lib/index.ts @@ -4,6 +4,7 @@ export * from './inspector'; export * from './synth-utils'; export * from './assertions/exist'; +export * from './assertions/have-output'; export * from './assertions/have-resource'; export * from './assertions/have-type'; export * from './assertions/match-template'; diff --git a/packages/@aws-cdk/assert/package.json b/packages/@aws-cdk/assert/package.json index d485dc658a68f..8c289aa0f194e 100644 --- a/packages/@aws-cdk/assert/package.json +++ b/packages/@aws-cdk/assert/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/assert", - "version": "1.19.0", + "version": "1.21.0", "description": "An assertion library for use with CDK Apps", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -23,9 +23,8 @@ ], "coverageThreshold": { "global": { - "statements": 80, - "lines": 80, - "branches": 60 + "statements": 75, + "branches": 65 } }, "preset": "ts-jest", @@ -41,16 +40,16 @@ }, "license": "Apache-2.0", "devDependencies": { - "@types/jest": "^24.0.25", - "cdk-build-tools": "1.19.0", + "@types/jest": "^24.9.0", + "cdk-build-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0", - "ts-jest": "^24.2.0" + "pkglint": "1.21.0", + "ts-jest": "^24.3.0" }, "dependencies": { - "@aws-cdk/cloudformation-diff": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/cloudformation-diff": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "peerDependencies": { "jest": "^24.9.0" diff --git a/packages/@aws-cdk/assert/test/have-output.test.ts b/packages/@aws-cdk/assert/test/have-output.test.ts new file mode 100644 index 0000000000000..71dfd9015c89c --- /dev/null +++ b/packages/@aws-cdk/assert/test/have-output.test.ts @@ -0,0 +1,201 @@ +import * as cxapi from '@aws-cdk/cx-api'; +import { unlink, writeFileSync } from 'fs'; +import { join } from 'path'; +import '../jest'; + +let templateFilePath: string; +let synthStack: cxapi.CloudFormationStackArtifact; +let noOutputStack: cxapi.CloudFormationStackArtifact; + +beforeEach(done => { + synthStack = mkStack({ + Resources: { + SomeResource: { + Type: 'Some::Resource', + Properties: { + PropA: 'somevalue' + } + }, + AnotherResource: { + Type: 'Some::AnotherResource', + Properties: { + PropA: 'anothervalue' + } + } + }, + Outputs: { + TestOutput: { + Value: { + 'Fn::GetAtt': [ + 'SomeResource', + 'Arn' + ] + }, + Export: { + Name: 'TestOutputExportName' + } + }, + ComplexExportNameOutput: { + Value: { + 'Fn::GetAtt': [ + 'ComplexOutputResource', + 'Arn' + ] + }, + Export: { + Name: { + "Fn::Sub": "${AWS::StackName}-ComplexExportNameOutput" + } + } + } + } + }); + noOutputStack = mkStack({ + Resources: { + SomeResource: { + Type: 'Some::Resource', + Properties: { + PropA: 'somevalue' + } + } + } + }); + done(); +}); + +test('haveOutput should assert true when output with correct name is provided', () => { + expect(synthStack).toHaveOutput({ + outputName: 'TestOutput' + }); +}); + +test('haveOutput should assert false when output with incorrect name is provided', () => { + expect(synthStack).not.toHaveOutput({ + outputName: 'WrongOutput' + }); +}); + +test('haveOutput should assert true when output with correct name and export name is provided', () => { + expect(synthStack).toHaveOutput({ + outputName: 'TestOutput', + exportName: 'TestOutputExportName', + }); +}); + +test('haveOutput should assert false when output with correct name and incorrect export name is provided', () => { + expect(synthStack).not.toHaveOutput({ + outputName: 'TestOutput', + exportName: 'WrongTestOutputExportName', + }); +}); + +test('haveOutput should assert true when output with correct name, export name and value is provided', () => { + expect(synthStack).toHaveOutput({ + outputName: 'TestOutput', + exportName: 'TestOutputExportName', + outputValue: { + 'Fn::GetAtt': [ + 'SomeResource', + 'Arn' + ] + } + }); +}); + +test('haveOutput should assert false when output with correct name and export name and incorrect value is provided', () => { + expect(synthStack).not.toHaveOutput({ + outputName: 'TestOutput', + exportName: 'TestOutputExportName', + outputValue: 'SomeWrongValue' + }); +}); + +test('haveOutput should assert true when output with correct export name and value is provided', () => { + expect(synthStack).toHaveOutput({ + exportName: 'TestOutputExportName', + outputValue: { + 'Fn::GetAtt': [ + 'SomeResource', + 'Arn' + ] + } + }); +}); + +test('haveOutput should assert false when output with correct export name and incorrect value is provided', () => { + expect(synthStack).not.toHaveOutput({ + exportName: 'TestOutputExportName', + outputValue: 'WrongValue' + }); +}); + +test('haveOutput should assert true when output with correct output name and value is provided', () => { + expect(synthStack).toHaveOutput({ + outputName: 'TestOutput', + outputValue: { + 'Fn::GetAtt': [ + 'SomeResource', + 'Arn' + ] + } + }); +}); + +test('haveOutput should assert false when output with correct output name and incorrect value is provided', () => { + expect(synthStack).not.toHaveOutput({ + outputName: 'TestOutput', + outputValue: 'WrongValue' + }); +}); + +test('haveOutput should assert false when asserting against noOutputStack', () => { + expect(noOutputStack).not.toHaveOutput({ + outputName: 'TestOutputName', + exportName: 'TestExportName', + outputValue: 'TestOutputValue' + }); +}); + +test('haveOutput should throw Error when none of outputName and exportName is provided', () => { + expect(() => expect(synthStack).toHaveOutput({ outputValue: 'SomeValue' })) + .toThrow('At least one of [outputName, exportName] should be provided'); +}); + +test('haveOutput should be able to handle complex exportName values', () => { + expect(synthStack).toHaveOutput({ + exportName: {'Fn::Sub': '${AWS::StackName}-ComplexExportNameOutput'}, + outputValue: { + 'Fn::GetAtt': [ + 'ComplexOutputResource', + 'Arn' + ] + } + }); +}); + +afterEach(done => { + if (templateFilePath) { + unlink(templateFilePath, done); + } else { + done(); + } +}); + +function mkStack(template: any): cxapi.CloudFormationStackArtifact { + const templateFileName = 'test-have-output-template.json'; + const stackName = 'test-have-output'; + const assembly = new cxapi.CloudAssemblyBuilder(); + + assembly.addArtifact(stackName, { + type: cxapi.ArtifactType.AWS_CLOUDFORMATION_STACK, + environment: cxapi.EnvironmentUtils.format('123456789012', 'bermuda-triangle-1'), + properties: { + templateFile: templateFileName + } + }); + + templateFilePath = join(assembly.outdir, templateFileName); + writeFileSync(templateFilePath, JSON.stringify(template)); + + return assembly.buildAssembly().getStackByName(stackName); +} diff --git a/packages/@aws-cdk/assets/lib/fs/copy.ts b/packages/@aws-cdk/assets/lib/fs/copy.ts index 7fc66c9043aa0..01b6c19cc66a6 100644 --- a/packages/@aws-cdk/assets/lib/fs/copy.ts +++ b/packages/@aws-cdk/assets/lib/fs/copy.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import { CopyOptions } from './copy-options'; import { FollowMode } from './follow-mode'; +import { CopyOptions } from './options'; import { shouldExclude, shouldFollow } from './utils'; export function copyDirectory(srcDir: string, destDir: string, options: CopyOptions = { }, rootDir?: string) { diff --git a/packages/@aws-cdk/assets/lib/fs/fingerprint.ts b/packages/@aws-cdk/assets/lib/fs/fingerprint.ts index 085335bc64a70..6b3f653a95f34 100644 --- a/packages/@aws-cdk/assets/lib/fs/fingerprint.ts +++ b/packages/@aws-cdk/assets/lib/fs/fingerprint.ts @@ -1,8 +1,8 @@ import * as crypto from 'crypto'; import * as fs from 'fs'; import * as path from 'path'; -import { CopyOptions } from './copy-options'; import { FollowMode } from './follow-mode'; +import { FingerprintOptions } from './options'; import { shouldExclude, shouldFollow } from './utils'; const BUFFER_SIZE = 8 * 1024; @@ -10,14 +10,6 @@ const CTRL_SOH = '\x01'; const CTRL_SOT = '\x02'; const CTRL_ETX = '\x03'; -export interface FingerprintOptions extends CopyOptions { - /** - * Extra information to encode into the fingerprint (e.g. build instructions - * and other inputs) - */ - extra?: string; -} - /** * Produces fingerprint based on the contents of a single file or an entire directory tree. * @@ -31,7 +23,7 @@ export interface FingerprintOptions extends CopyOptions { */ export function fingerprint(fileOrDirectory: string, options: FingerprintOptions = { }) { const hash = crypto.createHash('sha256'); - _hashField(hash, 'options.extra', options.extra || ''); + _hashField(hash, 'options.extra', options.extraHash || ''); const follow = options.follow || FollowMode.EXTERNAL; _hashField(hash, 'options.follow', follow); diff --git a/packages/@aws-cdk/assets/lib/fs/index.ts b/packages/@aws-cdk/assets/lib/fs/index.ts index a66267535075d..a1a4c68a83cef 100644 --- a/packages/@aws-cdk/assets/lib/fs/index.ts +++ b/packages/@aws-cdk/assets/lib/fs/index.ts @@ -1,4 +1,4 @@ export * from './copy'; -export * from './copy-options'; export * from './fingerprint'; export * from './follow-mode'; +export * from './options'; diff --git a/packages/@aws-cdk/assets/lib/fs/copy-options.ts b/packages/@aws-cdk/assets/lib/fs/options.ts similarity index 55% rename from packages/@aws-cdk/assets/lib/fs/copy-options.ts rename to packages/@aws-cdk/assets/lib/fs/options.ts index ac8d8b5686f0d..727da36568502 100644 --- a/packages/@aws-cdk/assets/lib/fs/copy-options.ts +++ b/packages/@aws-cdk/assets/lib/fs/options.ts @@ -18,3 +18,16 @@ export interface CopyOptions { */ readonly exclude?: string[]; } + +/** + * Options related to calculating source hash. + */ +export interface FingerprintOptions extends CopyOptions { + /** + * Extra information to encode into the fingerprint (e.g. build instructions + * and other inputs) + * + * @default - hash is only based on source content + */ + readonly extraHash?: string; +} diff --git a/packages/@aws-cdk/assets/lib/index.ts b/packages/@aws-cdk/assets/lib/index.ts index fffa67ab1b17f..e2a67003867bd 100644 --- a/packages/@aws-cdk/assets/lib/index.ts +++ b/packages/@aws-cdk/assets/lib/index.ts @@ -1,4 +1,4 @@ -export * from './fs/copy-options'; +export * from './api'; export * from './fs/follow-mode'; +export * from './fs/options'; export * from './staging'; -export * from './api'; diff --git a/packages/@aws-cdk/assets/lib/staging.ts b/packages/@aws-cdk/assets/lib/staging.ts index b148647ac011d..0961b306c8629 100644 --- a/packages/@aws-cdk/assets/lib/staging.ts +++ b/packages/@aws-cdk/assets/lib/staging.ts @@ -2,9 +2,9 @@ import { Construct, ISynthesisSession } from '@aws-cdk/core'; import * as cxapi from '@aws-cdk/cx-api'; import * as fs from 'fs'; import * as path from 'path'; -import { copyDirectory, CopyOptions, fingerprint } from './fs'; +import { copyDirectory, fingerprint, FingerprintOptions } from './fs'; -export interface StagingProps extends CopyOptions { +export interface StagingProps extends FingerprintOptions { readonly sourcePath: string; } @@ -46,7 +46,7 @@ export class Staging extends Construct { */ public readonly sourceHash: string; - private readonly copyOptions: CopyOptions; + private readonly fingerprintOptions: FingerprintOptions; private readonly relativePath?: string; @@ -54,7 +54,7 @@ export class Staging extends Construct { super(scope, id); this.sourcePath = props.sourcePath; - this.copyOptions = props; + this.fingerprintOptions = props; this.sourceHash = fingerprint(this.sourcePath, props); const stagingDisabled = this.node.tryGetContext(cxapi.DISABLE_ASSET_STAGING_CONTEXT); @@ -84,7 +84,7 @@ export class Staging extends Construct { fs.copyFileSync(this.sourcePath, targetPath); } else if (stat.isDirectory()) { fs.mkdirSync(targetPath); - copyDirectory(this.sourcePath, targetPath, this.copyOptions); + copyDirectory(this.sourcePath, targetPath, this.fingerprintOptions); } else { throw new Error(`Unknown file type: ${this.sourcePath}`); } diff --git a/packages/@aws-cdk/assets/package.json b/packages/@aws-cdk/assets/package.json index 421e5fcd61603..ab473771fc775 100644 --- a/packages/@aws-cdk/assets/package.json +++ b/packages/@aws-cdk/assets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/assets", - "version": "1.19.0", + "version": "1.21.0", "description": "Integration of CDK apps with local assets", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -63,27 +63,27 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/minimatch": "^3.0.3", "@types/nodeunit": "^0.0.30", "@types/sinon": "^7.5.0", - "aws-cdk": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "aws-cdk": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0", - "sinon": "^8.0.2", + "pkglint": "1.21.0", + "sinon": "^8.1.0", "ts-mock-imports": "^1.2.6" }, "dependencies": { - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0", "minimatch": "^3.0.4" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -99,4 +99,4 @@ "docs-public-apis:@aws-cdk/assets.FollowMode" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/assets/test/test.staging.ts b/packages/@aws-cdk/assets/test/test.staging.ts index 803af0a487b32..b1d3652a33211 100644 --- a/packages/@aws-cdk/assets/test/test.staging.ts +++ b/packages/@aws-cdk/assets/test/test.staging.ts @@ -57,5 +57,22 @@ export = { 'tree.json', ]); test.done(); + }, + + 'allow specifying extra data to include in the source hash'(test: Test) { + // GIVEN + const app = new App(); + const stack = new Stack(app, 'stack'); + const directory = path.join(__dirname, 'fs', 'fixtures', 'test1'); + + // WHEN + const withoutExtra = new Staging(stack, 'withoutExtra', { sourcePath: directory }); + const withExtra = new Staging(stack, 'withExtra', { sourcePath: directory, extraHash: 'boom' }); + + // THEN + test.notEqual(withoutExtra.sourceHash, withExtra.sourceHash); + test.deepEqual(withoutExtra.sourceHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00'); + test.deepEqual(withExtra.sourceHash, 'c95c915a5722bb9019e2c725d11868e5a619b55f36172f76bcbcaa8bb2d10c5f'); + test.done(); } }; diff --git a/packages/@aws-cdk/aws-accessanalyzer/package.json b/packages/@aws-cdk/aws-accessanalyzer/package.json index c895435c570fd..39d710301debc 100644 --- a/packages/@aws-cdk/aws-accessanalyzer/package.json +++ b/packages/@aws-cdk/aws-accessanalyzer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-accessanalyzer", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AccessAnalyzer", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amazonmq/package.json b/packages/@aws-cdk/aws-amazonmq/package.json index e2830728ad973..99c789cc9a58e 100644 --- a/packages/@aws-cdk/aws-amazonmq/package.json +++ b/packages/@aws-cdk/aws-amazonmq/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-amazonmq", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AmazonMQ", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-amplify/package.json b/packages/@aws-cdk/aws-amplify/package.json index 51bea99d1ee26..76ee03ad57ea6 100644 --- a/packages/@aws-cdk/aws-amplify/package.json +++ b/packages/@aws-cdk/aws-amplify/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-amplify", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Amplify", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/README.md b/packages/@aws-cdk/aws-apigateway/README.md index 0fd8dee131bd6..fb8b7df94acd4 100644 --- a/packages/@aws-cdk/aws-apigateway/README.md +++ b/packages/@aws-cdk/aws-apigateway/README.md @@ -484,7 +484,7 @@ CNAME records only for subdomains.) ```ts new route53.ARecord(this, 'CustomDomainAliasRecord', { zone: hostedZoneForExampleCom, - target: route53.AddressRecordTarget.fromAlias(new route53_targets.ApiGateway(api)) + target: route53.RecordTarget.fromAlias(new route53_targets.ApiGateway(api)) }); ``` @@ -527,7 +527,7 @@ If you wish to setup this domain with an Amazon Route53 alias, use the `route53_ ```ts new route53.ARecord(this, 'CustomDomainAliasRecord', { zone: hostedZoneForExampleCom, - target: route53.AddressRecordTarget.fromAlias(new route53_targets.ApiGatewayDomain(domainName)) + target: route53.RecordTarget.fromAlias(new route53_targets.ApiGatewayDomain(domainName)) }); ``` @@ -582,6 +582,15 @@ OPTIONS added to them. See [#906](https://github.com/aws/aws-cdk/issues/906) for a list of CORS features which are not yet supported. +## APIGateway v2 + +APIGateway v2 APIs are now moved to its own package named `aws-apigatewayv2`. For backwards compatibility, existing +APIGateway v2 "CFN resources" (such as `CfnApi`) that were previously exported as part of this package, are still +exported from here and have been marked deprecated. However, updates to these CloudFormation resources, such as new +properties and new resource types will not be available. + +Move to using `aws-apigatewayv2` to get the latest APIs and updates. + ---- This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. diff --git a/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts b/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts new file mode 100644 index 0000000000000..b77a261b063b5 --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/lib/apigatewayv2.ts @@ -0,0 +1,2939 @@ +// Copyright 2012-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// Originally generated from the AWS CloudFormation Resource Specification. Now, hand managed. + +// tslint:disable:max-line-length + +import * as cdk from '@aws-cdk/core'; + +/** + * Properties for defining a `AWS::ApiGatewayV2::Api` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnApiV2Props { + + /** + * `AWS::ApiGatewayV2::Api.ApiKeySelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-apikeyselectionexpression + */ + readonly apiKeySelectionExpression?: string; + + /** + * `AWS::ApiGatewayV2::Api.BasePath` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-basepath + */ + readonly basePath?: string; + + /** + * `AWS::ApiGatewayV2::Api.Body` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-body + */ + readonly body?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Api.BodyS3Location` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-bodys3location + */ + readonly bodyS3Location?: CfnApiV2.BodyS3LocationProperty | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Api.CorsConfiguration` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-corsconfiguration + */ + readonly corsConfiguration?: CfnApiV2.CorsProperty | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Api.CredentialsArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-credentialsarn + */ + readonly credentialsArn?: string; + + /** + * `AWS::ApiGatewayV2::Api.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-description + */ + readonly description?: string; + + /** + * `AWS::ApiGatewayV2::Api.DisableSchemaValidation` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-disableschemavalidation + */ + readonly disableSchemaValidation?: boolean | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Api.FailOnWarnings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-failonwarnings + */ + readonly failOnWarnings?: boolean | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Api.Name` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-name + */ + readonly name?: string; + + /** + * `AWS::ApiGatewayV2::Api.ProtocolType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-protocoltype + */ + readonly protocolType?: string; + + /** + * `AWS::ApiGatewayV2::Api.RouteKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-routekey + */ + readonly routeKey?: string; + + /** + * `AWS::ApiGatewayV2::Api.RouteSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-routeselectionexpression + */ + readonly routeSelectionExpression?: string; + + /** + * `AWS::ApiGatewayV2::Api.Tags` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-tags + */ + readonly tags?: any; + + /** + * `AWS::ApiGatewayV2::Api.Target` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-target + */ + readonly target?: string; + + /** + * `AWS::ApiGatewayV2::Api.Version` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-version + */ + readonly version?: string; +} + +/** + * Determine whether the given properties match those of a `CfnApiV2Props` + * + * @param properties - the TypeScript properties of a `CfnApiV2Props` + * + * @returns the result of the validation. + */ +function CfnApiV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiKeySelectionExpression', cdk.validateString)(properties.apiKeySelectionExpression)); + errors.collect(cdk.propertyValidator('basePath', cdk.validateString)(properties.basePath)); + errors.collect(cdk.propertyValidator('body', cdk.validateObject)(properties.body)); + errors.collect(cdk.propertyValidator('bodyS3Location', CfnApiV2_BodyS3LocationPropertyValidator)(properties.bodyS3Location)); + errors.collect(cdk.propertyValidator('corsConfiguration', CfnApiV2_CorsPropertyValidator)(properties.corsConfiguration)); + errors.collect(cdk.propertyValidator('credentialsArn', cdk.validateString)(properties.credentialsArn)); + errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description)); + errors.collect(cdk.propertyValidator('disableSchemaValidation', cdk.validateBoolean)(properties.disableSchemaValidation)); + errors.collect(cdk.propertyValidator('failOnWarnings', cdk.validateBoolean)(properties.failOnWarnings)); + errors.collect(cdk.propertyValidator('name', cdk.validateString)(properties.name)); + errors.collect(cdk.propertyValidator('protocolType', cdk.validateString)(properties.protocolType)); + errors.collect(cdk.propertyValidator('routeKey', cdk.validateString)(properties.routeKey)); + errors.collect(cdk.propertyValidator('routeSelectionExpression', cdk.validateString)(properties.routeSelectionExpression)); + errors.collect(cdk.propertyValidator('tags', cdk.validateObject)(properties.tags)); + errors.collect(cdk.propertyValidator('target', cdk.validateString)(properties.target)); + errors.collect(cdk.propertyValidator('version', cdk.validateString)(properties.version)); + return errors.wrap('supplied properties not correct for "CfnApiV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Api` resource + * + * @param properties - the TypeScript properties of a `CfnApiV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Api` resource. + */ +// @ts-ignore TS6133 +function cfnApiV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnApiV2PropsValidator(properties).assertSuccess(); + return { + ApiKeySelectionExpression: cdk.stringToCloudFormation(properties.apiKeySelectionExpression), + BasePath: cdk.stringToCloudFormation(properties.basePath), + Body: cdk.objectToCloudFormation(properties.body), + BodyS3Location: cfnApiV2BodyS3LocationPropertyToCloudFormation(properties.bodyS3Location), + CorsConfiguration: cfnApiV2CorsPropertyToCloudFormation(properties.corsConfiguration), + CredentialsArn: cdk.stringToCloudFormation(properties.credentialsArn), + Description: cdk.stringToCloudFormation(properties.description), + DisableSchemaValidation: cdk.booleanToCloudFormation(properties.disableSchemaValidation), + FailOnWarnings: cdk.booleanToCloudFormation(properties.failOnWarnings), + Name: cdk.stringToCloudFormation(properties.name), + ProtocolType: cdk.stringToCloudFormation(properties.protocolType), + RouteKey: cdk.stringToCloudFormation(properties.routeKey), + RouteSelectionExpression: cdk.stringToCloudFormation(properties.routeSelectionExpression), + Tags: cdk.objectToCloudFormation(properties.tags), + Target: cdk.stringToCloudFormation(properties.target), + Version: cdk.stringToCloudFormation(properties.version), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Api` + * + * @cloudformationResource AWS::ApiGatewayV2::Api + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnApiV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Api"; + + /** + * `AWS::ApiGatewayV2::Api.ApiKeySelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-apikeyselectionexpression + */ + public apiKeySelectionExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.BasePath` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-basepath + */ + public basePath: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.Body` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-body + */ + public body: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Api.BodyS3Location` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-bodys3location + */ + public bodyS3Location: CfnApiV2.BodyS3LocationProperty | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Api.CorsConfiguration` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-corsconfiguration + */ + public corsConfiguration: CfnApiV2.CorsProperty | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Api.CredentialsArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-credentialsarn + */ + public credentialsArn: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-description + */ + public description: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.DisableSchemaValidation` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-disableschemavalidation + */ + public disableSchemaValidation: boolean | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Api.FailOnWarnings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-failonwarnings + */ + public failOnWarnings: boolean | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Api.Name` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-name + */ + public name: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.ProtocolType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-protocoltype + */ + public protocolType: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.RouteKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-routekey + */ + public routeKey: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.RouteSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-routeselectionexpression + */ + public routeSelectionExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.Tags` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-tags + */ + public readonly tags: cdk.TagManager; + + /** + * `AWS::ApiGatewayV2::Api.Target` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-target + */ + public target: string | undefined; + + /** + * `AWS::ApiGatewayV2::Api.Version` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-version + */ + public version: string | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::Api`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnApiV2Props = {}) { + super(scope, id, { type: CfnApiV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + + this.apiKeySelectionExpression = props.apiKeySelectionExpression; + this.basePath = props.basePath; + this.body = props.body; + this.bodyS3Location = props.bodyS3Location; + this.corsConfiguration = props.corsConfiguration; + this.credentialsArn = props.credentialsArn; + this.description = props.description; + this.disableSchemaValidation = props.disableSchemaValidation; + this.failOnWarnings = props.failOnWarnings; + this.name = props.name; + this.protocolType = props.protocolType; + this.routeKey = props.routeKey; + this.routeSelectionExpression = props.routeSelectionExpression; + this.tags = new cdk.TagManager(cdk.TagType.MAP, "AWS::ApiGatewayV2::Api", props.tags, { tagPropertyName: 'tags' }); + this.target = props.target; + this.version = props.version; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnApiV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiKeySelectionExpression: this.apiKeySelectionExpression, + basePath: this.basePath, + body: this.body, + bodyS3Location: this.bodyS3Location, + corsConfiguration: this.corsConfiguration, + credentialsArn: this.credentialsArn, + description: this.description, + disableSchemaValidation: this.disableSchemaValidation, + failOnWarnings: this.failOnWarnings, + name: this.name, + protocolType: this.protocolType, + routeKey: this.routeKey, + routeSelectionExpression: this.routeSelectionExpression, + tags: this.tags.renderTags(), + target: this.target, + version: this.version, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnApiV2PropsToCloudFormation(props); + } +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnApiV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface BodyS3LocationProperty { + /** + * `CfnApiV2.BodyS3LocationProperty.Bucket` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-bucket + */ + readonly bucket?: string; + /** + * `CfnApiV2.BodyS3LocationProperty.Etag` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-etag + */ + readonly etag?: string; + /** + * `CfnApiV2.BodyS3LocationProperty.Key` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-key + */ + readonly key?: string; + /** + * `CfnApiV2.BodyS3LocationProperty.Version` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-bodys3location.html#cfn-apigatewayv2-api-bodys3location-version + */ + readonly version?: string; + } +} + +/** + * Determine whether the given properties match those of a `BodyS3LocationProperty` + * + * @param properties - the TypeScript properties of a `BodyS3LocationProperty` + * + * @returns the result of the validation. + */ +function CfnApiV2_BodyS3LocationPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('bucket', cdk.validateString)(properties.bucket)); + errors.collect(cdk.propertyValidator('etag', cdk.validateString)(properties.etag)); + errors.collect(cdk.propertyValidator('key', cdk.validateString)(properties.key)); + errors.collect(cdk.propertyValidator('version', cdk.validateString)(properties.version)); + return errors.wrap('supplied properties not correct for "BodyS3LocationProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Api.BodyS3Location` resource + * + * @param properties - the TypeScript properties of a `BodyS3LocationProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Api.BodyS3Location` resource. + */ +// @ts-ignore TS6133 +function cfnApiV2BodyS3LocationPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnApiV2_BodyS3LocationPropertyValidator(properties).assertSuccess(); + return { + Bucket: cdk.stringToCloudFormation(properties.bucket), + Etag: cdk.stringToCloudFormation(properties.etag), + Key: cdk.stringToCloudFormation(properties.key), + Version: cdk.stringToCloudFormation(properties.version), + }; +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnApiV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface CorsProperty { + /** + * `CfnApiV2.CorsProperty.AllowCredentials` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html#cfn-apigatewayv2-api-cors-allowcredentials + */ + readonly allowCredentials?: boolean | cdk.IResolvable; + /** + * `CfnApiV2.CorsProperty.AllowHeaders` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html#cfn-apigatewayv2-api-cors-allowheaders + */ + readonly allowHeaders?: string[]; + /** + * `CfnApiV2.CorsProperty.AllowMethods` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html#cfn-apigatewayv2-api-cors-allowmethods + */ + readonly allowMethods?: string[]; + /** + * `CfnApiV2.CorsProperty.AllowOrigins` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html#cfn-apigatewayv2-api-cors-alloworigins + */ + readonly allowOrigins?: string[]; + /** + * `CfnApiV2.CorsProperty.ExposeHeaders` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html#cfn-apigatewayv2-api-cors-exposeheaders + */ + readonly exposeHeaders?: string[]; + /** + * `CfnApiV2.CorsProperty.MaxAge` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-api-cors.html#cfn-apigatewayv2-api-cors-maxage + */ + readonly maxAge?: number; + } +} + +/** + * Determine whether the given properties match those of a `CorsProperty` + * + * @param properties - the TypeScript properties of a `CorsProperty` + * + * @returns the result of the validation. + */ +function CfnApiV2_CorsPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('allowCredentials', cdk.validateBoolean)(properties.allowCredentials)); + errors.collect(cdk.propertyValidator('allowHeaders', cdk.listValidator(cdk.validateString))(properties.allowHeaders)); + errors.collect(cdk.propertyValidator('allowMethods', cdk.listValidator(cdk.validateString))(properties.allowMethods)); + errors.collect(cdk.propertyValidator('allowOrigins', cdk.listValidator(cdk.validateString))(properties.allowOrigins)); + errors.collect(cdk.propertyValidator('exposeHeaders', cdk.listValidator(cdk.validateString))(properties.exposeHeaders)); + errors.collect(cdk.propertyValidator('maxAge', cdk.validateNumber)(properties.maxAge)); + return errors.wrap('supplied properties not correct for "CorsProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Api.Cors` resource + * + * @param properties - the TypeScript properties of a `CorsProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Api.Cors` resource. + */ +// @ts-ignore TS6133 +function cfnApiV2CorsPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnApiV2_CorsPropertyValidator(properties).assertSuccess(); + return { + AllowCredentials: cdk.booleanToCloudFormation(properties.allowCredentials), + AllowHeaders: cdk.listMapper(cdk.stringToCloudFormation)(properties.allowHeaders), + AllowMethods: cdk.listMapper(cdk.stringToCloudFormation)(properties.allowMethods), + AllowOrigins: cdk.listMapper(cdk.stringToCloudFormation)(properties.allowOrigins), + ExposeHeaders: cdk.listMapper(cdk.stringToCloudFormation)(properties.exposeHeaders), + MaxAge: cdk.numberToCloudFormation(properties.maxAge), + }; +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::ApiMapping` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnApiMappingV2Props { + + /** + * `AWS::ApiGatewayV2::ApiMapping.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::ApiMapping.DomainName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-domainname + */ + readonly domainName: string; + + /** + * `AWS::ApiGatewayV2::ApiMapping.Stage` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-stage + */ + readonly stage: string; + + /** + * `AWS::ApiGatewayV2::ApiMapping.ApiMappingKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-apimappingkey + */ + readonly apiMappingKey?: string; +} + +/** + * Determine whether the given properties match those of a `CfnApiMappingV2Props` + * + * @param properties - the TypeScript properties of a `CfnApiMappingV2Props` + * + * @returns the result of the validation. + */ +function CfnApiMappingV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiMappingKey', cdk.validateString)(properties.apiMappingKey)); + errors.collect(cdk.propertyValidator('domainName', cdk.requiredValidator)(properties.domainName)); + errors.collect(cdk.propertyValidator('domainName', cdk.validateString)(properties.domainName)); + errors.collect(cdk.propertyValidator('stage', cdk.requiredValidator)(properties.stage)); + errors.collect(cdk.propertyValidator('stage', cdk.validateString)(properties.stage)); + return errors.wrap('supplied properties not correct for "CfnApiMappingV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::ApiMapping` resource + * + * @param properties - the TypeScript properties of a `CfnApiMappingV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::ApiMapping` resource. + */ +// @ts-ignore TS6133 +function cfnApiMappingV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnApiMappingV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + DomainName: cdk.stringToCloudFormation(properties.domainName), + Stage: cdk.stringToCloudFormation(properties.stage), + ApiMappingKey: cdk.stringToCloudFormation(properties.apiMappingKey), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::ApiMapping` + * + * @cloudformationResource AWS::ApiGatewayV2::ApiMapping + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnApiMappingV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::ApiMapping"; + + /** + * `AWS::ApiGatewayV2::ApiMapping.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::ApiMapping.DomainName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-domainname + */ + public domainName: string; + + /** + * `AWS::ApiGatewayV2::ApiMapping.Stage` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-stage + */ + public stage: string; + + /** + * `AWS::ApiGatewayV2::ApiMapping.ApiMappingKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-apimapping.html#cfn-apigatewayv2-apimapping-apimappingkey + */ + public apiMappingKey: string | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::ApiMapping`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnApiMappingV2Props) { + super(scope, id, { type: CfnApiMappingV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'domainName', this); + cdk.requireProperty(props, 'stage', this); + + this.apiId = props.apiId; + this.domainName = props.domainName; + this.stage = props.stage; + this.apiMappingKey = props.apiMappingKey; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnApiMappingV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + domainName: this.domainName, + stage: this.stage, + apiMappingKey: this.apiMappingKey, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnApiMappingV2PropsToCloudFormation(props); + } +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::Authorizer` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnAuthorizerV2Props { + + /** + * `AWS::ApiGatewayV2::Authorizer.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizertype + */ + readonly authorizerType: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.IdentitySource` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource + */ + readonly identitySource: string[]; + + /** + * `AWS::ApiGatewayV2::Authorizer.Name` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-name + */ + readonly name: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerCredentialsArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizercredentialsarn + */ + readonly authorizerCredentialsArn?: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerResultTtlInSeconds` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizerresultttlinseconds + */ + readonly authorizerResultTtlInSeconds?: number; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerUri` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizeruri + */ + readonly authorizerUri?: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.IdentityValidationExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identityvalidationexpression + */ + readonly identityValidationExpression?: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.JwtConfiguration` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-jwtconfiguration + */ + readonly jwtConfiguration?: CfnAuthorizerV2.JWTConfigurationProperty | cdk.IResolvable; +} + +/** + * Determine whether the given properties match those of a `CfnAuthorizerV2Props` + * + * @param properties - the TypeScript properties of a `CfnAuthorizerV2Props` + * + * @returns the result of the validation. + */ +function CfnAuthorizerV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('authorizerCredentialsArn', cdk.validateString)(properties.authorizerCredentialsArn)); + errors.collect(cdk.propertyValidator('authorizerResultTtlInSeconds', cdk.validateNumber)(properties.authorizerResultTtlInSeconds)); + errors.collect(cdk.propertyValidator('authorizerType', cdk.requiredValidator)(properties.authorizerType)); + errors.collect(cdk.propertyValidator('authorizerType', cdk.validateString)(properties.authorizerType)); + errors.collect(cdk.propertyValidator('authorizerUri', cdk.validateString)(properties.authorizerUri)); + errors.collect(cdk.propertyValidator('identitySource', cdk.requiredValidator)(properties.identitySource)); + errors.collect(cdk.propertyValidator('identitySource', cdk.listValidator(cdk.validateString))(properties.identitySource)); + errors.collect(cdk.propertyValidator('identityValidationExpression', cdk.validateString)(properties.identityValidationExpression)); + errors.collect(cdk.propertyValidator('jwtConfiguration', CfnAuthorizerV2_JWTConfigurationPropertyValidator)(properties.jwtConfiguration)); + errors.collect(cdk.propertyValidator('name', cdk.requiredValidator)(properties.name)); + errors.collect(cdk.propertyValidator('name', cdk.validateString)(properties.name)); + return errors.wrap('supplied properties not correct for "CfnAuthorizerV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Authorizer` resource + * + * @param properties - the TypeScript properties of a `CfnAuthorizerV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Authorizer` resource. + */ +// @ts-ignore TS6133 +function cfnAuthorizerV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnAuthorizerV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + AuthorizerType: cdk.stringToCloudFormation(properties.authorizerType), + IdentitySource: cdk.listMapper(cdk.stringToCloudFormation)(properties.identitySource), + Name: cdk.stringToCloudFormation(properties.name), + AuthorizerCredentialsArn: cdk.stringToCloudFormation(properties.authorizerCredentialsArn), + AuthorizerResultTtlInSeconds: cdk.numberToCloudFormation(properties.authorizerResultTtlInSeconds), + AuthorizerUri: cdk.stringToCloudFormation(properties.authorizerUri), + IdentityValidationExpression: cdk.stringToCloudFormation(properties.identityValidationExpression), + JwtConfiguration: cfnAuthorizerV2JWTConfigurationPropertyToCloudFormation(properties.jwtConfiguration), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Authorizer` + * + * @cloudformationResource AWS::ApiGatewayV2::Authorizer + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnAuthorizerV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Authorizer"; + + /** + * `AWS::ApiGatewayV2::Authorizer.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizertype + */ + public authorizerType: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.IdentitySource` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource + */ + public identitySource: string[]; + + /** + * `AWS::ApiGatewayV2::Authorizer.Name` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-name + */ + public name: string; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerCredentialsArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizercredentialsarn + */ + public authorizerCredentialsArn: string | undefined; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerResultTtlInSeconds` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizerresultttlinseconds + */ + public authorizerResultTtlInSeconds: number | undefined; + + /** + * `AWS::ApiGatewayV2::Authorizer.AuthorizerUri` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-authorizeruri + */ + public authorizerUri: string | undefined; + + /** + * `AWS::ApiGatewayV2::Authorizer.IdentityValidationExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identityvalidationexpression + */ + public identityValidationExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::Authorizer.JwtConfiguration` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-jwtconfiguration + */ + public jwtConfiguration: CfnAuthorizerV2.JWTConfigurationProperty | cdk.IResolvable | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::Authorizer`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnAuthorizerV2Props) { + super(scope, id, { type: CfnAuthorizerV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'authorizerType', this); + cdk.requireProperty(props, 'identitySource', this); + cdk.requireProperty(props, 'name', this); + + this.apiId = props.apiId; + this.authorizerType = props.authorizerType; + this.identitySource = props.identitySource; + this.name = props.name; + this.authorizerCredentialsArn = props.authorizerCredentialsArn; + this.authorizerResultTtlInSeconds = props.authorizerResultTtlInSeconds; + this.authorizerUri = props.authorizerUri; + this.identityValidationExpression = props.identityValidationExpression; + this.jwtConfiguration = props.jwtConfiguration; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnAuthorizerV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + authorizerType: this.authorizerType, + identitySource: this.identitySource, + name: this.name, + authorizerCredentialsArn: this.authorizerCredentialsArn, + authorizerResultTtlInSeconds: this.authorizerResultTtlInSeconds, + authorizerUri: this.authorizerUri, + identityValidationExpression: this.identityValidationExpression, + jwtConfiguration: this.jwtConfiguration, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnAuthorizerV2PropsToCloudFormation(props); + } +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnAuthorizerV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-authorizer-jwtconfiguration.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface JWTConfigurationProperty { + /** + * `CfnAuthorizerV2.JWTConfigurationProperty.Audience` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-authorizer-jwtconfiguration.html#cfn-apigatewayv2-authorizer-jwtconfiguration-audience + */ + readonly audience?: string[]; + /** + * `CfnAuthorizerV2.JWTConfigurationProperty.Issuer` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-authorizer-jwtconfiguration.html#cfn-apigatewayv2-authorizer-jwtconfiguration-issuer + */ + readonly issuer?: string; + } +} + +/** + * Determine whether the given properties match those of a `JWTConfigurationProperty` + * + * @param properties - the TypeScript properties of a `JWTConfigurationProperty` + * + * @returns the result of the validation. + */ +function CfnAuthorizerV2_JWTConfigurationPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('audience', cdk.listValidator(cdk.validateString))(properties.audience)); + errors.collect(cdk.propertyValidator('issuer', cdk.validateString)(properties.issuer)); + return errors.wrap('supplied properties not correct for "JWTConfigurationProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Authorizer.JWTConfiguration` resource + * + * @param properties - the TypeScript properties of a `JWTConfigurationProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Authorizer.JWTConfiguration` resource. + */ +// @ts-ignore TS6133 +function cfnAuthorizerV2JWTConfigurationPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnAuthorizerV2_JWTConfigurationPropertyValidator(properties).assertSuccess(); + return { + Audience: cdk.listMapper(cdk.stringToCloudFormation)(properties.audience), + Issuer: cdk.stringToCloudFormation(properties.issuer), + }; +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::Deployment` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnDeploymentV2Props { + + /** + * `AWS::ApiGatewayV2::Deployment.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html#cfn-apigatewayv2-deployment-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::Deployment.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html#cfn-apigatewayv2-deployment-description + */ + readonly description?: string; + + /** + * `AWS::ApiGatewayV2::Deployment.StageName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html#cfn-apigatewayv2-deployment-stagename + */ + readonly stageName?: string; +} + +/** + * Determine whether the given properties match those of a `CfnDeploymentV2Props` + * + * @param properties - the TypeScript properties of a `CfnDeploymentV2Props` + * + * @returns the result of the validation. + */ +function CfnDeploymentV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description)); + errors.collect(cdk.propertyValidator('stageName', cdk.validateString)(properties.stageName)); + return errors.wrap('supplied properties not correct for "CfnDeploymentV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Deployment` resource + * + * @param properties - the TypeScript properties of a `CfnDeploymentV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Deployment` resource. + */ +// @ts-ignore TS6133 +function cfnDeploymentV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnDeploymentV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + Description: cdk.stringToCloudFormation(properties.description), + StageName: cdk.stringToCloudFormation(properties.stageName), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Deployment` + * + * @cloudformationResource AWS::ApiGatewayV2::Deployment + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnDeploymentV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Deployment"; + + /** + * `AWS::ApiGatewayV2::Deployment.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html#cfn-apigatewayv2-deployment-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::Deployment.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html#cfn-apigatewayv2-deployment-description + */ + public description: string | undefined; + + /** + * `AWS::ApiGatewayV2::Deployment.StageName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html#cfn-apigatewayv2-deployment-stagename + */ + public stageName: string | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::Deployment`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnDeploymentV2Props) { + super(scope, id, { type: CfnDeploymentV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + + this.apiId = props.apiId; + this.description = props.description; + this.stageName = props.stageName; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnDeploymentV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + description: this.description, + stageName: this.stageName, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnDeploymentV2PropsToCloudFormation(props); + } +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::DomainName` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnDomainNameV2Props { + + /** + * `AWS::ApiGatewayV2::DomainName.DomainName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-domainname + */ + readonly domainName: string; + + /** + * `AWS::ApiGatewayV2::DomainName.DomainNameConfigurations` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-domainnameconfigurations + */ + readonly domainNameConfigurations?: Array | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::DomainName.Tags` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-tags + */ + readonly tags?: any; +} + +/** + * Determine whether the given properties match those of a `CfnDomainNameV2Props` + * + * @param properties - the TypeScript properties of a `CfnDomainNameV2Props` + * + * @returns the result of the validation. + */ +function CfnDomainNameV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('domainName', cdk.requiredValidator)(properties.domainName)); + errors.collect(cdk.propertyValidator('domainName', cdk.validateString)(properties.domainName)); + errors.collect(cdk.propertyValidator('domainNameConfigurations', cdk.listValidator(CfnDomainNameV2_DomainNameConfigurationPropertyValidator))(properties.domainNameConfigurations)); + errors.collect(cdk.propertyValidator('tags', cdk.validateObject)(properties.tags)); + return errors.wrap('supplied properties not correct for "CfnDomainNameV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::DomainName` resource + * + * @param properties - the TypeScript properties of a `CfnDomainNameV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::DomainName` resource. + */ +// @ts-ignore TS6133 +function cfnDomainNameV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnDomainNameV2PropsValidator(properties).assertSuccess(); + return { + DomainName: cdk.stringToCloudFormation(properties.domainName), + DomainNameConfigurations: cdk.listMapper(cfnDomainNameV2DomainNameConfigurationPropertyToCloudFormation)(properties.domainNameConfigurations), + Tags: cdk.objectToCloudFormation(properties.tags), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::DomainName` + * + * @cloudformationResource AWS::ApiGatewayV2::DomainName + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnDomainNameV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::DomainName"; + + /** + * @cloudformationAttribute RegionalDomainName + */ + public readonly attrRegionalDomainName: string; + + /** + * @cloudformationAttribute RegionalHostedZoneId + */ + public readonly attrRegionalHostedZoneId: string; + + /** + * `AWS::ApiGatewayV2::DomainName.DomainName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-domainname + */ + public domainName: string; + + /** + * `AWS::ApiGatewayV2::DomainName.DomainNameConfigurations` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-domainnameconfigurations + */ + public domainNameConfigurations: Array | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::DomainName.Tags` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-domainname.html#cfn-apigatewayv2-domainname-tags + */ + public readonly tags: cdk.TagManager; + + /** + * Create a new `AWS::ApiGatewayV2::DomainName`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnDomainNameV2Props) { + super(scope, id, { type: CfnDomainNameV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'domainName', this); + this.attrRegionalDomainName = cdk.Token.asString(this.getAtt('RegionalDomainName')); + this.attrRegionalHostedZoneId = cdk.Token.asString(this.getAtt('RegionalHostedZoneId')); + + this.domainName = props.domainName; + this.domainNameConfigurations = props.domainNameConfigurations; + this.tags = new cdk.TagManager(cdk.TagType.MAP, "AWS::ApiGatewayV2::DomainName", props.tags, { tagPropertyName: 'tags' }); + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnDomainNameV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + domainName: this.domainName, + domainNameConfigurations: this.domainNameConfigurations, + tags: this.tags.renderTags(), + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnDomainNameV2PropsToCloudFormation(props); + } +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnDomainNameV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface DomainNameConfigurationProperty { + /** + * `CfnDomainNameV2.DomainNameConfigurationProperty.CertificateArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-certificatearn + */ + readonly certificateArn?: string; + /** + * `CfnDomainNameV2.DomainNameConfigurationProperty.CertificateName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-certificatename + */ + readonly certificateName?: string; + /** + * `CfnDomainNameV2.DomainNameConfigurationProperty.EndpointType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-endpointtype + */ + readonly endpointType?: string; + } +} + +/** + * Determine whether the given properties match those of a `DomainNameConfigurationProperty` + * + * @param properties - the TypeScript properties of a `DomainNameConfigurationProperty` + * + * @returns the result of the validation. + */ +function CfnDomainNameV2_DomainNameConfigurationPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('certificateArn', cdk.validateString)(properties.certificateArn)); + errors.collect(cdk.propertyValidator('certificateName', cdk.validateString)(properties.certificateName)); + errors.collect(cdk.propertyValidator('endpointType', cdk.validateString)(properties.endpointType)); + return errors.wrap('supplied properties not correct for "DomainNameConfigurationProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::DomainName.DomainNameConfiguration` resource + * + * @param properties - the TypeScript properties of a `DomainNameConfigurationProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::DomainName.DomainNameConfiguration` resource. + */ +// @ts-ignore TS6133 +function cfnDomainNameV2DomainNameConfigurationPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnDomainNameV2_DomainNameConfigurationPropertyValidator(properties).assertSuccess(); + return { + CertificateArn: cdk.stringToCloudFormation(properties.certificateArn), + CertificateName: cdk.stringToCloudFormation(properties.certificateName), + EndpointType: cdk.stringToCloudFormation(properties.endpointType), + }; +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::Integration` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnIntegrationV2Props { + + /** + * `AWS::ApiGatewayV2::Integration.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::Integration.IntegrationType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationtype + */ + readonly integrationType: string; + + /** + * `AWS::ApiGatewayV2::Integration.ConnectionType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-connectiontype + */ + readonly connectionType?: string; + + /** + * `AWS::ApiGatewayV2::Integration.ContentHandlingStrategy` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-contenthandlingstrategy + */ + readonly contentHandlingStrategy?: string; + + /** + * `AWS::ApiGatewayV2::Integration.CredentialsArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-credentialsarn + */ + readonly credentialsArn?: string; + + /** + * `AWS::ApiGatewayV2::Integration.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-description + */ + readonly description?: string; + + /** + * `AWS::ApiGatewayV2::Integration.IntegrationMethod` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationmethod + */ + readonly integrationMethod?: string; + + /** + * `AWS::ApiGatewayV2::Integration.IntegrationUri` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationuri + */ + readonly integrationUri?: string; + + /** + * `AWS::ApiGatewayV2::Integration.PassthroughBehavior` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-passthroughbehavior + */ + readonly passthroughBehavior?: string; + + /** + * `AWS::ApiGatewayV2::Integration.PayloadFormatVersion` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-payloadformatversion + */ + readonly payloadFormatVersion?: string; + + /** + * `AWS::ApiGatewayV2::Integration.RequestParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-requestparameters + */ + readonly requestParameters?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Integration.RequestTemplates` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-requesttemplates + */ + readonly requestTemplates?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Integration.TemplateSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-templateselectionexpression + */ + readonly templateSelectionExpression?: string; + + /** + * `AWS::ApiGatewayV2::Integration.TimeoutInMillis` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-timeoutinmillis + */ + readonly timeoutInMillis?: number; +} + +/** + * Determine whether the given properties match those of a `CfnIntegrationV2Props` + * + * @param properties - the TypeScript properties of a `CfnIntegrationV2Props` + * + * @returns the result of the validation. + */ +function CfnIntegrationV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('connectionType', cdk.validateString)(properties.connectionType)); + errors.collect(cdk.propertyValidator('contentHandlingStrategy', cdk.validateString)(properties.contentHandlingStrategy)); + errors.collect(cdk.propertyValidator('credentialsArn', cdk.validateString)(properties.credentialsArn)); + errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description)); + errors.collect(cdk.propertyValidator('integrationMethod', cdk.validateString)(properties.integrationMethod)); + errors.collect(cdk.propertyValidator('integrationType', cdk.requiredValidator)(properties.integrationType)); + errors.collect(cdk.propertyValidator('integrationType', cdk.validateString)(properties.integrationType)); + errors.collect(cdk.propertyValidator('integrationUri', cdk.validateString)(properties.integrationUri)); + errors.collect(cdk.propertyValidator('passthroughBehavior', cdk.validateString)(properties.passthroughBehavior)); + errors.collect(cdk.propertyValidator('payloadFormatVersion', cdk.validateString)(properties.payloadFormatVersion)); + errors.collect(cdk.propertyValidator('requestParameters', cdk.validateObject)(properties.requestParameters)); + errors.collect(cdk.propertyValidator('requestTemplates', cdk.validateObject)(properties.requestTemplates)); + errors.collect(cdk.propertyValidator('templateSelectionExpression', cdk.validateString)(properties.templateSelectionExpression)); + errors.collect(cdk.propertyValidator('timeoutInMillis', cdk.validateNumber)(properties.timeoutInMillis)); + return errors.wrap('supplied properties not correct for "CfnIntegrationV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Integration` resource + * + * @param properties - the TypeScript properties of a `CfnIntegrationV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Integration` resource. + */ +// @ts-ignore TS6133 +function cfnIntegrationV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnIntegrationV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + IntegrationType: cdk.stringToCloudFormation(properties.integrationType), + ConnectionType: cdk.stringToCloudFormation(properties.connectionType), + ContentHandlingStrategy: cdk.stringToCloudFormation(properties.contentHandlingStrategy), + CredentialsArn: cdk.stringToCloudFormation(properties.credentialsArn), + Description: cdk.stringToCloudFormation(properties.description), + IntegrationMethod: cdk.stringToCloudFormation(properties.integrationMethod), + IntegrationUri: cdk.stringToCloudFormation(properties.integrationUri), + PassthroughBehavior: cdk.stringToCloudFormation(properties.passthroughBehavior), + PayloadFormatVersion: cdk.stringToCloudFormation(properties.payloadFormatVersion), + RequestParameters: cdk.objectToCloudFormation(properties.requestParameters), + RequestTemplates: cdk.objectToCloudFormation(properties.requestTemplates), + TemplateSelectionExpression: cdk.stringToCloudFormation(properties.templateSelectionExpression), + TimeoutInMillis: cdk.numberToCloudFormation(properties.timeoutInMillis), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Integration` + * + * @cloudformationResource AWS::ApiGatewayV2::Integration + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnIntegrationV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Integration"; + + /** + * `AWS::ApiGatewayV2::Integration.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::Integration.IntegrationType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationtype + */ + public integrationType: string; + + /** + * `AWS::ApiGatewayV2::Integration.ConnectionType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-connectiontype + */ + public connectionType: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.ContentHandlingStrategy` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-contenthandlingstrategy + */ + public contentHandlingStrategy: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.CredentialsArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-credentialsarn + */ + public credentialsArn: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-description + */ + public description: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.IntegrationMethod` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationmethod + */ + public integrationMethod: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.IntegrationUri` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationuri + */ + public integrationUri: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.PassthroughBehavior` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-passthroughbehavior + */ + public passthroughBehavior: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.PayloadFormatVersion` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-payloadformatversion + */ + public payloadFormatVersion: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.RequestParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-requestparameters + */ + public requestParameters: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.RequestTemplates` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-requesttemplates + */ + public requestTemplates: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.TemplateSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-templateselectionexpression + */ + public templateSelectionExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::Integration.TimeoutInMillis` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-timeoutinmillis + */ + public timeoutInMillis: number | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::Integration`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnIntegrationV2Props) { + super(scope, id, { type: CfnIntegrationV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'integrationType', this); + + this.apiId = props.apiId; + this.integrationType = props.integrationType; + this.connectionType = props.connectionType; + this.contentHandlingStrategy = props.contentHandlingStrategy; + this.credentialsArn = props.credentialsArn; + this.description = props.description; + this.integrationMethod = props.integrationMethod; + this.integrationUri = props.integrationUri; + this.passthroughBehavior = props.passthroughBehavior; + this.payloadFormatVersion = props.payloadFormatVersion; + this.requestParameters = props.requestParameters; + this.requestTemplates = props.requestTemplates; + this.templateSelectionExpression = props.templateSelectionExpression; + this.timeoutInMillis = props.timeoutInMillis; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnIntegrationV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + integrationType: this.integrationType, + connectionType: this.connectionType, + contentHandlingStrategy: this.contentHandlingStrategy, + credentialsArn: this.credentialsArn, + description: this.description, + integrationMethod: this.integrationMethod, + integrationUri: this.integrationUri, + passthroughBehavior: this.passthroughBehavior, + payloadFormatVersion: this.payloadFormatVersion, + requestParameters: this.requestParameters, + requestTemplates: this.requestTemplates, + templateSelectionExpression: this.templateSelectionExpression, + timeoutInMillis: this.timeoutInMillis, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnIntegrationV2PropsToCloudFormation(props); + } +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::IntegrationResponse` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnIntegrationResponseV2Props { + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.IntegrationId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-integrationid + */ + readonly integrationId: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.IntegrationResponseKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-integrationresponsekey + */ + readonly integrationResponseKey: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ContentHandlingStrategy` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-contenthandlingstrategy + */ + readonly contentHandlingStrategy?: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ResponseParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-responseparameters + */ + readonly responseParameters?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ResponseTemplates` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-responsetemplates + */ + readonly responseTemplates?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.TemplateSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-templateselectionexpression + */ + readonly templateSelectionExpression?: string; +} + +/** + * Determine whether the given properties match those of a `CfnIntegrationResponseV2Props` + * + * @param properties - the TypeScript properties of a `CfnIntegrationResponseV2Props` + * + * @returns the result of the validation. + */ +function CfnIntegrationResponseV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('contentHandlingStrategy', cdk.validateString)(properties.contentHandlingStrategy)); + errors.collect(cdk.propertyValidator('integrationId', cdk.requiredValidator)(properties.integrationId)); + errors.collect(cdk.propertyValidator('integrationId', cdk.validateString)(properties.integrationId)); + errors.collect(cdk.propertyValidator('integrationResponseKey', cdk.requiredValidator)(properties.integrationResponseKey)); + errors.collect(cdk.propertyValidator('integrationResponseKey', cdk.validateString)(properties.integrationResponseKey)); + errors.collect(cdk.propertyValidator('responseParameters', cdk.validateObject)(properties.responseParameters)); + errors.collect(cdk.propertyValidator('responseTemplates', cdk.validateObject)(properties.responseTemplates)); + errors.collect(cdk.propertyValidator('templateSelectionExpression', cdk.validateString)(properties.templateSelectionExpression)); + return errors.wrap('supplied properties not correct for "CfnIntegrationResponseV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::IntegrationResponse` resource + * + * @param properties - the TypeScript properties of a `CfnIntegrationResponseV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::IntegrationResponse` resource. + */ +// @ts-ignore TS6133 +function cfnIntegrationResponseV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnIntegrationResponseV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + IntegrationId: cdk.stringToCloudFormation(properties.integrationId), + IntegrationResponseKey: cdk.stringToCloudFormation(properties.integrationResponseKey), + ContentHandlingStrategy: cdk.stringToCloudFormation(properties.contentHandlingStrategy), + ResponseParameters: cdk.objectToCloudFormation(properties.responseParameters), + ResponseTemplates: cdk.objectToCloudFormation(properties.responseTemplates), + TemplateSelectionExpression: cdk.stringToCloudFormation(properties.templateSelectionExpression), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::IntegrationResponse` + * + * @cloudformationResource AWS::ApiGatewayV2::IntegrationResponse + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnIntegrationResponseV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::IntegrationResponse"; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.IntegrationId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-integrationid + */ + public integrationId: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.IntegrationResponseKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-integrationresponsekey + */ + public integrationResponseKey: string; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ContentHandlingStrategy` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-contenthandlingstrategy + */ + public contentHandlingStrategy: string | undefined; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ResponseParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-responseparameters + */ + public responseParameters: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.ResponseTemplates` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-responsetemplates + */ + public responseTemplates: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::IntegrationResponse.TemplateSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html#cfn-apigatewayv2-integrationresponse-templateselectionexpression + */ + public templateSelectionExpression: string | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::IntegrationResponse`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnIntegrationResponseV2Props) { + super(scope, id, { type: CfnIntegrationResponseV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'integrationId', this); + cdk.requireProperty(props, 'integrationResponseKey', this); + + this.apiId = props.apiId; + this.integrationId = props.integrationId; + this.integrationResponseKey = props.integrationResponseKey; + this.contentHandlingStrategy = props.contentHandlingStrategy; + this.responseParameters = props.responseParameters; + this.responseTemplates = props.responseTemplates; + this.templateSelectionExpression = props.templateSelectionExpression; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnIntegrationResponseV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + integrationId: this.integrationId, + integrationResponseKey: this.integrationResponseKey, + contentHandlingStrategy: this.contentHandlingStrategy, + responseParameters: this.responseParameters, + responseTemplates: this.responseTemplates, + templateSelectionExpression: this.templateSelectionExpression, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnIntegrationResponseV2PropsToCloudFormation(props); + } +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::Model` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnModelV2Props { + + /** + * `AWS::ApiGatewayV2::Model.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::Model.Name` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-name + */ + readonly name: string; + + /** + * `AWS::ApiGatewayV2::Model.Schema` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-schema + */ + readonly schema: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Model.ContentType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-contenttype + */ + readonly contentType?: string; + + /** + * `AWS::ApiGatewayV2::Model.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-description + */ + readonly description?: string; +} + +/** + * Determine whether the given properties match those of a `CfnModelV2Props` + * + * @param properties - the TypeScript properties of a `CfnModelV2Props` + * + * @returns the result of the validation. + */ +function CfnModelV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('contentType', cdk.validateString)(properties.contentType)); + errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description)); + errors.collect(cdk.propertyValidator('name', cdk.requiredValidator)(properties.name)); + errors.collect(cdk.propertyValidator('name', cdk.validateString)(properties.name)); + errors.collect(cdk.propertyValidator('schema', cdk.requiredValidator)(properties.schema)); + errors.collect(cdk.propertyValidator('schema', cdk.validateObject)(properties.schema)); + return errors.wrap('supplied properties not correct for "CfnModelV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Model` resource + * + * @param properties - the TypeScript properties of a `CfnModelV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Model` resource. + */ +// @ts-ignore TS6133 +function cfnModelV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnModelV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + Name: cdk.stringToCloudFormation(properties.name), + Schema: cdk.objectToCloudFormation(properties.schema), + ContentType: cdk.stringToCloudFormation(properties.contentType), + Description: cdk.stringToCloudFormation(properties.description), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Model` + * + * @cloudformationResource AWS::ApiGatewayV2::Model + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnModelV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Model"; + + /** + * `AWS::ApiGatewayV2::Model.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::Model.Name` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-name + */ + public name: string; + + /** + * `AWS::ApiGatewayV2::Model.Schema` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-schema + */ + public schema: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Model.ContentType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-contenttype + */ + public contentType: string | undefined; + + /** + * `AWS::ApiGatewayV2::Model.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-model.html#cfn-apigatewayv2-model-description + */ + public description: string | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::Model`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnModelV2Props) { + super(scope, id, { type: CfnModelV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'name', this); + cdk.requireProperty(props, 'schema', this); + + this.apiId = props.apiId; + this.name = props.name; + this.schema = props.schema; + this.contentType = props.contentType; + this.description = props.description; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnModelV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + name: this.name, + schema: this.schema, + contentType: this.contentType, + description: this.description, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnModelV2PropsToCloudFormation(props); + } +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::Route` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnRouteV2Props { + + /** + * `AWS::ApiGatewayV2::Route.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::Route.RouteKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-routekey + */ + readonly routeKey: string; + + /** + * `AWS::ApiGatewayV2::Route.ApiKeyRequired` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-apikeyrequired + */ + readonly apiKeyRequired?: boolean | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Route.AuthorizationScopes` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-authorizationscopes + */ + readonly authorizationScopes?: string[]; + + /** + * `AWS::ApiGatewayV2::Route.AuthorizationType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-authorizationtype + */ + readonly authorizationType?: string; + + /** + * `AWS::ApiGatewayV2::Route.AuthorizerId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-authorizerid + */ + readonly authorizerId?: string; + + /** + * `AWS::ApiGatewayV2::Route.ModelSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-modelselectionexpression + */ + readonly modelSelectionExpression?: string; + + /** + * `AWS::ApiGatewayV2::Route.OperationName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-operationname + */ + readonly operationName?: string; + + /** + * `AWS::ApiGatewayV2::Route.RequestModels` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-requestmodels + */ + readonly requestModels?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Route.RequestParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-requestparameters + */ + readonly requestParameters?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Route.RouteResponseSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-routeresponseselectionexpression + */ + readonly routeResponseSelectionExpression?: string; + + /** + * `AWS::ApiGatewayV2::Route.Target` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-target + */ + readonly target?: string; +} + +/** + * Determine whether the given properties match those of a `CfnRouteV2Props` + * + * @param properties - the TypeScript properties of a `CfnRouteV2Props` + * + * @returns the result of the validation. + */ +function CfnRouteV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiKeyRequired', cdk.validateBoolean)(properties.apiKeyRequired)); + errors.collect(cdk.propertyValidator('authorizationScopes', cdk.listValidator(cdk.validateString))(properties.authorizationScopes)); + errors.collect(cdk.propertyValidator('authorizationType', cdk.validateString)(properties.authorizationType)); + errors.collect(cdk.propertyValidator('authorizerId', cdk.validateString)(properties.authorizerId)); + errors.collect(cdk.propertyValidator('modelSelectionExpression', cdk.validateString)(properties.modelSelectionExpression)); + errors.collect(cdk.propertyValidator('operationName', cdk.validateString)(properties.operationName)); + errors.collect(cdk.propertyValidator('requestModels', cdk.validateObject)(properties.requestModels)); + errors.collect(cdk.propertyValidator('requestParameters', cdk.validateObject)(properties.requestParameters)); + errors.collect(cdk.propertyValidator('routeKey', cdk.requiredValidator)(properties.routeKey)); + errors.collect(cdk.propertyValidator('routeKey', cdk.validateString)(properties.routeKey)); + errors.collect(cdk.propertyValidator('routeResponseSelectionExpression', cdk.validateString)(properties.routeResponseSelectionExpression)); + errors.collect(cdk.propertyValidator('target', cdk.validateString)(properties.target)); + return errors.wrap('supplied properties not correct for "CfnRouteV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Route` resource + * + * @param properties - the TypeScript properties of a `CfnRouteV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Route` resource. + */ +// @ts-ignore TS6133 +function cfnRouteV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnRouteV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + RouteKey: cdk.stringToCloudFormation(properties.routeKey), + ApiKeyRequired: cdk.booleanToCloudFormation(properties.apiKeyRequired), + AuthorizationScopes: cdk.listMapper(cdk.stringToCloudFormation)(properties.authorizationScopes), + AuthorizationType: cdk.stringToCloudFormation(properties.authorizationType), + AuthorizerId: cdk.stringToCloudFormation(properties.authorizerId), + ModelSelectionExpression: cdk.stringToCloudFormation(properties.modelSelectionExpression), + OperationName: cdk.stringToCloudFormation(properties.operationName), + RequestModels: cdk.objectToCloudFormation(properties.requestModels), + RequestParameters: cdk.objectToCloudFormation(properties.requestParameters), + RouteResponseSelectionExpression: cdk.stringToCloudFormation(properties.routeResponseSelectionExpression), + Target: cdk.stringToCloudFormation(properties.target), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Route` + * + * @cloudformationResource AWS::ApiGatewayV2::Route + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnRouteV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Route"; + + /** + * `AWS::ApiGatewayV2::Route.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::Route.RouteKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-routekey + */ + public routeKey: string; + + /** + * `AWS::ApiGatewayV2::Route.ApiKeyRequired` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-apikeyrequired + */ + public apiKeyRequired: boolean | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Route.AuthorizationScopes` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-authorizationscopes + */ + public authorizationScopes: string[] | undefined; + + /** + * `AWS::ApiGatewayV2::Route.AuthorizationType` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-authorizationtype + */ + public authorizationType: string | undefined; + + /** + * `AWS::ApiGatewayV2::Route.AuthorizerId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-authorizerid + */ + public authorizerId: string | undefined; + + /** + * `AWS::ApiGatewayV2::Route.ModelSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-modelselectionexpression + */ + public modelSelectionExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::Route.OperationName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-operationname + */ + public operationName: string | undefined; + + /** + * `AWS::ApiGatewayV2::Route.RequestModels` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-requestmodels + */ + public requestModels: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Route.RequestParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-requestparameters + */ + public requestParameters: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Route.RouteResponseSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-routeresponseselectionexpression + */ + public routeResponseSelectionExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::Route.Target` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html#cfn-apigatewayv2-route-target + */ + public target: string | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::Route`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnRouteV2Props) { + super(scope, id, { type: CfnRouteV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'routeKey', this); + + this.apiId = props.apiId; + this.routeKey = props.routeKey; + this.apiKeyRequired = props.apiKeyRequired; + this.authorizationScopes = props.authorizationScopes; + this.authorizationType = props.authorizationType; + this.authorizerId = props.authorizerId; + this.modelSelectionExpression = props.modelSelectionExpression; + this.operationName = props.operationName; + this.requestModels = props.requestModels; + this.requestParameters = props.requestParameters; + this.routeResponseSelectionExpression = props.routeResponseSelectionExpression; + this.target = props.target; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnRouteV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + routeKey: this.routeKey, + apiKeyRequired: this.apiKeyRequired, + authorizationScopes: this.authorizationScopes, + authorizationType: this.authorizationType, + authorizerId: this.authorizerId, + modelSelectionExpression: this.modelSelectionExpression, + operationName: this.operationName, + requestModels: this.requestModels, + requestParameters: this.requestParameters, + routeResponseSelectionExpression: this.routeResponseSelectionExpression, + target: this.target, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnRouteV2PropsToCloudFormation(props); + } +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnRouteV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-route-parameterconstraints.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface ParameterConstraintsProperty { + /** + * `CfnRouteV2.ParameterConstraintsProperty.Required` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-route-parameterconstraints.html#cfn-apigatewayv2-route-parameterconstraints-required + */ + readonly required: boolean | cdk.IResolvable; + } +} + +/** + * Determine whether the given properties match those of a `ParameterConstraintsProperty` + * + * @param properties - the TypeScript properties of a `ParameterConstraintsProperty` + * + * @returns the result of the validation. + */ +function CfnRouteV2_ParameterConstraintsPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('required', cdk.requiredValidator)(properties.required)); + errors.collect(cdk.propertyValidator('required', cdk.validateBoolean)(properties.required)); + return errors.wrap('supplied properties not correct for "ParameterConstraintsProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Route.ParameterConstraints` resource + * + * @param properties - the TypeScript properties of a `ParameterConstraintsProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Route.ParameterConstraints` resource. + */ +// @ts-ignore TS6133 +function cfnRouteV2ParameterConstraintsPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnRouteV2_ParameterConstraintsPropertyValidator(properties).assertSuccess(); + return { + Required: cdk.booleanToCloudFormation(properties.required), + }; +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::RouteResponse` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnRouteResponseV2Props { + + /** + * `AWS::ApiGatewayV2::RouteResponse.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.RouteId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-routeid + */ + readonly routeId: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.RouteResponseKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-routeresponsekey + */ + readonly routeResponseKey: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ModelSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-modelselectionexpression + */ + readonly modelSelectionExpression?: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ResponseModels` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-responsemodels + */ + readonly responseModels?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ResponseParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-responseparameters + */ + readonly responseParameters?: any | cdk.IResolvable; +} + +/** + * Determine whether the given properties match those of a `CfnRouteResponseV2Props` + * + * @param properties - the TypeScript properties of a `CfnRouteResponseV2Props` + * + * @returns the result of the validation. + */ +function CfnRouteResponseV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('modelSelectionExpression', cdk.validateString)(properties.modelSelectionExpression)); + errors.collect(cdk.propertyValidator('responseModels', cdk.validateObject)(properties.responseModels)); + errors.collect(cdk.propertyValidator('responseParameters', cdk.validateObject)(properties.responseParameters)); + errors.collect(cdk.propertyValidator('routeId', cdk.requiredValidator)(properties.routeId)); + errors.collect(cdk.propertyValidator('routeId', cdk.validateString)(properties.routeId)); + errors.collect(cdk.propertyValidator('routeResponseKey', cdk.requiredValidator)(properties.routeResponseKey)); + errors.collect(cdk.propertyValidator('routeResponseKey', cdk.validateString)(properties.routeResponseKey)); + return errors.wrap('supplied properties not correct for "CfnRouteResponseV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::RouteResponse` resource + * + * @param properties - the TypeScript properties of a `CfnRouteResponseV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::RouteResponse` resource. + */ +// @ts-ignore TS6133 +function cfnRouteResponseV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnRouteResponseV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + RouteId: cdk.stringToCloudFormation(properties.routeId), + RouteResponseKey: cdk.stringToCloudFormation(properties.routeResponseKey), + ModelSelectionExpression: cdk.stringToCloudFormation(properties.modelSelectionExpression), + ResponseModels: cdk.objectToCloudFormation(properties.responseModels), + ResponseParameters: cdk.objectToCloudFormation(properties.responseParameters), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::RouteResponse` + * + * @cloudformationResource AWS::ApiGatewayV2::RouteResponse + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnRouteResponseV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::RouteResponse"; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.RouteId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-routeid + */ + public routeId: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.RouteResponseKey` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-routeresponsekey + */ + public routeResponseKey: string; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ModelSelectionExpression` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-modelselectionexpression + */ + public modelSelectionExpression: string | undefined; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ResponseModels` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-responsemodels + */ + public responseModels: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::RouteResponse.ResponseParameters` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-routeresponse.html#cfn-apigatewayv2-routeresponse-responseparameters + */ + public responseParameters: any | cdk.IResolvable | undefined; + + /** + * Create a new `AWS::ApiGatewayV2::RouteResponse`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnRouteResponseV2Props) { + super(scope, id, { type: CfnRouteResponseV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'routeId', this); + cdk.requireProperty(props, 'routeResponseKey', this); + + this.apiId = props.apiId; + this.routeId = props.routeId; + this.routeResponseKey = props.routeResponseKey; + this.modelSelectionExpression = props.modelSelectionExpression; + this.responseModels = props.responseModels; + this.responseParameters = props.responseParameters; + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnRouteResponseV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + routeId: this.routeId, + routeResponseKey: this.routeResponseKey, + modelSelectionExpression: this.modelSelectionExpression, + responseModels: this.responseModels, + responseParameters: this.responseParameters, + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnRouteResponseV2PropsToCloudFormation(props); + } +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnRouteResponseV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-routeresponse-parameterconstraints.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface ParameterConstraintsProperty { + /** + * `CfnRouteResponseV2.ParameterConstraintsProperty.Required` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-routeresponse-parameterconstraints.html#cfn-apigatewayv2-routeresponse-parameterconstraints-required + */ + readonly required: boolean | cdk.IResolvable; + } +} + +/** + * Determine whether the given properties match those of a `ParameterConstraintsProperty` + * + * @param properties - the TypeScript properties of a `ParameterConstraintsProperty` + * + * @returns the result of the validation. + */ +function CfnRouteResponseV2_ParameterConstraintsPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('required', cdk.requiredValidator)(properties.required)); + errors.collect(cdk.propertyValidator('required', cdk.validateBoolean)(properties.required)); + return errors.wrap('supplied properties not correct for "ParameterConstraintsProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::RouteResponse.ParameterConstraints` resource + * + * @param properties - the TypeScript properties of a `ParameterConstraintsProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::RouteResponse.ParameterConstraints` resource. + */ +// @ts-ignore TS6133 +function cfnRouteResponseV2ParameterConstraintsPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnRouteResponseV2_ParameterConstraintsPropertyValidator(properties).assertSuccess(); + return { + Required: cdk.booleanToCloudFormation(properties.required), + }; +} + +/** + * Properties for defining a `AWS::ApiGatewayV2::Stage` + * + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html + * @deprecated moved to package aws-apigatewayv2 + */ +export interface CfnStageV2Props { + + /** + * `AWS::ApiGatewayV2::Stage.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-apiid + */ + readonly apiId: string; + + /** + * `AWS::ApiGatewayV2::Stage.StageName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagename + */ + readonly stageName: string; + + /** + * `AWS::ApiGatewayV2::Stage.AccessLogSettings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings + */ + readonly accessLogSettings?: CfnStageV2.AccessLogSettingsProperty | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Stage.AutoDeploy` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-autodeploy + */ + readonly autoDeploy?: boolean | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Stage.ClientCertificateId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-clientcertificateid + */ + readonly clientCertificateId?: string; + + /** + * `AWS::ApiGatewayV2::Stage.DefaultRouteSettings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-defaultroutesettings + */ + readonly defaultRouteSettings?: CfnStageV2.RouteSettingsProperty | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Stage.DeploymentId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-deploymentid + */ + readonly deploymentId?: string; + + /** + * `AWS::ApiGatewayV2::Stage.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-description + */ + readonly description?: string; + + /** + * `AWS::ApiGatewayV2::Stage.RouteSettings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings + */ + readonly routeSettings?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Stage.StageVariables` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables + */ + readonly stageVariables?: any | cdk.IResolvable; + + /** + * `AWS::ApiGatewayV2::Stage.Tags` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-tags + */ + readonly tags?: any; +} + +/** + * Determine whether the given properties match those of a `CfnStageV2Props` + * + * @param properties - the TypeScript properties of a `CfnStageV2Props` + * + * @returns the result of the validation. + */ +function CfnStageV2PropsValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('accessLogSettings', CfnStageV2_AccessLogSettingsPropertyValidator)(properties.accessLogSettings)); + errors.collect(cdk.propertyValidator('apiId', cdk.requiredValidator)(properties.apiId)); + errors.collect(cdk.propertyValidator('apiId', cdk.validateString)(properties.apiId)); + errors.collect(cdk.propertyValidator('autoDeploy', cdk.validateBoolean)(properties.autoDeploy)); + errors.collect(cdk.propertyValidator('clientCertificateId', cdk.validateString)(properties.clientCertificateId)); + errors.collect(cdk.propertyValidator('defaultRouteSettings', CfnStageV2_RouteSettingsPropertyValidator)(properties.defaultRouteSettings)); + errors.collect(cdk.propertyValidator('deploymentId', cdk.validateString)(properties.deploymentId)); + errors.collect(cdk.propertyValidator('description', cdk.validateString)(properties.description)); + errors.collect(cdk.propertyValidator('routeSettings', cdk.validateObject)(properties.routeSettings)); + errors.collect(cdk.propertyValidator('stageName', cdk.requiredValidator)(properties.stageName)); + errors.collect(cdk.propertyValidator('stageName', cdk.validateString)(properties.stageName)); + errors.collect(cdk.propertyValidator('stageVariables', cdk.validateObject)(properties.stageVariables)); + errors.collect(cdk.propertyValidator('tags', cdk.validateObject)(properties.tags)); + return errors.wrap('supplied properties not correct for "CfnStageV2Props"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Stage` resource + * + * @param properties - the TypeScript properties of a `CfnStageV2Props` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Stage` resource. + */ +// @ts-ignore TS6133 +function cfnStageV2PropsToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnStageV2PropsValidator(properties).assertSuccess(); + return { + ApiId: cdk.stringToCloudFormation(properties.apiId), + StageName: cdk.stringToCloudFormation(properties.stageName), + AccessLogSettings: cfnStageV2AccessLogSettingsPropertyToCloudFormation(properties.accessLogSettings), + AutoDeploy: cdk.booleanToCloudFormation(properties.autoDeploy), + ClientCertificateId: cdk.stringToCloudFormation(properties.clientCertificateId), + DefaultRouteSettings: cfnStageV2RouteSettingsPropertyToCloudFormation(properties.defaultRouteSettings), + DeploymentId: cdk.stringToCloudFormation(properties.deploymentId), + Description: cdk.stringToCloudFormation(properties.description), + RouteSettings: cdk.objectToCloudFormation(properties.routeSettings), + StageVariables: cdk.objectToCloudFormation(properties.stageVariables), + Tags: cdk.objectToCloudFormation(properties.tags), + }; +} + +/** + * A CloudFormation `AWS::ApiGatewayV2::Stage` + * + * @cloudformationResource AWS::ApiGatewayV2::Stage + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html + * @deprecated moved to package aws-apigatewayv2 + */ +export class CfnStageV2 extends cdk.CfnResource implements cdk.IInspectable { + /** + * The CloudFormation resource type name for this resource class. + */ + public static readonly CFN_RESOURCE_TYPE_NAME = "AWS::ApiGatewayV2::Stage"; + + /** + * `AWS::ApiGatewayV2::Stage.ApiId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-apiid + */ + public apiId: string; + + /** + * `AWS::ApiGatewayV2::Stage.StageName` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagename + */ + public stageName: string; + + /** + * `AWS::ApiGatewayV2::Stage.AccessLogSettings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-accesslogsettings + */ + public accessLogSettings: CfnStageV2.AccessLogSettingsProperty | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.AutoDeploy` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-autodeploy + */ + public autoDeploy: boolean | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.ClientCertificateId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-clientcertificateid + */ + public clientCertificateId: string | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.DefaultRouteSettings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-defaultroutesettings + */ + public defaultRouteSettings: CfnStageV2.RouteSettingsProperty | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.DeploymentId` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-deploymentid + */ + public deploymentId: string | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.Description` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-description + */ + public description: string | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.RouteSettings` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings + */ + public routeSettings: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.StageVariables` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-stagevariables + */ + public stageVariables: any | cdk.IResolvable | undefined; + + /** + * `AWS::ApiGatewayV2::Stage.Tags` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-tags + */ + public readonly tags: cdk.TagManager; + + /** + * Create a new `AWS::ApiGatewayV2::Stage`. + * + * @param scope - scope in which this resource is defined + * @param id - scoped id of the resource + * @param props - resource properties + */ + constructor(scope: cdk.Construct, id: string, props: CfnStageV2Props) { + super(scope, id, { type: CfnStageV2.CFN_RESOURCE_TYPE_NAME, properties: props }); + cdk.requireProperty(props, 'apiId', this); + cdk.requireProperty(props, 'stageName', this); + + this.apiId = props.apiId; + this.stageName = props.stageName; + this.accessLogSettings = props.accessLogSettings; + this.autoDeploy = props.autoDeploy; + this.clientCertificateId = props.clientCertificateId; + this.defaultRouteSettings = props.defaultRouteSettings; + this.deploymentId = props.deploymentId; + this.description = props.description; + this.routeSettings = props.routeSettings; + this.stageVariables = props.stageVariables; + this.tags = new cdk.TagManager(cdk.TagType.MAP, "AWS::ApiGatewayV2::Stage", props.tags, { tagPropertyName: 'tags' }); + } + + /** + * Examines the CloudFormation resource and discloses attributes. + * + * @param inspector - tree inspector to collect and process attributes + * + * @stability experimental + */ + public inspect(inspector: cdk.TreeInspector) { + inspector.addAttribute("aws:cdk:cloudformation:type", CfnStageV2.CFN_RESOURCE_TYPE_NAME); + inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties); + } + + protected get cfnProperties(): { [key: string]: any } { + return { + apiId: this.apiId, + stageName: this.stageName, + accessLogSettings: this.accessLogSettings, + autoDeploy: this.autoDeploy, + clientCertificateId: this.clientCertificateId, + defaultRouteSettings: this.defaultRouteSettings, + deploymentId: this.deploymentId, + description: this.description, + routeSettings: this.routeSettings, + stageVariables: this.stageVariables, + tags: this.tags.renderTags(), + }; + } + protected renderProperties(props: {[key: string]: any}): { [key: string]: any } { + return cfnStageV2PropsToCloudFormation(props); + } +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnStageV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-accesslogsettings.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface AccessLogSettingsProperty { + /** + * `CfnStageV2.AccessLogSettingsProperty.DestinationArn` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-accesslogsettings.html#cfn-apigatewayv2-stage-accesslogsettings-destinationarn + */ + readonly destinationArn?: string; + /** + * `CfnStageV2.AccessLogSettingsProperty.Format` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-accesslogsettings.html#cfn-apigatewayv2-stage-accesslogsettings-format + */ + readonly format?: string; + } +} + +/** + * Determine whether the given properties match those of a `AccessLogSettingsProperty` + * + * @param properties - the TypeScript properties of a `AccessLogSettingsProperty` + * + * @returns the result of the validation. + */ +function CfnStageV2_AccessLogSettingsPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('destinationArn', cdk.validateString)(properties.destinationArn)); + errors.collect(cdk.propertyValidator('format', cdk.validateString)(properties.format)); + return errors.wrap('supplied properties not correct for "AccessLogSettingsProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Stage.AccessLogSettings` resource + * + * @param properties - the TypeScript properties of a `AccessLogSettingsProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Stage.AccessLogSettings` resource. + */ +// @ts-ignore TS6133 +function cfnStageV2AccessLogSettingsPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnStageV2_AccessLogSettingsPropertyValidator(properties).assertSuccess(); + return { + DestinationArn: cdk.stringToCloudFormation(properties.destinationArn), + Format: cdk.stringToCloudFormation(properties.format), + }; +} + +/** + * @deprecated moved to package aws-apigatewayv2 + */ +export namespace CfnStageV2 { + /** + * @stability deprecated + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html + * @deprecated moved to package aws-apigatewayv2 + */ + export interface RouteSettingsProperty { + /** + * `CfnStageV2.RouteSettingsProperty.DataTraceEnabled` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html#cfn-apigatewayv2-stage-routesettings-datatraceenabled + */ + readonly dataTraceEnabled?: boolean | cdk.IResolvable; + /** + * `CfnStageV2.RouteSettingsProperty.DetailedMetricsEnabled` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html#cfn-apigatewayv2-stage-routesettings-detailedmetricsenabled + */ + readonly detailedMetricsEnabled?: boolean | cdk.IResolvable; + /** + * `CfnStageV2.RouteSettingsProperty.LoggingLevel` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html#cfn-apigatewayv2-stage-routesettings-logginglevel + */ + readonly loggingLevel?: string; + /** + * `CfnStageV2.RouteSettingsProperty.ThrottlingBurstLimit` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html#cfn-apigatewayv2-stage-routesettings-throttlingburstlimit + */ + readonly throttlingBurstLimit?: number; + /** + * `CfnStageV2.RouteSettingsProperty.ThrottlingRateLimit` + * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html#cfn-apigatewayv2-stage-routesettings-throttlingratelimit + */ + readonly throttlingRateLimit?: number; + } +} + +/** + * Determine whether the given properties match those of a `RouteSettingsProperty` + * + * @param properties - the TypeScript properties of a `RouteSettingsProperty` + * + * @returns the result of the validation. + */ +function CfnStageV2_RouteSettingsPropertyValidator(properties: any): cdk.ValidationResult { + if (!cdk.canInspect(properties)) { return cdk.VALIDATION_SUCCESS; } + const errors = new cdk.ValidationResults(); + errors.collect(cdk.propertyValidator('dataTraceEnabled', cdk.validateBoolean)(properties.dataTraceEnabled)); + errors.collect(cdk.propertyValidator('detailedMetricsEnabled', cdk.validateBoolean)(properties.detailedMetricsEnabled)); + errors.collect(cdk.propertyValidator('loggingLevel', cdk.validateString)(properties.loggingLevel)); + errors.collect(cdk.propertyValidator('throttlingBurstLimit', cdk.validateNumber)(properties.throttlingBurstLimit)); + errors.collect(cdk.propertyValidator('throttlingRateLimit', cdk.validateNumber)(properties.throttlingRateLimit)); + return errors.wrap('supplied properties not correct for "RouteSettingsProperty"'); +} + +/** + * Renders the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Stage.RouteSettings` resource + * + * @param properties - the TypeScript properties of a `RouteSettingsProperty` + * + * @returns the AWS CloudFormation properties of an `AWS::ApiGatewayV2::Stage.RouteSettings` resource. + */ +// @ts-ignore TS6133 +function cfnStageV2RouteSettingsPropertyToCloudFormation(properties: any): any { + if (!cdk.canInspect(properties)) { return properties; } + CfnStageV2_RouteSettingsPropertyValidator(properties).assertSuccess(); + return { + DataTraceEnabled: cdk.booleanToCloudFormation(properties.dataTraceEnabled), + DetailedMetricsEnabled: cdk.booleanToCloudFormation(properties.detailedMetricsEnabled), + LoggingLevel: cdk.stringToCloudFormation(properties.loggingLevel), + ThrottlingBurstLimit: cdk.numberToCloudFormation(properties.throttlingBurstLimit), + ThrottlingRateLimit: cdk.numberToCloudFormation(properties.throttlingRateLimit), + }; +} diff --git a/packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts b/packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts index ad222b627593e..5175407981186 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts @@ -13,7 +13,7 @@ export interface TokenAuthorizerProps { /** * An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer. * - * @default - none + * @default this.node.uniqueId */ readonly authorizerName?: string; @@ -92,7 +92,7 @@ export class TokenAuthorizer extends Authorizer implements IAuthorizer { const restApiId = Lazy.stringValue({ produce: () => this.restApiId }); const resource = new CfnAuthorizer(this, 'Resource', { - name: props.authorizerName, + name: props.authorizerName ?? this.node.uniqueId, restApiId, type: 'TOKEN', authorizerUri: `arn:aws:apigateway:${Stack.of(this).region}:lambda:path/2015-03-31/functions/${props.handler.functionArn}/invocations`, diff --git a/packages/@aws-cdk/aws-apigateway/lib/index.ts b/packages/@aws-cdk/aws-apigateway/lib/index.ts index 9b17ddf169fcb..3ce1a7901dd96 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/index.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/index.ts @@ -22,4 +22,4 @@ export * from './authorizers'; // AWS::ApiGateway CloudFormation Resources: export * from './apigateway.generated'; // AWS::ApiGatewayV2 CloudFormation resources: -export * from './apigatewayv2.generated'; +export * from './apigatewayv2'; diff --git a/packages/@aws-cdk/aws-apigateway/lib/restapi.ts b/packages/@aws-cdk/aws-apigateway/lib/restapi.ts index 25cf73991db69..a66bba21fbd22 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/restapi.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/restapi.ts @@ -212,13 +212,8 @@ export class RestApi extends Resource implements IRestApi { */ public deploymentStage!: Stage; - /** - * The domain name mapped to this API, if defined through the `domainName` - * configuration prop. - */ - public readonly domainName?: DomainName; - private readonly methods = new Array(); + private _domainName?: DomainName; private _latestDeployment: Deployment | undefined; constructor(scope: Construct, id: string, props: RestApiProps = { }) { @@ -253,10 +248,18 @@ export class RestApi extends Resource implements IRestApi { this.restApiRootResourceId = resource.attrRootResourceId; if (props.domainName) { - this.domainName = this.addDomainName('CustomDomain', props.domainName); + this.addDomainName('CustomDomain', props.domainName); } } + /** + * The first domain name mapped to this API, if defined through the `domainName` + * configuration prop, or added via `addDomainName` + */ + public get domainName() { + return this._domainName; + } + /** * API Gateway deployment that represents the latest changes of the API. * This resource will be automatically updated every time the REST API model changes. @@ -292,10 +295,14 @@ export class RestApi extends Resource implements IRestApi { * @param options custom domain options */ public addDomainName(id: string, options: DomainNameOptions): DomainName { - return new DomainName(this, id, { + const domainName = new DomainName(this, id, { ...options, mapping: this }); + if (!this._domainName) { + this._domainName = domainName; + } + return domainName; } /** diff --git a/packages/@aws-cdk/aws-apigateway/package.json b/packages/@aws-cdk/aws-apigateway/package.json index baf2be01515fe..22b40c08adf00 100644 --- a/packages/@aws-cdk/aws-apigateway/package.json +++ b/packages/@aws-cdk/aws-apigateway/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-apigateway", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ApiGateway", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -47,10 +47,7 @@ "compat": "cdk-compat" }, "cdk-build": { - "cloudformation": [ - "AWS::ApiGateway", - "AWS::ApiGatewayV2" - ] + "cloudformation": "AWS::ApiGateway" }, "keywords": [ "aws", @@ -65,33 +62,41 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, + "nyc": { + "exclude": [ + "coverage/**", + "test/**", + "lib/*.generated.js", + "lib/apigatewayv2.js" + ] + }, "awslint": { "exclude": [ "from-method:@aws-cdk/aws-apigateway.Resource", @@ -290,4 +295,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer-iam-role.expected.json b/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer-iam-role.expected.json index 702856a6922b3..d2c26cd1de4ba 100644 --- a/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer-iam-role.expected.json +++ b/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer-iam-role.expected.json @@ -105,6 +105,7 @@ "MyAuthorizer6575980E": { "Type": "AWS::ApiGateway::Authorizer", "Properties": { + "Name": "TokenAuthorizerIAMRoleIntegMyAuthorizer1DFDE3B5", "RestApiId": { "Ref": "MyRestApi2D1F47A9" }, diff --git a/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.expected.json b/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.expected.json index bfad9880b7040..60c98adf6e1d2 100644 --- a/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.expected.json +++ b/packages/@aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.expected.json @@ -199,6 +199,7 @@ "MyAuthorizer6575980E": { "Type": "AWS::ApiGateway::Authorizer", "Properties": { + "Name": "TokenAuthorizerIntegMyAuthorizer793B1D5F", "RestApiId": { "Ref": "MyRestApi2D1F47A9" }, diff --git a/packages/@aws-cdk/aws-apigateway/test/authorizers/test.lambda.ts b/packages/@aws-cdk/aws-apigateway/test/authorizers/test.lambda.ts index a2bbb570ceede..f58edf2657ced 100644 --- a/packages/@aws-cdk/aws-apigateway/test/authorizers/test.lambda.ts +++ b/packages/@aws-cdk/aws-apigateway/test/authorizers/test.lambda.ts @@ -12,7 +12,7 @@ export = { const func = new lambda.Function(stack, 'myfunction', { handler: 'handler', code: lambda.Code.fromInline('foo'), - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, }); const auth = new TokenAuthorizer(stack, 'myauthorizer', { @@ -47,7 +47,7 @@ export = { const func = new lambda.Function(stack, 'myfunction', { handler: 'handler', code: lambda.Code.fromInline('foo'), - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, }); const auth = new TokenAuthorizer(stack, 'myauthorizer', { @@ -82,7 +82,7 @@ export = { const func = new lambda.Function(stack, 'myfunction', { handler: 'handler', code: lambda.Code.fromInline('foo'), - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, }); const role = new iam.Role(stack, 'authorizerassumerole', { diff --git a/packages/@aws-cdk/aws-apigateway/test/test.domains.ts b/packages/@aws-cdk/aws-apigateway/test/test.domains.ts index 3591cf9558717..a285b472f3dd9 100644 --- a/packages/@aws-cdk/aws-apigateway/test/test.domains.ts +++ b/packages/@aws-cdk/aws-apigateway/test/test.domains.ts @@ -177,6 +177,112 @@ export = { } })); + test.done(); + }, + + 'a domain name can be added later'(test: Test) { + // GIVEN + const domainName = 'my.domain.com'; + const stack = new Stack(); + const certificate = new acm.Certificate(stack, 'cert', { domainName: 'my.domain.com' }); + + // WHEN + const api = new apigw.RestApi(stack, 'api', {}); + + api.root.addMethod('GET'); + + api.addDomainName('domainId', { domainName, certificate }); + + // THEN + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { + "DomainName": domainName, + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": { + "Ref": "cert56CA94EB" + } + })); + expect(stack).to(haveResource('AWS::ApiGateway::BasePathMapping', { + "DomainName": { + "Ref": "apidomainId102F8DAA" + }, + "RestApiId": { + "Ref": "apiC8550315" + }, + "Stage": { + "Ref": "apiDeploymentStageprod896C8101" + } + })); + + test.done(); + }, + + 'multiple domain names can be added'(test: Test) { + // GIVEN + const domainName = 'my.domain.com'; + const stack = new Stack(); + const certificate = new acm.Certificate(stack, 'cert', { domainName: 'my.domain.com' }); + + // WHEN + const api = new apigw.RestApi(stack, 'api', {}); + + api.root.addMethod('GET'); + + const domainName1 = api.addDomainName('domainId', { domainName, certificate }); + api.addDomainName('domainId1', { domainName: 'your.domain.com', certificate }); + api.addDomainName('domainId2', { domainName: 'our.domain.com', certificate }); + + test.deepEqual(api.domainName, domainName1); + + // THEN + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { + "DomainName": 'my.domain.com', + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": { + "Ref": "cert56CA94EB" + } + })); + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { + "DomainName": 'your.domain.com', + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": { + "Ref": "cert56CA94EB" + } + })); + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { + "DomainName": 'our.domain.com', + "EndpointConfiguration": { + "Types": [ + "REGIONAL" + ] + }, + "RegionalCertificateArn": { + "Ref": "cert56CA94EB" + } + })); + expect(stack).to(haveResource('AWS::ApiGateway::BasePathMapping', { + "DomainName": { + "Ref": "apidomainId102F8DAA" + }, + "RestApiId": { + "Ref": "apiC8550315" + }, + "Stage": { + "Ref": "apiDeploymentStageprod896C8101" + } + })); + test.done(); } }; diff --git a/packages/@aws-cdk/aws-apigateway/test/test.method.ts b/packages/@aws-cdk/aws-apigateway/test/test.method.ts index 612e10c7d3144..ef799d8c65225 100644 --- a/packages/@aws-cdk/aws-apigateway/test/test.method.ts +++ b/packages/@aws-cdk/aws-apigateway/test/test.method.ts @@ -639,7 +639,7 @@ export = { const func = new lambda.Function(stack, 'myfunction', { handler: 'handler', code: lambda.Code.fromInline('foo'), - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, }); const auth = new apigw.TokenAuthorizer(stack, 'myauthorizer1', { diff --git a/packages/@aws-cdk/aws-apigatewayv2/.gitignore b/packages/@aws-cdk/aws-apigatewayv2/.gitignore new file mode 100644 index 0000000000000..95ee96981d6b4 --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/.gitignore @@ -0,0 +1,14 @@ +*.d.ts +*.generated.ts +*.js +*.js.map +*.snk +.jsii +.LAST_BUILD +.LAST_PACKAGE +nyc.config.js +.nyc_output +coverage +dist +tsconfig.json +tslint.json diff --git a/packages/@aws-cdk/aws-apigatewayv2/.npmignore b/packages/@aws-cdk/aws-apigatewayv2/.npmignore new file mode 100644 index 0000000000000..d0c509385b070 --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/.npmignore @@ -0,0 +1,20 @@ +# The basics +*.ts +*.tgz +*.snk +!*.d.ts +!*.js + +# Coverage +coverage +.nyc_output +.nycrc + +# Build gear +dist +.LAST_BUILD +.LAST_PACKAGE + +*.tsbuildinfo +tsconfig.json +!.jsii \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigatewayv2/LICENSE b/packages/@aws-cdk/aws-apigatewayv2/LICENSE new file mode 100644 index 0000000000000..b71ec1688783a --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/@aws-cdk/aws-apigatewayv2/NOTICE b/packages/@aws-cdk/aws-apigatewayv2/NOTICE new file mode 100644 index 0000000000000..bfccac9a7f69c --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/NOTICE @@ -0,0 +1,2 @@ +AWS Cloud Development Kit (AWS CDK) +Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/@aws-cdk/aws-apigatewayv2/README.md b/packages/@aws-cdk/aws-apigatewayv2/README.md new file mode 100644 index 0000000000000..8368e8c281dcc --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/README.md @@ -0,0 +1,23 @@ +## AWS::APIGatewayv2 Construct Library + + +--- + +![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge) + +> **This is a _developer preview_ (public beta) module. Releases might lack important features and might have +> future breaking changes.** +> +> This API is still under active development and subject to non-backward +> compatible changes or removal in any future version. Use of the API is not recommended in production +> environments. Experimental APIs are not subject to the Semantic Versioning model. + +--- + + + +This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project. + +```ts +import apigatewayv2 = require('@aws-cdk/aws-apigatewayv2'); +``` diff --git a/packages/@aws-cdk/aws-apigatewayv2/lib/index.ts b/packages/@aws-cdk/aws-apigatewayv2/lib/index.ts new file mode 100644 index 0000000000000..cbfa720284216 --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/lib/index.ts @@ -0,0 +1,2 @@ +// AWS::APIGatewayv2 CloudFormation Resources: +export * from './apigatewayv2.generated'; diff --git a/packages/@aws-cdk/aws-apigatewayv2/package.json b/packages/@aws-cdk/aws-apigatewayv2/package.json new file mode 100644 index 0000000000000..64a79a47070c4 --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/package.json @@ -0,0 +1,98 @@ +{ + "name": "@aws-cdk/aws-apigatewayv2", + "version": "1.21.0", + "description": "The CDK Construct Library for AWS::APIGatewayv2", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "jsii": { + "outdir": "dist", + "targets": { + "dotnet": { + "namespace": "Amazon.CDK.AWS.APIGatewayv2", + "packageId": "Amazon.CDK.AWS.APIGatewayv2", + "signAssembly": true, + "assemblyOriginatorKeyFile": "../../key.snk", + "iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png" + }, + "java": { + "package": "software.amazon.awscdk.services.apigatewayv2", + "maven": { + "groupId": "software.amazon.awscdk", + "artifactId": "apigatewayv2" + } + }, + "python": { + "distName": "aws-cdk.aws-apigatewayv2", + "module": "aws_cdk.aws_apigatewayv2" + } + } + }, + "repository": { + "type": "git", + "url": "https://github.com/aws/aws-cdk.git", + "directory": "packages/@aws-cdk/aws-apigatewayv2" + }, + "homepage": "https://github.com/aws/aws-cdk", + "scripts": { + "build": "cdk-build", + "integ": "cdk-integ", + "lint": "cdk-lint", + "package": "cdk-package", + "awslint": "cdk-awslint", + "pkglint": "pkglint -f", + "test": "cdk-test", + "watch": "cdk-watch", + "cfn2ts": "cfn2ts", + "compat": "cdk-compat", + "build+test": "npm run build && npm test", + "build+test+package": "npm run build+test && npm run package" + }, + "cdk-build": { + "cloudformation": "AWS::ApiGatewayV2" + }, + "keywords": [ + "aws", + "cdk", + "constructs", + "apigateway" + ], + "author": { + "name": "Amazon Web Services", + "url": "https://aws.amazon.com", + "organization": true + }, + "jest": { + "moduleFileExtensions": [ + "js" + ], + "coverageThreshold": { + "global": { + "branches": 60, + "statements": 80 + } + }, + "collectCoverage": true, + "coverageReporters": [ + "lcov", + "html", + "text-summary" + ] + }, + "license": "Apache-2.0", + "devDependencies": { + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" + }, + "dependencies": { + "@aws-cdk/core": "1.21.0" + }, + "peerDependencies": { + "@aws-cdk/core": "1.21.0" + }, + "engines": { + "node": ">= 10.3.0" + }, + "stability": "experimental" +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigatewayv2/test/apigatewayv2.test.ts b/packages/@aws-cdk/aws-apigatewayv2/test/apigatewayv2.test.ts new file mode 100644 index 0000000000000..e394ef336bfb4 --- /dev/null +++ b/packages/@aws-cdk/aws-apigatewayv2/test/apigatewayv2.test.ts @@ -0,0 +1,6 @@ +import '@aws-cdk/assert/jest'; +import {} from '../lib'; + +test('No tests are specified for this package', () => { + expect(true).toBe(true); +}); diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts index 50514841c229e..8b7b6fd8e5bea 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/step-scaling-policy.ts @@ -103,7 +103,6 @@ export class StepScalingPolicy extends cdk.Construct { this.lowerAlarm = new cloudwatch.Alarm(this, 'LowerAlarm', { // Recommended by AutoScaling metric: props.metric, - period: cdk.Duration.minutes(1), // Recommended by AutoScaling alarmDescription: 'Lower threshold scaling alarm', comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD, evaluationPeriods: 1, @@ -134,7 +133,6 @@ export class StepScalingPolicy extends cdk.Construct { this.upperAlarm = new cloudwatch.Alarm(this, 'UpperAlarm', { // Recommended by AutoScaling metric: props.metric, - period: cdk.Duration.minutes(1), // Recommended by AutoScaling alarmDescription: 'Upper threshold scaling alarm', comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD, evaluationPeriods: 1, diff --git a/packages/@aws-cdk/aws-applicationautoscaling/package.json b/packages/@aws-cdk/aws-applicationautoscaling/package.json index c4c3496defb0e..7f7037f22ea60 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/package.json +++ b/packages/@aws-cdk/aws-applicationautoscaling/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-applicationautoscaling", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ApplicationAutoScaling", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,26 +62,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "fast-check": "^1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-autoscaling-common": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling-common": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-autoscaling-common": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling-common": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -118,4 +118,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-applicationautoscaling/test/test.scalable-target.ts b/packages/@aws-cdk/aws-applicationautoscaling/test/test.scalable-target.ts index 7d2176bd29fa3..341dd0eeec4c9 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/test/test.scalable-target.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/test/test.scalable-target.ts @@ -1,4 +1,5 @@ import { expect, haveResource } from '@aws-cdk/assert'; +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as cdk from '@aws-cdk/core'; import { Test } from 'nodeunit'; import * as appscaling from '../lib'; @@ -82,5 +83,61 @@ export = { })); test.done(); - } + }, + + 'step scaling on MathExpression'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const target = createScalableTarget(stack); + + // WHEN + target.scaleOnMetric('Metric', { + metric: new cloudwatch.MathExpression({ + expression: 'a', + usingMetrics: { + a: new cloudwatch.Metric({ + namespace: 'Test', + metricName: 'Metric', + }) + }, + }), + adjustmentType: appscaling.AdjustmentType.CHANGE_IN_CAPACITY, + scalingSteps: [ + { change: -1, lower: 0, upper: 49 }, + { change: 0, lower: 50, upper: 99 }, + { change: 1, lower: 100 } + ] + }); + + // THEN + expect(stack).notTo(haveResource('AWS::CloudWatch::Alarm', { + Period: 60 + })); + + expect(stack).to(haveResource('AWS::CloudWatch::Alarm', { + ComparisonOperator: "LessThanOrEqualToThreshold", + EvaluationPeriods: 1, + Metrics: [ + { + Expression: "a", + Id: "expr_1" + }, + { + Id: "a", + MetricStat: { + Metric: { + MetricName: "Metric", + Namespace: "Test" + }, + Period: 300, + Stat: "Average" + }, + ReturnData: false + } + ], + Threshold: 49 + })); + + test.done(); + }, }; diff --git a/packages/@aws-cdk/aws-appmesh/package.json b/packages/@aws-cdk/aws-appmesh/package.json index 229d36ef1d637..56199f8f4dcf5 100644 --- a/packages/@aws-cdk/aws-appmesh/package.json +++ b/packages/@aws-cdk/aws-appmesh/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-appmesh", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AppMesh", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -64,25 +64,25 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -123,4 +123,4 @@ ] }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appstream/package.json b/packages/@aws-cdk/aws-appstream/package.json index d030287cdc2c2..c5cc9b26e4f12 100644 --- a/packages/@aws-cdk/aws-appstream/package.json +++ b/packages/@aws-cdk/aws-appstream/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-appstream", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AppStream", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-appsync/package.json b/packages/@aws-cdk/aws-appsync/package.json index 291a439cea604..296745778e5f9 100644 --- a/packages/@aws-cdk/aws-appsync/package.json +++ b/packages/@aws-cdk/aws-appsync/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-appsync", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AppSync", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,29 +79,29 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cognito": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cognito": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cognito": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cognito": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-athena/package.json b/packages/@aws-cdk/aws-athena/package.json index 6944f60419602..d212b4f281f9d 100644 --- a/packages/@aws-cdk/aws-athena/package.json +++ b/packages/@aws-cdk/aws-athena/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-athena", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Athena", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling-common/package.json b/packages/@aws-cdk/aws-autoscaling-common/package.json index 7edd7b190e522..698f979ebf541 100644 --- a/packages/@aws-cdk/aws-autoscaling-common/package.json +++ b/packages/@aws-cdk/aws-autoscaling-common/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-autoscaling-common", - "version": "1.19.0", + "version": "1.21.0", "description": "Common implementation package for @aws-cdk/aws-autoscaling and @aws-cdk/aws-applicationautoscaling", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -58,22 +58,22 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "fast-check": "^1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "awslint": { "exclude": [ @@ -100,4 +100,4 @@ "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling-hooktargets/package.json b/packages/@aws-cdk/aws-autoscaling-hooktargets/package.json index 501371a8dd5c6..48867c100c2d3 100644 --- a/packages/@aws-cdk/aws-autoscaling-hooktargets/package.json +++ b/packages/@aws-cdk/aws-autoscaling-hooktargets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-autoscaling-hooktargets", - "version": "1.19.0", + "version": "1.21.0", "description": "Lifecycle hook for AWS AutoScaling", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,35 +76,35 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts b/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts index a89e6813a736b..e9d530804d77c 100644 --- a/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts +++ b/packages/@aws-cdk/aws-autoscaling/lib/step-scaling-policy.ts @@ -104,7 +104,6 @@ export class StepScalingPolicy extends cdk.Construct { this.lowerAlarm = new cloudwatch.Alarm(this, 'LowerAlarm', { // Recommended by AutoScaling metric: props.metric, - period: cdk.Duration.minutes(1), // Recommended by AutoScaling alarmDescription: 'Lower threshold scaling alarm', comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD, evaluationPeriods: 1, @@ -135,7 +134,6 @@ export class StepScalingPolicy extends cdk.Construct { this.upperAlarm = new cloudwatch.Alarm(this, 'UpperAlarm', { // Recommended by AutoScaling metric: props.metric, - period: cdk.Duration.minutes(1), // Recommended by AutoScaling alarmDescription: 'Upper threshold scaling alarm', comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD, evaluationPeriods: 1, diff --git a/packages/@aws-cdk/aws-autoscaling/package.json b/packages/@aws-cdk/aws-autoscaling/package.json index 99f68c1bf183d..b92c603abb7fa 100644 --- a/packages/@aws-cdk/aws-autoscaling/package.json +++ b/packages/@aws-cdk/aws-autoscaling/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-autoscaling", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AutoScaling", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,35 +62,35 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/cx-api": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/cx-api": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-autoscaling-common": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling-common": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-autoscaling-common": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling-common": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -138,4 +138,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts b/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts index 7df0498fc58e4..5762bc9981836 100644 --- a/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts +++ b/packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts @@ -1,4 +1,5 @@ import {expect, haveResource, haveResourceLike, InspectionFailure, ResourcePart} from '@aws-cdk/assert'; +import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; @@ -858,6 +859,104 @@ export = { test.done(); }, + + 'step scaling on metric'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = mockVpc(stack); + const asg = new autoscaling.AutoScalingGroup(stack, 'MyStack', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.M4, ec2.InstanceSize.MICRO), + machineImage: new ec2.AmazonLinuxImage(), + vpc, + }); + + // WHEN + asg.scaleOnMetric('Metric', { + metric: new cloudwatch.Metric({ + namespace: 'Test', + metricName: 'Metric', + }), + adjustmentType: autoscaling.AdjustmentType.CHANGE_IN_CAPACITY, + scalingSteps: [ + { change: -1, lower: 0, upper: 49 }, + { change: 0, lower: 50, upper: 99 }, + { change: 1, lower: 100 } + ] + }); + + // THEN + expect(stack).to(haveResource('AWS::CloudWatch::Alarm', { + ComparisonOperator: "LessThanOrEqualToThreshold", + EvaluationPeriods: 1, + MetricName: "Metric", + Namespace: "Test", + Period: 300, + })); + + test.done(); + }, + + 'step scaling on MathExpression'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = mockVpc(stack); + const asg = new autoscaling.AutoScalingGroup(stack, 'MyStack', { + instanceType: ec2.InstanceType.of(ec2.InstanceClass.M4, ec2.InstanceSize.MICRO), + machineImage: new ec2.AmazonLinuxImage(), + vpc, + }); + + // WHEN + asg.scaleOnMetric('Metric', { + metric: new cloudwatch.MathExpression({ + expression: 'a', + usingMetrics: { + a: new cloudwatch.Metric({ + namespace: 'Test', + metricName: 'Metric', + }) + }, + }), + adjustmentType: autoscaling.AdjustmentType.CHANGE_IN_CAPACITY, + scalingSteps: [ + { change: -1, lower: 0, upper: 49 }, + { change: 0, lower: 50, upper: 99 }, + { change: 1, lower: 100 } + ] + }); + + // THEN + expect(stack).notTo(haveResource('AWS::CloudWatch::Alarm', { + Period: 60 + })); + + expect(stack).to(haveResource('AWS::CloudWatch::Alarm', { + "ComparisonOperator": "LessThanOrEqualToThreshold", + "EvaluationPeriods": 1, + "Metrics": [ + { + "Expression": "a", + "Id": "expr_1" + }, + { + "Id": "a", + "MetricStat": { + "Metric": { + "MetricName": "Metric", + "Namespace": "Test" + }, + "Period": 300, + "Stat": "Average" + }, + "ReturnData": false + } + ], + "Threshold": 49 + })); + + test.done(); + }, + }; function mockVpc(stack: cdk.Stack) { diff --git a/packages/@aws-cdk/aws-autoscalingplans/package.json b/packages/@aws-cdk/aws-autoscalingplans/package.json index 432eaa015e6c9..9b405f031b809 100644 --- a/packages/@aws-cdk/aws-autoscalingplans/package.json +++ b/packages/@aws-cdk/aws-autoscalingplans/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-autoscalingplans", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::AutoScalingPlans", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-backup/package.json b/packages/@aws-cdk/aws-backup/package.json index 1a6857049f12f..041f2c01625b9 100644 --- a/packages/@aws-cdk/aws-backup/package.json +++ b/packages/@aws-cdk/aws-backup/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-backup", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Backup", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/package.json b/packages/@aws-cdk/aws-batch/package.json index f68e1f87f4e3c..de2c6cc4d9768 100644 --- a/packages/@aws-cdk/aws-batch/package.json +++ b/packages/@aws-cdk/aws-batch/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-batch", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Batch", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-budgets/package.json b/packages/@aws-cdk/aws-budgets/package.json index eba3f61715a01..e50de334dc05a 100644 --- a/packages/@aws-cdk/aws-budgets/package.json +++ b/packages/@aws-cdk/aws-budgets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-budgets", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Budgets", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file 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 60ded7d75db26..2279a0aede26f 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 @@ -1,7 +1,7 @@ { "name": "dns_validated_certificate_handler", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.", "main": "lib/index.js", "directories": { diff --git a/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts index e9bfe1b1d787c..5cfa1edb47ad1 100644 --- a/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts @@ -75,7 +75,7 @@ export class DnsValidatedCertificate extends cdk.Resource implements ICertificat })); requestorFunction.addToRolePolicy(new iam.PolicyStatement({ actions: ['route53:changeResourceRecordSets'], - resources: [`arn:aws:route53:::hostedzone/${this.hostedZoneId}`], + resources: [`arn:${cdk.Stack.of(requestorFunction).partition}:route53:::hostedzone/${this.hostedZoneId}`], })); const certificate = new cfn.CustomResource(this, 'CertificateRequestorResource', { diff --git a/packages/@aws-cdk/aws-certificatemanager/package.json b/packages/@aws-cdk/aws-certificatemanager/package.json index e07554a3622be..1dcf73b2a5ac0 100644 --- a/packages/@aws-cdk/aws-certificatemanager/package.json +++ b/packages/@aws-cdk/aws-certificatemanager/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-certificatemanager", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::CertificateManager", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,27 +62,27 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -96,4 +96,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts index a78d9c03f7c91..3b62fbc3f309b 100644 --- a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts @@ -66,10 +66,10 @@ export = { 'Fn::Join': [ '', [ - 'arn:aws:route53:::hostedzone/', - { - Ref: 'ExampleDotCom4D1B83AA' - } + 'arn:', + { Ref: 'AWS::Partition' }, + ':route53:::hostedzone/', + { Ref: 'ExampleDotCom4D1B83AA' } ] ] } diff --git a/packages/@aws-cdk/aws-cloud9/package.json b/packages/@aws-cdk/aws-cloud9/package.json index 8ab4c932542bd..d646b062eed46 100644 --- a/packages/@aws-cdk/aws-cloud9/package.json +++ b/packages/@aws-cdk/aws-cloud9/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cloud9", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Cloud9", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudformation/README.md b/packages/@aws-cdk/aws-cloudformation/README.md index 9fe486f1b168c..192b788edae9f 100644 --- a/packages/@aws-cdk/aws-cloudformation/README.md +++ b/packages/@aws-cdk/aws-cloudformation/README.md @@ -68,7 +68,7 @@ import cfn = require('@aws-cdk/aws-cloudformation'); import s3 = require('@aws-cdk/aws-s3'); class MyNestedStack extends cfn.NestedStack { - constructor(scope: Construct, id: string, props: cfn.NestedStackProps) { + constructor(scope: Construct, id: string, props?: cfn.NestedStackProps) { super(scope, id, props); new s3.Bucket(this, 'NestedBucket'); @@ -76,11 +76,11 @@ class MyNestedStack extends cfn.NestedStack { } class MyParentStack extends Stack { - constructor(scope: Construct, id: string, props: StackProps) { + constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props); - new MyNestedStack(scope, 'Nested1'); - new MyNestedStack(scope, 'Nested2'); + new MyNestedStack(this, 'Nested1'); + new MyNestedStack(this, 'Nested2'); } } ``` diff --git a/packages/@aws-cdk/aws-cloudformation/package.json b/packages/@aws-cdk/aws-cloudformation/package.json index 4cde4fbe8d441..8417dc0e226a3 100644 --- a/packages/@aws-cdk/aws-cloudformation/package.json +++ b/packages/@aws-cdk/aws-cloudformation/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cloudformation", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS CloudFormation", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,36 +62,36 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", "@types/aws-lambda": "^8.10.39", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -106,4 +106,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts b/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts index f2748ad57d607..91a1a00e575dc 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts +++ b/packages/@aws-cdk/aws-cloudformation/test/test.nested-stack.ts @@ -788,19 +788,28 @@ export = { }); // THEN - const parentParams = SynthUtils.toCloudFormation(parent).Parameters; - const nestedParams = SynthUtils.toCloudFormation(nested).Parameters; - test.ok(parentParams.AssetParametershashofsourceImageName1CFB7817); - test.ok(nestedParams.referencetomystackAssetParametershashofsourceImageName7D5F0882Ref); - - // verify parameter is passed to nested stack - expect(parent).to(haveResource('AWS::CloudFormation::Stack', { - Parameters: { - referencetomystackAssetParametershashofsourceImageName7D5F0882Ref: { - Ref: "AssetParametershashofsourceImageName1CFB7817" - } + const asm = app.synth(); + test.deepEqual(asm.getStackArtifact(parent.artifactId).assets, [ + { + repositoryName: 'aws-cdk/assets', + imageTag: 'hash-of-source', + id: 'hash-of-source', + packaging: 'container-image', + path: 'my-image', + sourceHash: 'hash-of-source', + buildArgs: { key: 'value', boom: 'bam' }, + target: 'buildTarget' + }, + { + path: 'mystacknestedstackFAE12FB5.nested.template.json', + id: 'fcdaee79eb79f37eca3a9b1cc0cc9ba150e4eea8c5d6d0c343cb6cd9dc68e2e5', + packaging: 'file', + sourceHash: 'fcdaee79eb79f37eca3a9b1cc0cc9ba150e4eea8c5d6d0c343cb6cd9dc68e2e5', + s3BucketParameter: 'AssetParametersfcdaee79eb79f37eca3a9b1cc0cc9ba150e4eea8c5d6d0c343cb6cd9dc68e2e5S3Bucket67A749F8', + s3KeyParameter: 'AssetParametersfcdaee79eb79f37eca3a9b1cc0cc9ba150e4eea8c5d6d0c343cb6cd9dc68e2e5S3VersionKeyE1E6A8D4', + artifactHashParameter: 'AssetParametersfcdaee79eb79f37eca3a9b1cc0cc9ba150e4eea8c5d6d0c343cb6cd9dc68e2e5ArtifactHash0AEDBE8A' } - })); + ]); test.done(); }, diff --git a/packages/@aws-cdk/aws-cloudfront/package.json b/packages/@aws-cdk/aws-cloudfront/package.json index ea22fb7efd699..a4bafc967c4da 100644 --- a/packages/@aws-cdk/aws-cloudfront/package.json +++ b/packages/@aws-cdk/aws-cloudfront/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cloudfront", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS CloudFront", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,31 +62,31 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -140,4 +140,4 @@ "props-default-doc:@aws-cdk/aws-cloudfront.ViewerCertificateOptions.aliases" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudtrail/package.json b/packages/@aws-cdk/aws-cloudtrail/package.json index 6063fff0b8f40..ac097ee7c0bc2 100644 --- a/packages/@aws-cdk/aws-cloudtrail/package.json +++ b/packages/@aws-cdk/aws-cloudtrail/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cloudtrail", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS CloudTrail", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,32 +62,32 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "colors": "^1.4.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -104,4 +104,4 @@ "docs-public-apis:@aws-cdk/aws-cloudtrail.ReadWriteType.ALL" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudwatch-actions/package.json b/packages/@aws-cdk/aws-cloudwatch-actions/package.json index 0e0e623664983..f841541bfbae8 100644 --- a/packages/@aws-cdk/aws-cloudwatch-actions/package.json +++ b/packages/@aws-cdk/aws-cloudwatch-actions/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cloudwatch-actions", - "version": "1.19.0", + "version": "1.21.0", "description": "Alarm Actions for AWS CloudWatch CDK library", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,30 +76,30 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -112,4 +112,4 @@ "docs-public-apis:@aws-cdk/aws-cloudwatch-actions.SnsAction.bind" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts b/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts index 909e4a3acacb7..6c08c4b227f2f 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/metric.ts @@ -561,7 +561,10 @@ export interface CreateAlarmOptions { /** * The period over which the specified statistic is applied. * - * @default Duration.minutes(5) + * Cannot be used with `MathExpression` objects. + * + * @default - The period from the metric + * @deprecated Use `metric.with({ period: ... })` to encode the period into the Metric object */ readonly period?: cdk.Duration; @@ -577,7 +580,10 @@ export interface CreateAlarmOptions { * - "SampleCount | "n" * - "pNN.NN" * - * @default Average + * Cannot be used with `MathExpression` objects. + * + * @default - The statistic from the metric + * @deprecated Use `metric.with({ statistic: ... })` to encode the period into the Metric object */ readonly statistic?: string; @@ -668,11 +674,10 @@ function changeAllPeriods(metrics: Record, period: cdk.Duration /** * Return a new metric object which is the same type as the input object, but with the period changed * - * Uses JavaScript prototyping hackery to achieve this. Relies on the fact that - * both implementations of IMetric have a `period` member that contains that particular - * value. + * Relies on the fact that implementations of `IMetric` are also supposed to have + * an implementation of `with` that accepts an argument called `period`. See `IModifiableMetric`. */ -function changePeriod(metric: A, period: cdk.Duration): IMetric { +function changePeriod(metric: IMetric, period: cdk.Duration): IMetric { if (isModifiableMetric(metric)) { return metric.with({ period }); } diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/private/env-tokens.ts b/packages/@aws-cdk/aws-cloudwatch/lib/private/env-tokens.ts index e0157393df489..15fcda4886791 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/private/env-tokens.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/private/env-tokens.ts @@ -26,7 +26,9 @@ class StackDependentToken implements cdk.IResolvable { public resolve(context: cdk.IResolveContext) { const stackValue = this.fn(cdk.Stack.of(context.scope)); - if (cdk.Token.isUnresolved(stackValue) || stackValue === this.originalValue) { + // Don't render if the values are definitely the same. If the stack + // is unresolved we don't know, better output the value. + if (!cdk.Token.isUnresolved(stackValue) && stackValue === this.originalValue) { return undefined; } diff --git a/packages/@aws-cdk/aws-cloudwatch/package.json b/packages/@aws-cdk/aws-cloudwatch/package.json index 3572ab532c71b..7c3b188e35a22 100644 --- a/packages/@aws-cdk/aws-cloudwatch/package.json +++ b/packages/@aws-cdk/aws-cloudwatch/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cloudwatch", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS CloudWatch", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,22 +62,22 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "awslint": { "exclude": [ @@ -169,4 +169,4 @@ "node": ">= 10.3.0" }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.cross-environment.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.cross-environment.ts index a35f34d953304..3a970d80bb20e 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.cross-environment.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.cross-environment.ts @@ -46,6 +46,38 @@ export = { test.done(); }, + + 'metric with explicit account and region will render in environment agnostic stack'(test: Test) { + // GIVEN + const graph = new GraphWidget({ + left: [ + a.with({ account: '1234', region: 'us-north-5' }) + ], + }); + + // THEN + graphMetricsAre(test, new Stack(), graph, [ + [ 'Test', 'ACount', { accountId: '1234', region: 'us-north-5' }], + ]); + + test.done(); + }, + + 'metric attached to agnostic stack will not render in agnostic stack'(test: Test) { + // GIVEN + const graph = new GraphWidget({ + left: [ + a.attachTo(new Stack()), + ], + }); + + // THEN + graphMetricsAre(test, new Stack(), graph, [ + [ 'Test', 'ACount' ], + ]); + + test.done(); + }, }, 'in alarms': { diff --git a/packages/@aws-cdk/aws-codebuild/package.json b/packages/@aws-cdk/aws-codebuild/package.json index 8c7f486e6d1e3..a6b3a1f488487 100644 --- a/packages/@aws-cdk/aws-codebuild/package.json +++ b/packages/@aws-cdk/aws-codebuild/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codebuild", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS CodeBuild", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -66,47 +66,47 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-codecommit": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-codecommit": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-codecommit": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-codecommit": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -207,4 +207,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codebuild/test/integ.docker-asset.lit.expected.json b/packages/@aws-cdk/aws-codebuild/test/integ.docker-asset.lit.expected.json index 6f0652023ea13..561aeb8f22f9a 100644 --- a/packages/@aws-cdk/aws-codebuild/test/integ.docker-asset.lit.expected.json +++ b/packages/@aws-cdk/aws-codebuild/test/integ.docker-asset.lit.expected.json @@ -1,181 +1,5 @@ { "Resources": { - "MyImageAdoptRepository6CA902F6": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters90a0be42035e43667ec935f49efc23c6bd6c9ec566b92dae96a94f505f091f2bImageName2105B480" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters90a0be42035e43667ec935f49efc23c6bd6c9ec566b92dae96a94f505f091f2bImageName2105B480" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - }, "MyProjectRole9BBE5233": { "Type": "AWS::IAM::Role", "Properties": { @@ -221,13 +45,7 @@ { "Ref": "AWS::AccountId" }, - ":repository/", - { - "Fn::GetAtt": [ - "MyImageAdoptRepository6CA902F6", - "RepositoryName" - ] - } + ":repository/aws-cdk/assets" ] ] } @@ -328,34 +146,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters90a0be42035e43667ec935f49efc23c6bd6c9ec566b92dae96a94f505f091f2bImageName2105B480" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters90a0be42035e43667ec935f49efc23c6bd6c9ec566b92dae96a94f505f091f2bImageName2105B480" - } - ] - } - ] - } + "/aws-cdk/assets:ee9ebbb592f461ed4638ea9ea64fab9fd384fd2f890c4fef981f9938d82419f4" ] ] }, @@ -375,23 +166,5 @@ } } } - }, - "Parameters": { - "AssetParameters90a0be42035e43667ec935f49efc23c6bd6c9ec566b92dae96a94f505f091f2bImageName2105B480": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"90a0be42035e43667ec935f49efc23c6bd6c9ec566b92dae96a94f505f091f2b\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codebuild/test/test.project.ts b/packages/@aws-cdk/aws-codebuild/test/test.project.ts index 1eccd319898c8..17402b5ae1395 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.project.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.project.ts @@ -301,4 +301,34 @@ export = { test.done(); }, + + 'can use an ImmutableRole for a Project within a VPC'(test: Test) { + const stack = new cdk.Stack(); + + const role = new iam.Role(stack, 'Role', { + assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com') + }); + + const vpc = new ec2.Vpc(stack, 'Vpc'); + + new codebuild.Project(stack, 'Project', { + source: codebuild.Source.gitHubEnterprise({ + httpsCloneUrl: 'https://mygithub-enterprise.com/myuser/myrepo', + }), + role: role.withoutPolicyUpdates(), + vpc, + }); + + expect(stack).to(countResources('AWS::IAM::Policy', 0)); + + // Check that the CodeBuild project does not have a DependsOn + expect(stack).to(haveResource('AWS::CodeBuild::Project', (res: any) => { + if (res.DependsOn && res.DependsOn.length > 0) { + throw new Error(`CodeBuild project should have no DependsOn, but got: ${JSON.stringify(res, undefined, 2)}`); + } + return true; + }, ResourcePart.CompleteDefinition)); + + test.done(); + }, }; \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codecommit/package.json b/packages/@aws-cdk/aws-codecommit/package.json index 2d93c05c0a412..7c2c20d559c82 100644 --- a/packages/@aws-cdk/aws-codecommit/package.json +++ b/packages/@aws-cdk/aws-codecommit/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codecommit", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS CodeCommit", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -67,26 +67,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -107,4 +107,4 @@ "docs-public-apis:@aws-cdk/aws-codecommit.RepositoryEventTrigger.DELETE_REF" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codedeploy/package.json b/packages/@aws-cdk/aws-codedeploy/package.json index b50f26cdc5746..b037721ea68cf 100644 --- a/packages/@aws-cdk/aws-codedeploy/package.json +++ b/packages/@aws-cdk/aws-codedeploy/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codedeploy", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::CodeDeploy", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -65,36 +65,36 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -157,4 +157,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline-actions/README.md b/packages/@aws-cdk/aws-codepipeline-actions/README.md index 406f868e19e27..92102fc07e18a 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/README.md +++ b/packages/@aws-cdk/aws-codepipeline-actions/README.md @@ -44,6 +44,26 @@ pipeline.addStage({ }); ``` +The CodeCommit source action emits variables: + +```typescript +const sourceAction = new codepipeline_actions.CodeCommitSourceAction({ + // ... + variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you +}); + +// later: + +new codepipeline_actions.CodeBuildAction({ + // ... + environmentVariables: { + COMMIT_ID: { + value: sourceAction.variables.commitId, + }, + }, +}); +``` + #### GitHub To use GitHub as the source of a CodePipeline: @@ -66,6 +86,26 @@ pipeline.addStage({ }); ``` +The GitHub source action emits variables: + +```typescript +const sourceAction = new codepipeline_actions.GitHubSourceAction({ + // ... + variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you +}); + +// later: + +new codepipeline_actions.CodeBuildAction({ + // ... + environmentVariables: { + COMMIT_URL: { + value: sourceAction.variables.commitUrl, + }, + }, +}); +``` + #### AWS S3 To use an S3 Bucket as a source in CodePipeline: @@ -116,6 +156,26 @@ const sourceAction = new codepipeline_actions.S3SourceAction({ }); ``` +The S3 source action emits variables: + +```typescript +const sourceAction = new codepipeline_actions.S3SourceAction({ + // ... + variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you +}); + +// later: + +new codepipeline_actions.CodeBuildAction({ + // ... + environmentVariables: { + VERSION_ID: { + value: sourceAction.variables.versionId, + }, + }, +}); +``` + #### AWS ECR To use an ECR Repository as a source in a Pipeline: @@ -137,6 +197,26 @@ pipeline.addStage({ }); ``` +The ECR source action emits variables: + +```typescript +const sourceAction = new codepipeline_actions.EcrSourceAction({ + // ... + variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you +}); + +// later: + +new codepipeline_actions.CodeBuildAction({ + // ... + environmentVariables: { + IMAGE_URI: { + value: sourceAction.variables.imageUri, + }, + }, +}); +``` + ### Build & test #### AWS CodeBuild @@ -266,6 +346,48 @@ const project = new codebuild.PipelineProject(this, 'MyProject', { }); ``` +##### Variables + +The CodeBuild action emits variables. +Unlike many other actions, the variables are not static, +but dynamic, defined in the buildspec, +in the 'exported-variables' subsection of the 'env' section. +Example: + +```typescript +const buildAction = new codepipeline_actions.CodeBuildAction({ + actionName: 'Build1', + input: sourceOutput, + project: new codebuild.PipelineProject(this, 'Project', { + buildSpec: codebuild.BuildSpec.fromObject({ + version: '0.2', + env: { + 'exported-variables': [ + 'MY_VAR', + ], + }, + phases: { + build: { + commands: 'export MY_VAR="some value"', + }, + }, + }), + }), + variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you +}); + +// later: + +new codepipeline_actions.CodeBuildAction({ + // ... + environmentVariables: { + MyVar: { + value: buildAction.variable('MY_VAR'), + }, + }, +}); +``` + #### Jenkins In order to use Jenkins Actions in the Pipeline, @@ -304,7 +426,7 @@ const buildAction = new codepipeline_actions.JenkinsAction({ actionName: 'JenkinsBuild', jenkinsProvider: jenkinsProvider, projectName: 'MyProject', - type: ccodepipeline_actions.JenkinsActionType.BUILD, + type: codepipeline_actions.JenkinsActionType.BUILD, }); ``` @@ -418,10 +540,10 @@ const lambdaCode = lambda.Code.fromCfnParameters(); const func = new lambda.Function(lambdaStack, 'Lambda', { code: lambdaCode, handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, }); // used to make sure each CDK synthesis produces a different Version -const version = func.addVersion('NewVersion') +const version = func.addVersion('NewVersion'); const alias = new lambda.Alias(lambdaStack, 'LambdaAlias', { aliasName: 'Prod', version, @@ -598,5 +720,48 @@ const lambdaAction = new codepipeline_actions.LambdaInvokeAction({ }); ``` +The Lambda invoke action emits variables. +Unlike many other actions, the variables are not static, +but dynamic, defined by the function calling the `PutJobSuccessResult` +API with the `outputVariables` property filled with the map of variables +Example: + +```typescript +import lambda = require('@aws-cdk/aws-lambda'); + +const lambdaInvokeAction = new codepipeline_actions.LambdaInvokeAction({ + actionName: 'Lambda', + lambda: new lambda.Function(this, 'Func', { + runtime: lambda.Runtime.NODEJS_10_X, + handler: 'index.handler', + code: lambda.Code.fromInline(` + var AWS = require('aws-sdk'); + + exports.handler = async function(event, context) { + var codepipeline = new AWS.CodePipeline(); + await codepipeline.putJobSuccessResult({ + jobId: event['CodePipeline.job'].id, + outputVariables: { + MY_VAR: "some value", + }, + }).promise(); + } + `), + }), + variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you +}); + +// later: + +new codepipeline_actions.CodeBuildAction({ + // ... + environmentVariables: { + MyVar: { + value: lambdaInvokeAction.variable('MY_VAR'), + }, + }, +}); +``` + See [the AWS documentation](https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html) on how to write a Lambda function invoked from CodePipeline. diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/action.ts index 514ebd9cc70bc..024cd1a66fc9a 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/action.ts @@ -1,6 +1,6 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as events from '@aws-cdk/aws-events'; -import { Construct } from '@aws-cdk/core'; +import { Construct, Lazy } from '@aws-cdk/core'; /** * Low-level class for generic CodePipeline Actions. @@ -13,12 +13,34 @@ import { Construct } from '@aws-cdk/core'; * @experimental */ export abstract class Action implements codepipeline.IAction { + public readonly actionProperties: codepipeline.ActionProperties; private _pipeline?: codepipeline.IPipeline; private _stage?: codepipeline.IStage; private _scope?: Construct; + private readonly customerProvidedNamespace?: string; + private readonly namespaceOrToken: string; + private actualNamespace?: string; + private variableReferenced = false; - constructor(public readonly actionProperties: codepipeline.ActionProperties) { - // nothing to do + protected constructor(actionProperties: codepipeline.ActionProperties) { + this.customerProvidedNamespace = actionProperties.variablesNamespace; + this.namespaceOrToken = Lazy.stringValue({ produce: () => { + // make sure the action was bound (= added to a pipeline) + if (this.actualNamespace !== undefined) { + return this.customerProvidedNamespace !== undefined + // if a customer passed a namespace explicitly, always use that + ? this.customerProvidedNamespace + // otherwise, only return a namespace if any variable was referenced + : (this.variableReferenced ? this.actualNamespace : undefined); + } else { + throw new Error(`Cannot reference variables of action '${this.actionProperties.actionName}', ` + + 'as that action was never added to a pipeline'); + } + }}); + this.actionProperties = { + ...actionProperties, + variablesNamespace: this.namespaceOrToken, + }; } public bind(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): @@ -27,6 +49,11 @@ export abstract class Action implements codepipeline.IAction { this._stage = stage; this._scope = scope; + this.actualNamespace = this.customerProvidedNamespace === undefined + // default a namespace name, based on the stage and action names + ? `${stage.stageName}_${this.actionProperties.actionName}_NS` + : this.customerProvidedNamespace; + return this.bound(scope, stage, options); } @@ -34,7 +61,7 @@ export abstract class Action implements codepipeline.IAction { const rule = new events.Rule(this.scope, name, options); rule.addTarget(target); rule.addEventPattern({ - detailType: [ 'CodePipeline Stage Execution State Change' ], + detailType: [ 'CodePipeline Action Execution State Change' ], source: [ 'aws.codepipeline' ], resources: [ this.pipeline.pipelineArn ], detail: { @@ -45,6 +72,11 @@ export abstract class Action implements codepipeline.IAction { return rule; } + protected variableExpression(variableName: string): string { + this.variableReferenced = true; + return `#{${this.namespaceOrToken}.${variableName}}`; + } + /** * The method called when an Action is attached to a Pipeline. * This method is guaranteed to be called only once for each Action instance. diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts index 845a3a052f4cd..10348f02533a3 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/build-action.ts @@ -92,6 +92,20 @@ export class CodeBuildAction extends Action { this.props = props; } + /** + * Reference a CodePipeline variable defined by the CodeBuild project this action points to. + * Variables in CodeBuild actions are defined using the 'exported-variables' subsection of the 'env' + * section of the buildspec. + * + * @param variableName the name of the variable to reference. + * A variable by this name must be present in the 'exported-variables' section of the buildspec + * + * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax + */ + public variable(variableName: string): string { + return this.variableExpression(variableName); + } + protected bound(scope: cdk.Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // check for a cross-account action if there are any outputs diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts index 35c3cbea50f8c..76183aa51aa83 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts @@ -29,6 +29,29 @@ export enum CodeCommitTrigger { EVENTS = 'Events', } +/** + * The CodePipeline variables emitted by the CodeCommit source Action. + */ +export interface CodeCommitSourceVariables { + /** The name of the repository this action points to. */ + readonly repositoryName: string; + + /** The name of the branch this action tracks. */ + readonly branchName: string; + + /** The date the currently last commit on the tracked branch was authored, in ISO-8601 format. */ + readonly authorDate: string; + + /** The date the currently last commit on the tracked branch was committed, in ISO-8601 format. */ + readonly committerDate: string; + + /** The SHA1 hash of the currently last commit on the tracked branch. */ + readonly commitId: string; + + /** The message of the currently last commit on the tracked branch. */ + readonly commitMessage: string; +} + /** * Construction properties of the {@link CodeCommitSourceAction CodeCommit source CodePipeline Action}. */ @@ -79,6 +102,18 @@ export class CodeCommitSourceAction extends Action { this.props = props; } + /** The variables emitted by this action. */ + public get variables(): CodeCommitSourceVariables { + return { + repositoryName: this.variableExpression('RepositoryName'), + branchName: this.variableExpression('BranchName'), + authorDate: this.variableExpression('AuthorDate'), + committerDate: this.variableExpression('CommitterDate'), + commitId: this.variableExpression('CommitId'), + commitMessage: this.variableExpression('CommitMessage'), + }; + } + protected bound(_scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { const createEvent = this.props.trigger === undefined || diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts index 05f1932705fba..09ee9d3744af3 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts @@ -6,6 +6,26 @@ import { Construct } from '@aws-cdk/core'; import { Action } from '../action'; import { sourceArtifactBounds } from '../common'; +/** + * The CodePipeline variables emitted by the ECR source Action. + */ +export interface EcrSourceVariables { + /** The identifier of the registry. In ECR, this is usually the ID of the AWS account owning it. */ + readonly registryId: string; + + /** The physical name of the repository that this action tracks. */ + readonly repositoryName: string; + + /** The digest of the current image, in the form ':'. */ + readonly imageDigest: string; + + /** The Docker tag of the current image. */ + readonly imageTag: string; + + /** The full ECR Docker URI of the current image. */ + readonly imageUri: string; +} + /** * Construction properties of {@link EcrSourceAction}. */ @@ -51,6 +71,17 @@ export class EcrSourceAction extends Action { this.props = props; } + /** The variables emitted by this action. */ + public get variables(): EcrSourceVariables { + return { + registryId: this.variableExpression('RegistryId'), + repositoryName: this.variableExpression('RepositoryName'), + imageDigest: this.variableExpression('ImageDigest'), + imageTag: this.variableExpression('ImageTag'), + imageUri: this.variableExpression('ImageURI'), + }; + } + protected bound(_scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { options.role.addToPolicy(new iam.PolicyStatement({ diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts index 6b1b718846631..42062e9040dde 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts @@ -12,6 +12,26 @@ export enum GitHubTrigger { WEBHOOK = 'WebHook', } +/** + * The CodePipeline variables emitted by GitHub source Action. + */ +export interface GitHubSourceVariables { + /** The name of the repository this action points to. */ + readonly repositoryName: string; + /** The name of the branch this action tracks. */ + readonly branchName: string; + /** The date the currently last commit on the tracked branch was authored, in ISO-8601 format. */ + readonly authorDate: string; + /** The date the currently last commit on the tracked branch was committed, in ISO-8601 format. */ + readonly committerDate: string; + /** The SHA1 hash of the currently last commit on the tracked branch. */ + readonly commitId: string; + /** The message of the currently last commit on the tracked branch. */ + readonly commitMessage: string; + /** The GitHub API URL of the currently last commit on the tracked branch. */ + readonly commitUrl: string; +} + /** * Construction properties of the {@link GitHubSourceAction GitHub source action}. */ @@ -79,6 +99,19 @@ export class GitHubSourceAction extends Action { this.props = props; } + /** The variables emitted by this action. */ + public get variables(): GitHubSourceVariables { + return { + repositoryName: this.variableExpression('RepositoryName'), + branchName: this.variableExpression('BranchName'), + authorDate: this.variableExpression('AuthorDate'), + committerDate: this.variableExpression('CommitterDate'), + commitId: this.variableExpression('CommitId'), + commitMessage: this.variableExpression('CommitMessage'), + commitUrl: this.variableExpression('CommitUrl'), + }; + } + protected bound(scope: Construct, stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { if (!this.props.trigger || this.props.trigger === GitHubTrigger.WEBHOOK) { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts index 839cbb0a42acd..a0220fc6e7d2b 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts @@ -74,6 +74,21 @@ export class LambdaInvokeAction extends Action { this.props = props; } + /** + * Reference a CodePipeline variable defined by the Lambda function this action points to. + * Variables in Lambda invoke actions are defined by calling the PutJobSuccessResult CodePipeline API call + * with the 'outputVariables' property filled. + * + * @param variableName the name of the variable to reference. + * A variable by this name must be present in the 'outputVariables' section of the PutJobSuccessResult + * request that the Lambda function calls when the action is invoked + * + * @see https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobSuccessResult.html + */ + public variable(variableName: string): string { + return this.variableExpression(variableName); + } + protected bound(scope: Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { // allow pipeline to list functions diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts index badccd4591f46..3a318011caad3 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts @@ -24,6 +24,13 @@ export interface ManualApprovalActionProps extends codepipeline.CommonAwsActionP * Any additional information that you want to include in the notification email message. */ readonly additionalInformation?: string; + + /** + * URL you want to provide to the reviewer as part of the approval request. + * + * @default - the approval request will not have an external link + */ + readonly externalEntityLink?: string; } /** @@ -73,6 +80,7 @@ export class ManualApprovalAction extends Action { ? { NotificationArn: this._notificationTopic.topicArn, CustomData: this.props.additionalInformation, + ExternalEntityLink: this.props.externalEntityLink, } : undefined, }; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts index d65e4cf1dca3c..0aa421ce14b36 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts @@ -1,9 +1,47 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as s3 from '@aws-cdk/aws-s3'; -import { Construct } from '@aws-cdk/core'; +import { Construct, Duration } from '@aws-cdk/core'; import { Action } from '../action'; import { deployArtifactBounds } from '../common'; +// Class copied verbatim from the aws-s3-deployment module. +// Yes, it sucks that we didn't abstract this properly in a common class, +// but having 2 different CacheControl classes that behave differently would be worse I think. +// Something to do when CDK 2.0.0 comes out. +/** + * Used for HTTP cache-control header, which influences downstream caches. + * Use the provided static factory methods to construct instances of this class. + * Used in the {@link S3DeployActionProps.cacheControl} property. + * + * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 + */ +export class CacheControl { + /** The 'must-revalidate' cache control directive. */ + public static mustRevalidate() { return new CacheControl('must-revalidate'); } + /** The 'no-cache' cache control directive. */ + public static noCache() { return new CacheControl('no-cache'); } + /** The 'no-transform' cache control directive. */ + public static noTransform() { return new CacheControl('no-transform'); } + /** The 'public' cache control directive. */ + public static setPublic() { return new CacheControl('public'); } + /** The 'private' cache control directive. */ + public static setPrivate() { return new CacheControl('private'); } + /** The 'proxy-revalidate' cache control directive. */ + public static proxyRevalidate() { return new CacheControl('proxy-revalidate'); } + /** The 'max-age' cache control directive. */ + public static maxAge(t: Duration) { return new CacheControl(`max-age: ${t.toSeconds()}`); } + /** The 's-max-age' cache control directive. */ + public static sMaxAge(t: Duration) { return new CacheControl(`s-max-age: ${t.toSeconds()}`); } + /** + * Allows you to create an arbitrary cache control directive, + * in case our support is missing a method for a particular directive. + */ + public static fromString(s: string) { return new CacheControl(s); } + + /** @param value the actual text value of the created directive */ + private constructor(public value: string) {} +} + /** * Construction properties of the {@link S3DeployAction S3 deploy Action}. */ @@ -29,6 +67,23 @@ export interface S3DeployActionProps extends codepipeline.CommonAwsActionProps { * The Amazon S3 bucket that is the deploy target. */ readonly bucket: s3.IBucket; + + /** + * The specified canned ACL to objects deployed to Amazon S3. + * This overwrites any existing ACL that was applied to the object. + * + * @default - the original object ACL + */ + readonly accessControl?: s3.BucketAccessControl; + + /** + * The caching behavior for requests/responses for objects in the bucket. + * The final cache control property will be the result of joining all of the provided array elements with a comma + * (plus a space after the comma). + * + * @default - none, decided by the HTTP client + */ + readonly cacheControl?: CacheControl[]; } /** @@ -63,6 +118,8 @@ export class S3DeployAction extends Action { BucketName: this.props.bucket.bucketName, Extract: this.props.extract === false ? 'false' : 'true', ObjectKey: this.props.objectKey, + CannedACL: this.props.accessControl, + CacheControl: this.props.cacheControl && this.props.cacheControl.map(ac => ac.value).join(', '), }, }; } diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts index e311d624d54f2..1cf1d821dd0ac 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts @@ -30,6 +30,17 @@ export enum S3Trigger { EVENTS = 'Events', } +/** + * The CodePipeline variables emitted by the S3 source Action. + */ +export interface S3SourceVariables { + /** The identifier of the S3 version of the object that triggered the build. */ + readonly versionId: string; + + /** The e-tag of the S3 version of the object that triggered the build. */ + readonly eTag: string; +} + /** * Construction properties of the {@link S3SourceAction S3 source Action}. */ @@ -88,6 +99,14 @@ export class S3SourceAction extends Action { this.props = props; } + /** The variables emitted by this action. */ + public get variables(): S3SourceVariables { + return { + versionId: this.variableExpression('VersionId'), + eTag: this.variableExpression('ETag'), + }; + } + protected bound(_scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { if (this.props.trigger === S3Trigger.EVENTS) { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/package.json b/packages/@aws-cdk/aws-codepipeline-actions/package.json index 935eb68e48f63..e381573002266 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/package.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codepipeline-actions", - "version": "1.19.0", + "version": "1.21.0", "description": "Concrete Actions for AWS Code Pipeline", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -64,52 +64,52 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-cloudtrail": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-cloudtrail": "1.21.0", "@types/lodash": "^4.14.149", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "lodash": "^4.17.15", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codecommit": "1.19.0", - "@aws-cdk/aws-codedeploy": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codecommit": "1.21.0", + "@aws-cdk/aws-codedeploy": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codecommit": "1.19.0", - "@aws-cdk/aws-codedeploy": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codecommit": "1.21.0", + "@aws-cdk/aws-codedeploy": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -160,4 +160,4 @@ "props-default-doc:@aws-cdk/aws-codepipeline-actions.CodeDeployEcsDeployActionProps.containerImageInputs" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/codebuild/test.codebuild-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/codebuild/test.codebuild-action.ts index 45ff0a49654b4..dacfae6d21cd1 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/codebuild/test.codebuild-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/codebuild/test.codebuild-action.ts @@ -3,6 +3,7 @@ import * as codebuild from '@aws-cdk/aws-codebuild'; import * as codecommit from '@aws-cdk/aws-codecommit'; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as s3 from '@aws-cdk/aws-s3'; +import * as sns from '@aws-cdk/aws-sns'; import { App, Stack } from '@aws-cdk/core'; import { Test } from 'nodeunit'; import * as cpactions from '../../lib'; @@ -122,5 +123,84 @@ export = { test.done(); }, + + 'exposes variables for other actions to consume'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + const codeBuildAction = new cpactions.CodeBuildAction({ + actionName: 'CodeBuild', + input: sourceOutput, + project: new codebuild.PipelineProject(stack, 'CodeBuild', { + buildSpec: codebuild.BuildSpec.fromObject({ + version: '0.2', + env: { + 'exported-variables': [ + 'SomeVar', + ], + }, + phases: { + build: { + commands: [ + 'export SomeVar="Some Value"', + ], + }, + }, + }), + }), + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [ + new cpactions.S3SourceAction({ + actionName: 'S3_Source', + bucket: s3.Bucket.fromBucketName(stack, 'Bucket', 'bucket'), + bucketKey: 'key', + output: sourceOutput, + }), + ], + }, + { + stageName: 'Build', + actions: [ + codeBuildAction, + new cpactions.ManualApprovalAction({ + actionName: 'Approve', + additionalInformation: codeBuildAction.variable('SomeVar'), + notificationTopic: sns.Topic.fromTopicArn(stack, 'Topic', 'arn:aws:sns:us-east-1:123456789012:mytopic'), + runOrder: 2, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Build", + "Actions": [ + { + "Name": "CodeBuild", + "Namespace": "Build_CodeBuild_NS", + }, + { + "Name": "Approve", + "Configuration": { + "CustomData": "#{Build_CodeBuild_NS.SomeVar}", + }, + }, + ], + }, + ], + })); + + test.done(); + }, }, }; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/codecommit/test.codecommit-source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/codecommit/test.codecommit-source-action.ts index 1086d3b0d82f4..e67cf3139d4b2 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/codecommit/test.codecommit-source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/codecommit/test.codecommit-source-action.ts @@ -109,6 +109,61 @@ export = { test.done(); }, + + 'exposes variables for other actions to consume'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + const codeCommitSourceAction = new cpactions.CodeCommitSourceAction({ + actionName: 'Source', + repository: new codecommit.Repository(stack, 'MyRepo', { + repositoryName: 'my-repo', + }), + output: sourceOutput, + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [codeCommitSourceAction], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + environmentVariables: { + AuthorDate: { value: codeCommitSourceAction.variables.authorDate }, + }, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Build", + "Actions": [ + { + "Name": "Build", + "Configuration": { + "EnvironmentVariables": '[{"name":"AuthorDate","type":"PLAINTEXT","value":"#{Source_Source_NS.AuthorDate}"}]', + }, + }, + ], + }, + ], + })); + + test.done(); + }, }, }; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/ecr/test.ecr-source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/ecr/test.ecr-source-action.ts new file mode 100644 index 0000000000000..d00283d33c9eb --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/ecr/test.ecr-source-action.ts @@ -0,0 +1,66 @@ +import { expect, haveResourceLike } from "@aws-cdk/assert"; +import * as codebuild from '@aws-cdk/aws-codebuild'; +import * as codepipeline from '@aws-cdk/aws-codepipeline'; +import * as ecr from '@aws-cdk/aws-ecr'; +import { Stack } from "@aws-cdk/core"; +import { Test } from 'nodeunit'; +import * as cpactions from '../../lib'; + +// tslint:disable:object-literal-key-quotes + +export = { + 'ECR source Action': { + 'exposes variables for other actions to consume'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + const ecrSourceAction = new cpactions.EcrSourceAction({ + actionName: 'Source', + output: sourceOutput, + repository: ecr.Repository.fromRepositoryName(stack, 'Repo', 'repo'), + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [ecrSourceAction], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + environmentVariables: { + ImageDigest: { value: ecrSourceAction.variables.imageDigest }, + }, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Build", + "Actions": [ + { + "Name": "Build", + "Configuration": { + "EnvironmentVariables": '[{"name":"ImageDigest","type":"PLAINTEXT","value":"#{Source_Source_NS.ImageDigest}"}]', + }, + }, + ], + }, + ], + })); + + test.done(); + }, + }, +}; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/github/test.github-source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/github/test.github-source-action.ts new file mode 100644 index 0000000000000..1707c245defa7 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/github/test.github-source-action.ts @@ -0,0 +1,211 @@ +import { expect, haveResourceLike, SynthUtils } from "@aws-cdk/assert"; +import * as codebuild from '@aws-cdk/aws-codebuild'; +import * as codepipeline from '@aws-cdk/aws-codepipeline'; +import { SecretValue, Stack } from "@aws-cdk/core"; +import { Test } from 'nodeunit'; +import * as cpactions from '../../lib'; + +// tslint:disable:object-literal-key-quotes + +export = { + 'GitHub source Action': { + 'exposes variables for other actions to consume'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + const gitHubSourceAction = new cpactions.GitHubSourceAction({ + actionName: 'Source', + owner: 'aws', + repo: 'aws-cdk', + output: sourceOutput, + oauthToken: SecretValue.plainText('secret'), + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [gitHubSourceAction], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + environmentVariables: { + CommitUrl: { value: gitHubSourceAction.variables.commitUrl }, + }, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Build", + "Actions": [ + { + "Name": "Build", + "Configuration": { + "EnvironmentVariables": '[{"name":"CommitUrl","type":"PLAINTEXT","value":"#{Source_Source_NS.CommitUrl}"}]', + }, + }, + ], + }, + ], + })); + + test.done(); + }, + + 'always renders the customer-supplied namespace, even if none of the variables are used'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [ + new cpactions.GitHubSourceAction({ + actionName: 'Source', + owner: 'aws', + repo: 'aws-cdk', + output: sourceOutput, + oauthToken: SecretValue.plainText('secret'), + variablesNamespace: 'MyNamespace', + }), + ], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + "Actions": [ + { + "Name": "Source", + "Namespace": "MyNamespace", + }, + ], + }, + { + }, + ], + })); + + test.done(); + }, + + 'fails if a variable from an action without a namespace set that is not part of a pipeline is referenced'(test: Test) { + const stack = new Stack(); + + const unusedSourceAction = new cpactions.GitHubSourceAction({ + actionName: 'Source2', + owner: 'aws', + repo: 'aws-cdk', + output: new codepipeline.Artifact(), + oauthToken: SecretValue.plainText('secret'), + }); + const sourceOutput = new codepipeline.Artifact(); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [new cpactions.GitHubSourceAction({ + actionName: 'Source1', + owner: 'aws', + repo: 'aws-cdk', + output: sourceOutput, + oauthToken: SecretValue.plainText('secret'), + })], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + environmentVariables: { + 'VAR1': { value: unusedSourceAction.variables.authorDate }, + }, + }), + ], + }, + ], + }); + + test.throws(() => { + SynthUtils.synthesize(stack); + }, /Cannot reference variables of action 'Source2', as that action was never added to a pipeline/); + + test.done(); + }, + + 'fails if a variable from an action with a namespace set that is not part of a pipeline is referenced'(test: Test) { + const stack = new Stack(); + + const unusedSourceAction = new cpactions.GitHubSourceAction({ + actionName: 'Source2', + owner: 'aws', + repo: 'aws-cdk', + output: new codepipeline.Artifact(), + oauthToken: SecretValue.plainText('secret'), + variablesNamespace: 'MyNamespace', + }); + const sourceOutput = new codepipeline.Artifact(); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [new cpactions.GitHubSourceAction({ + actionName: 'Source1', + owner: 'aws', + repo: 'aws-cdk', + output: sourceOutput, + oauthToken: SecretValue.plainText('secret'), + })], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + environmentVariables: { + 'VAR1': { value: unusedSourceAction.variables.authorDate }, + }, + }), + ], + }, + ], + }); + + test.throws(() => { + SynthUtils.synthesize(stack); + }, /Cannot reference variables of action 'Source2', as that action was never added to a pipeline/); + + test.done(); + }, + }, +}; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.expected.json index 5d136e655cc8b..050b8e6ef57dd 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.expected.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.expected.json @@ -484,7 +484,7 @@ "Properties": { "EventPattern": { "detail-type": [ - "CodePipeline Stage Execution State Change" + "CodePipeline Action Execution State Change" ], "source": [ "aws.codepipeline" diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.expected.json index 59e980a3009db..65591dd703225 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.expected.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.expected.json @@ -309,7 +309,9 @@ "BucketName": { "Ref": "DeployBucket67E2C076" }, - "Extract": "true" + "Extract": "true", + "CannedACL": "PublicRead", + "CacheControl": "public, max-age: 43200" }, "InputArtifacts": [ { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts index d2a21bf37070c..350c0ac1aa570 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts @@ -34,6 +34,11 @@ new codepipeline.Pipeline(stack, 'Pipeline', { actionName: 'DeployAction', input: sourceOutput, bucket: deployBucket, + accessControl: s3.BucketAccessControl.PUBLIC_READ, + cacheControl: [ + cpactions.CacheControl.setPublic(), + cpactions.CacheControl.maxAge(cdk.Duration.hours(12)), + ], }) ], }, diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/lambda/test.lambda-invoke-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/lambda/test.lambda-invoke-action.ts index fa7b63f51346a..e972ed2f33992 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/lambda/test.lambda-invoke-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/lambda/test.lambda-invoke-action.ts @@ -1,6 +1,8 @@ import { expect, haveResourceLike } from "@aws-cdk/assert"; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as lambda from '@aws-cdk/aws-lambda'; +import * as s3 from '@aws-cdk/aws-s3'; +import * as sns from '@aws-cdk/aws-sns'; import { Aws, Lazy, SecretValue, Stack, Token } from "@aws-cdk/core"; import { Test } from 'nodeunit'; import * as cpactions from '../../lib'; @@ -230,6 +232,68 @@ export = { test.done(); }, + + 'exposes variables for other actions to consume'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + const lambdaInvokeAction = new cpactions.LambdaInvokeAction({ + actionName: 'LambdaInvoke', + lambda: lambda.Function.fromFunctionArn(stack, 'Func', 'arn:aws:lambda:us-east-1:123456789012:function:some-func'), + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [ + new cpactions.S3SourceAction({ + actionName: 'S3_Source', + bucket: s3.Bucket.fromBucketName(stack, 'Bucket', 'bucket'), + bucketKey: 'key', + output: sourceOutput, + }), + ], + }, + { + stageName: 'Invoke', + actions: [ + lambdaInvokeAction, + new cpactions.ManualApprovalAction({ + actionName: 'Approve', + additionalInformation: lambdaInvokeAction.variable('SomeVar'), + notificationTopic: sns.Topic.fromTopicArn(stack, 'Topic', 'arn:aws:sns:us-east-1:123456789012:mytopic'), + runOrder: 2, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Invoke", + "Actions": [ + { + "Name": "LambdaInvoke", + "Namespace": "Invoke_LambdaInvoke_NS", + }, + { + "Name": "Approve", + "Configuration": { + "CustomData": "#{Invoke_LambdaInvoke_NS.SomeVar}", + }, + }, + ], + }, + ], + })); + + test.done(); + }, }, }; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/s3/test.s3-source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/s3/test.s3-source-action.ts index 8f6ed6b882b15..e3d91a9bb7daa 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/s3/test.s3-source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/s3/test.s3-source-action.ts @@ -175,6 +175,60 @@ export = { test.done(); }, + + 'exposes variables for other actions to consume'(test: Test) { + const stack = new Stack(); + + const sourceOutput = new codepipeline.Artifact(); + const s3SourceAction = new cpactions.S3SourceAction({ + actionName: 'Source', + output: sourceOutput, + bucket: new s3.Bucket(stack, 'Bucket'), + bucketKey: 'key.zip', + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [s3SourceAction], + }, + { + stageName: 'Build', + actions: [ + new cpactions.CodeBuildAction({ + actionName: 'Build', + project: new codebuild.PipelineProject(stack, 'MyProject'), + input: sourceOutput, + environmentVariables: { + VersionId: { value: s3SourceAction.variables.versionId }, + }, + }), + ], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Build", + "Actions": [ + { + "Name": "Build", + "Configuration": { + "EnvironmentVariables": '[{"name":"VersionId","type":"PLAINTEXT","value":"#{Source_Source_NS.VersionId}"}]', + }, + }, + ], + }, + ], + })); + + test.done(); + }, }, }; diff --git a/packages/@aws-cdk/aws-codepipeline/README.md b/packages/@aws-cdk/aws-codepipeline/README.md index 4e439c665aa90..5e77c98e492bb 100644 --- a/packages/@aws-cdk/aws-codepipeline/README.md +++ b/packages/@aws-cdk/aws-codepipeline/README.md @@ -83,7 +83,6 @@ sourceStage.addAction(someAction); ### Cross-region CodePipelines You can also use the cross-region feature to deploy resources -(currently, only CloudFormation Stacks are supported) into a different region than your Pipeline is in. It works like this: @@ -180,6 +179,56 @@ const replicationBucket = new s3.Bucket(replicationStack, 'ReplicationBucket', { }); ``` +### Variables + +The library supports the CodePipeline Variables feature. +Each action class that emits variables has a separate variables interface, +accessed as a property of the action instance called `variables`. +You instantiate the action class and assign it to a local variable; +when you want to use a variable in the configuration of a different action, +you access the appropriate property of the interface returned from `variables`, +which represents a single variable. +Example: + +```typescript +// MyAction is some action type that produces variables +const myAction = new MyAction({ + // ... +}); +new OtherAction({ + // ... + config: myAction.variables.myVariable, +}); +``` + +The namespace name that will be used will be automatically generated by the pipeline construct, +based on the stage and action name; +you can pass a custom name when creating the action instance: + +```typescript +const myAction = new MyAction({ + // ... + variablesNamespace: 'MyNamespace', +}); +``` + +There are also global variables available, +not tied to any action; +these are accessed through static properties of the `GlobalVariables` class: + +```typescript +new OtherAction({ + // ... + config: codepipeline.GlobalVariables.executionId, +}); +``` + +Check the documentation of the `@aws-cdk/aws-codepipeline-actions` +for details on how to use the variables for each action class. + +See the [CodePipeline documentation](https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html) +for more details on how to use the variables feature. + ### Events #### Using a pipeline as an event target diff --git a/packages/@aws-cdk/aws-codepipeline/lib/action.ts b/packages/@aws-cdk/aws-codepipeline/lib/action.ts index a8a2a74024520..e5c8e66dc0c15 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/action.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/action.ts @@ -27,6 +27,17 @@ export interface ActionArtifactBounds { readonly maxOutputs: number; } +/** + * The CodePipeline variables that are global, + * not bound to a specific action. + * This class defines a bunch of static fields that represent the different variables. + * These can be used can be used in any action configuration. + */ +export class GlobalVariables { + /** The identifier of the current pipeline execution. */ + public static readonly executionId = '#{codepipeline.PipelineExecutionId}'; +} + export interface ActionProperties { readonly actionName: string; readonly role?: iam.IRole; @@ -84,6 +95,13 @@ export interface ActionProperties { readonly artifactBounds: ActionArtifactBounds; readonly inputs?: Artifact[]; readonly outputs?: Artifact[]; + + /** + * The name of the namespace to use for variables emitted by this action. + * + * @default - a name will be generated, based on the stage and action names + */ + readonly variablesNamespace?: string; } export interface ActionBindOptions { @@ -181,6 +199,15 @@ export interface CommonActionProps { * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html */ readonly runOrder?: number; + + /** + * The name of the namespace to use for variables emitted by this action. + * + * @default - a name will be generated, based on the stage and action names, + * if any of the action's variables were referenced - otherwise, + * no namespace will be set + */ + readonly variablesNamespace?: string; } /** diff --git a/packages/@aws-cdk/aws-codepipeline/lib/full-action-descriptor.ts b/packages/@aws-cdk/aws-codepipeline/lib/full-action-descriptor.ts index e2aa2774bb5c3..b2759ff353b85 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/full-action-descriptor.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/full-action-descriptor.ts @@ -21,6 +21,7 @@ export class FullActionDescriptor { public readonly version: string; public readonly runOrder: number; public readonly artifactBounds: ActionArtifactBounds; + public readonly namespace?: string; public readonly inputs: Artifact[]; public readonly outputs: Artifact[]; public readonly region?: string; @@ -37,6 +38,7 @@ export class FullActionDescriptor { this.version = actionProperties.version || '1'; this.runOrder = actionProperties.runOrder === undefined ? 1 : actionProperties.runOrder; this.artifactBounds = actionProperties.artifactBounds; + this.namespace = actionProperties.variablesNamespace; this.inputs = deduplicateArtifacts(actionProperties.inputs); this.outputs = deduplicateArtifacts(actionProperties.outputs); this.region = props.actionRegion || actionProperties.region; diff --git a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts index 70480091e8371..5cb2e1465882f 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts @@ -8,7 +8,7 @@ import { CfnPipeline } from './codepipeline.generated'; import { CrossRegionSupportConstruct, CrossRegionSupportStack } from './cross-region-support-stack'; import { FullActionDescriptor } from './full-action-descriptor'; import { Stage } from './stage'; -import { validateName, validateSourceAction } from "./validation"; +import { validateName, validateNamespaceName, validateSourceAction } from "./validation"; /** * Allows you to control where to place a new Stage when it's added to the Pipeline. @@ -354,15 +354,18 @@ export class Pipeline extends PipelineBase { // get the role for the given action const actionRole = this.getRoleForAction(stage, action, actionScope); + // // CodePipeline Variables + validateNamespaceName(action.actionProperties.variablesNamespace); + // bind the Action - const actionDescriptor = action.bind(actionScope, stage, { + const actionConfig = action.bind(actionScope, stage, { role: actionRole ? actionRole : this.role, bucket: crossRegionInfo.artifactBucket, }); return new FullActionDescriptor({ action, - actionConfig: actionDescriptor, + actionConfig, actionRole, actionRegion: crossRegionInfo.region, }); diff --git a/packages/@aws-cdk/aws-codepipeline/lib/stage.ts b/packages/@aws-cdk/aws-codepipeline/lib/stage.ts index 15b31cefaf1d4..de236a3c30263 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/stage.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/stage.ts @@ -157,6 +157,7 @@ export class Stage implements IStage { runOrder: action.runOrder, roleArn: action.role ? action.role.roleArn : undefined, region: action.region, + namespace: action.namespace, }; } diff --git a/packages/@aws-cdk/aws-codepipeline/lib/validation.ts b/packages/@aws-cdk/aws-codepipeline/lib/validation.ts index c30e90eb0c2d4..821a13a2c9a1f 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/validation.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/validation.ts @@ -53,6 +53,10 @@ export function validateArtifactName(artifactName: string | undefined): void { validateAgainstRegex(/^[a-zA-Z0-9_-]{1,100}$/, 'Artifact', artifactName); } +export function validateNamespaceName(namespaceName: string | undefined): void { + validateAgainstRegex(/^[A-Za-z0-9@_-]{1,100}$/, 'Namespace', namespaceName); +} + function validateAgainstRegex(regex: RegExp, thing: string, name: string | undefined) { // name could be a Token - in that case, skip validation altogether if (cdk.Token.isUnresolved(name)) { diff --git a/packages/@aws-cdk/aws-codepipeline/package.json b/packages/@aws-cdk/aws-codepipeline/package.json index 779e52364608c..80e9841d45753 100644 --- a/packages/@aws-cdk/aws-codepipeline/package.json +++ b/packages/@aws-cdk/aws-codepipeline/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codepipeline", - "version": "1.19.0", + "version": "1.21.0", "description": "Better interface to AWS Code Pipeline", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -69,28 +69,28 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -120,6 +120,7 @@ "docs-public-apis:@aws-cdk/aws-codepipeline.ActionArtifactBounds.maxOutputs", "docs-public-apis:@aws-cdk/aws-codepipeline.ActionArtifactBounds.minInputs", "docs-public-apis:@aws-cdk/aws-codepipeline.ActionArtifactBounds.minOutputs", + "public-static-props-all-caps:@aws-cdk/aws-codepipeline.GlobalVariables.executionId", "docs-public-apis:@aws-cdk/aws-codepipeline.ActionBindOptions", "docs-public-apis:@aws-cdk/aws-codepipeline.ActionBindOptions.bucket", "docs-public-apis:@aws-cdk/aws-codepipeline.ActionBindOptions.role", @@ -161,4 +162,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts b/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts index 4496626a55c25..f1ba06d1f3128 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/fake-build-action.ts @@ -17,10 +17,13 @@ export interface FakeBuildActionProps extends codepipeline.CommonActionProps { account?: string; region?: string; + + customConfigKey?: string; } export class FakeBuildAction implements codepipeline.IAction { public readonly actionProperties: codepipeline.ActionProperties; + private readonly customConfigKey: string | undefined; constructor(props: FakeBuildActionProps) { this.actionProperties = { @@ -31,11 +34,16 @@ export class FakeBuildAction implements codepipeline.IAction { inputs: [props.input, ...props.extraInputs || []], outputs: props.output ? [props.output] : undefined, }; + this.customConfigKey = props.customConfigKey; } public bind(_scope: Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): codepipeline.ActionConfig { - return {}; + return { + configuration: { + CustomConfigKey: this.customConfigKey, + }, + }; } public onStateChange(_name: string, _target?: events.IRuleTarget, _options?: events.RuleProps): events.Rule { diff --git a/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts b/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts index c6f772e73a7df..099efb65b359a 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/fake-source-action.ts @@ -1,18 +1,23 @@ import * as events from '@aws-cdk/aws-events'; -import { Construct } from '@aws-cdk/core'; +import { Construct, Lazy } from '@aws-cdk/core'; import * as codepipeline from '../lib'; +export interface IFakeSourceActionVariables { + readonly firstVariable: string; +} + export interface FakeSourceActionProps extends codepipeline.CommonActionProps { - output: codepipeline.Artifact; + readonly output: codepipeline.Artifact; - extraOutputs?: codepipeline.Artifact[]; + readonly extraOutputs?: codepipeline.Artifact[]; - region?: string; + readonly region?: string; } export class FakeSourceAction implements codepipeline.IAction { public readonly inputs?: codepipeline.Artifact[]; public readonly outputs?: codepipeline.Artifact[]; + public readonly variables: IFakeSourceActionVariables; public readonly actionProperties: codepipeline.ActionProperties; @@ -24,6 +29,9 @@ export class FakeSourceAction implements codepipeline.IAction { artifactBounds: { minInputs: 0, maxInputs: 0, minOutputs: 1, maxOutputs: 4 }, outputs: [props.output, ...props.extraOutputs || []], }; + this.variables = { + firstVariable: Lazy.stringValue({ produce: () => `#{${this.actionProperties.variablesNamespace}.FirstVariable}` }), + }; } public bind(_scope: Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions): diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.variables.ts b/packages/@aws-cdk/aws-codepipeline/test/test.variables.ts new file mode 100644 index 0000000000000..4ae685ee976de --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline/test/test.variables.ts @@ -0,0 +1,144 @@ +import { expect, haveResourceLike } from '@aws-cdk/assert'; +import * as cdk from '@aws-cdk/core'; +import { Test } from 'nodeunit'; +import * as codepipeline from '../lib'; +import { FakeBuildAction } from './fake-build-action'; +import { FakeSourceAction } from './fake-source-action'; + +// tslint:disable:object-literal-key-quotes + +export = { + 'Pipeline Variables': { + 'uses the passed namespace when its passed when constructing the Action'(test: Test) { + const stack = new cdk.Stack(); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [new FakeSourceAction({ + actionName: 'Source', + output: new codepipeline.Artifact(), + variablesNamespace: 'MyNamespace', + })], + }, + ], + }); + + expect(stack, true).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + "Actions": [ + { + "Name": "Source", + "Namespace": "MyNamespace", + }, + ], + }, + ], + })); + + test.done(); + }, + + 'allows using the variable in the configuration of a different action'(test: Test) { + const stack = new cdk.Stack(); + const sourceOutput = new codepipeline.Artifact(); + const fakeSourceAction = new FakeSourceAction({ + actionName: 'Source', + output: sourceOutput, + variablesNamespace: 'SourceVariables', + }); + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [fakeSourceAction], + }, + { + stageName: 'Build', + actions: [new FakeBuildAction({ + actionName: 'Build', + input: sourceOutput, + customConfigKey: fakeSourceAction.variables.firstVariable, + })], + }, + ], + }); + + expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + }, + { + "Name": "Build", + "Actions": [ + { + "Name": "Build", + "Configuration": { + "CustomConfigKey": "#{SourceVariables.FirstVariable}", + }, + }, + ], + }, + ], + })); + + test.done(); + }, + + 'fails when trying add an action using variables with an empty string for the namespace to a pipeline'(test: Test) { + const stack = new cdk.Stack(); + const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); + const sourceStage = pipeline.addStage({ stageName: 'Source' }); + + const sourceAction = new FakeSourceAction({ + actionName: 'Source', + output: new codepipeline.Artifact(), + variablesNamespace: '', + }); + + test.throws(() => { + sourceStage.addAction(sourceAction); + }, /Namespace name must match regular expression:/); + + test.done(); + }, + + 'can use global variables'(test: Test) { + const stack = new cdk.Stack(); + + new codepipeline.Pipeline(stack, 'Pipeline', { + stages: [ + { + stageName: 'Source', + actions: [new FakeBuildAction({ + actionName: 'Build', + input: new codepipeline.Artifact(), + customConfigKey: codepipeline.GlobalVariables.executionId, + })], + }, + ], + }); + + expect(stack, true).to(haveResourceLike('AWS::CodePipeline::Pipeline', { + "Stages": [ + { + "Name": "Source", + "Actions": [ + { + "Name": "Build", + "Configuration": { + "CustomConfigKey": "#{codepipeline.PipelineExecutionId}", + }, + }, + ], + }, + ], + })); + + test.done(); + }, + }, +}; diff --git a/packages/@aws-cdk/aws-codestar/package.json b/packages/@aws-cdk/aws-codestar/package.json index 616fadaeb20ea..4abd43675c369 100644 --- a/packages/@aws-cdk/aws-codestar/package.json +++ b/packages/@aws-cdk/aws-codestar/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codestar", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::CodeStar", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codestarnotifications/package.json b/packages/@aws-cdk/aws-codestarnotifications/package.json index 51e6fd08376a5..af107a596a6b7 100644 --- a/packages/@aws-cdk/aws-codestarnotifications/package.json +++ b/packages/@aws-cdk/aws-codestarnotifications/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-codestarnotifications", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::CodeStarNotifications", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cognito/package.json b/packages/@aws-cdk/aws-cognito/package.json index f8ba452747b80..1d92b080a5ae8 100644 --- a/packages/@aws-cdk/aws-cognito/package.json +++ b/packages/@aws-cdk/aws-cognito/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-cognito", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Cognito", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,23 +62,23 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -108,4 +108,4 @@ ] }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-config/package.json b/packages/@aws-cdk/aws-config/package.json index 1c777f59ec680..2a1f96a1dfde1 100644 --- a/packages/@aws-cdk/aws-config/package.json +++ b/packages/@aws-cdk/aws-config/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-config", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Config", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,29 +62,29 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -99,4 +99,4 @@ "docs-public-apis:@aws-cdk/aws-config.MaximumExecutionFrequency.TWELVE_HOURS" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-datapipeline/package.json b/packages/@aws-cdk/aws-datapipeline/package.json index 2d76db42c735b..0f86703d7bfb2 100644 --- a/packages/@aws-cdk/aws-datapipeline/package.json +++ b/packages/@aws-cdk/aws-datapipeline/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-datapipeline", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::DataPipeline", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dax/package.json b/packages/@aws-cdk/aws-dax/package.json index 4e517d8c33a87..292ff66df7194 100644 --- a/packages/@aws-cdk/aws-dax/package.json +++ b/packages/@aws-cdk/aws-dax/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-dax", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::DAX", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-directoryservice/package.json b/packages/@aws-cdk/aws-directoryservice/package.json index 506c9fa3dd3be..b3a4193f77747 100644 --- a/packages/@aws-cdk/aws-directoryservice/package.json +++ b/packages/@aws-cdk/aws-directoryservice/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-directoryservice", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::DirectoryService", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dlm/package.json b/packages/@aws-cdk/aws-dlm/package.json index dbe0acf666573..8d677a5ad8167 100644 --- a/packages/@aws-cdk/aws-dlm/package.json +++ b/packages/@aws-cdk/aws-dlm/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-dlm", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::DLM", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dms/package.json b/packages/@aws-cdk/aws-dms/package.json index 87698021c582a..0597ca321a502 100644 --- a/packages/@aws-cdk/aws-dms/package.json +++ b/packages/@aws-cdk/aws-dms/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-dms", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::DMS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-docdb/package.json b/packages/@aws-cdk/aws-docdb/package.json index 5e694db43a5f8..d12eef3635c17 100644 --- a/packages/@aws-cdk/aws-docdb/package.json +++ b/packages/@aws-cdk/aws-docdb/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-docdb", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::DocDB", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file 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 73485f95de04a..8d5af8bd81b50 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 @@ -1,7 +1,7 @@ { "name": "aws-global-lambda-coordinator", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.", "main": "lib/handler.js", "directories": { diff --git a/packages/@aws-cdk/aws-dynamodb-global/package.json b/packages/@aws-cdk/aws-dynamodb-global/package.json index 8a143f19af2f1..24423184b5054 100644 --- a/packages/@aws-cdk/aws-dynamodb-global/package.json +++ b/packages/@aws-cdk/aws-dynamodb-global/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-dynamodb-global", - "version": "1.19.0", + "version": "1.21.0", "description": "Build a global dynamodb table", "license": "Apache-2.0", "homepage": "https://github.com/aws/aws-cdk", @@ -45,27 +45,27 @@ "global" ], "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "scripts": { "build": "cdk-build", @@ -87,4 +87,4 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-dynamodb/package.json b/packages/@aws-cdk/aws-dynamodb/package.json index e858e7726e426..b7dcfcde109e2 100644 --- a/packages/@aws-cdk/aws-dynamodb/package.json +++ b/packages/@aws-cdk/aws-dynamodb/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-dynamodb", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS DynamoDB", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,24 +62,24 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -106,4 +106,4 @@ "docs-public-apis:@aws-cdk/aws-dynamodb.ProjectionType.INCLUDE" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/README.md b/packages/@aws-cdk/aws-ec2/README.md index 6299f43307c07..1bdf16990fe67 100644 --- a/packages/@aws-cdk/aws-ec2/README.md +++ b/packages/@aws-cdk/aws-ec2/README.md @@ -434,6 +434,16 @@ myEndpoint.connections.allowDefaultPortFromAnyIpv4(); Alternatively, existing security groups can be used by specifying the `securityGroups` prop. +## VPC endpoint services +A VPC endpoint service enables you to expose a Network Load Balancer(s) as a provider service to consumers, who connect to your service over a VPC endpoint. You can restrict access to your service via whitelisted principals (anything that extends ArnPrincipal), and require that new connections be manually accepted. +```ts +new VpcEndpointService(this, "EndpointService", { + vpcEndpointServiceLoadBalancers: [networkLoadBalancer1, networkLoadBalancer2], + acceptanceRequired: true, + whitelistedPrincipals: [new ArnPrincipal("arn:aws:iam::123456789012:root")] +}); +``` + ## Bastion Hosts A bastion host functions as an instance used to access servers and resources in a VPC without open up the complete VPC on a network level. You can use bastion hosts using a standard SSH connection targetting port 22 on the host. As an alternative, you can connect the SSH connection diff --git a/packages/@aws-cdk/aws-ec2/lib/index.ts b/packages/@aws-cdk/aws-ec2/lib/index.ts index 2cbbd0fd8c698..c420f1d1b99b5 100644 --- a/packages/@aws-cdk/aws-ec2/lib/index.ts +++ b/packages/@aws-cdk/aws-ec2/lib/index.ts @@ -14,6 +14,7 @@ export * from './vpc'; export * from './vpc-lookup'; export * from './vpn'; export * from './vpc-endpoint'; +export * from './vpc-endpoint-service'; export * from './user-data'; export * from './windows-versions'; diff --git a/packages/@aws-cdk/aws-ec2/lib/peer.ts b/packages/@aws-cdk/aws-ec2/lib/peer.ts index 0af091cb7b890..bef1c90b11ed4 100644 --- a/packages/@aws-cdk/aws-ec2/lib/peer.ts +++ b/packages/@aws-cdk/aws-ec2/lib/peer.ts @@ -27,7 +27,17 @@ export interface IPeer extends IConnectable { } /** - * Factories for static connection peer + * Peer object factories (to be used in Security Group management) + * + * The static methods on this object can be used to create peer objects + * which represent a connection partner in Security Group rules. + * + * Use this object if you need to represent connection partners using plain IP + * addresses, or a prefix list ID. + * + * If you want to address a connection partner by Security Group, you can just + * use the Security Group (or the construct that contains a Security Group) + * directly, as it already implements `IPeer`. */ export class Peer { /** diff --git a/packages/@aws-cdk/aws-ec2/lib/security-group.ts b/packages/@aws-cdk/aws-ec2/lib/security-group.ts index 48179656f64f2..c900126a606b3 100644 --- a/packages/@aws-cdk/aws-ec2/lib/security-group.ts +++ b/packages/@aws-cdk/aws-ec2/lib/security-group.ts @@ -7,6 +7,9 @@ import { IVpc } from './vpc'; const SECURITY_GROUP_SYMBOL = Symbol.for('@aws-cdk/iam.SecurityGroup'); +/** + * Interface for security group-like objects + */ export interface ISecurityGroup extends IResource, IPeer { /** * ID for the current security group @@ -14,6 +17,11 @@ export interface ISecurityGroup extends IResource, IPeer { */ readonly securityGroupId: string; + /** + * Whether the SecurityGroup has been configured to allow all outbound traffic + */ + readonly allowAllOutbound: boolean; + /** * Add an ingress rule for the current security group * @@ -49,6 +57,7 @@ abstract class SecurityGroupBase extends Resource implements ISecurityGroup { } public abstract readonly securityGroupId: string; + public abstract readonly allowAllOutbound: boolean; public readonly canInlineRule = false; public readonly connections: Connections = new Connections({ securityGroups: [this] }); @@ -250,9 +259,38 @@ export interface SecurityGroupImportOptions { /** * Creates an Amazon EC2 security group within a VPC. * - * This class has an additional optimization over imported security groups that it can also create - * inline ingress and egress rule (which saves on the total number of resources inside - * the template). + * Security Groups act like a firewall with a set of rules, and are associated + * with any AWS resource that has or creates Elastic Network Interfaces (ENIs). + * A typical example of a resource that has a security group is an Instance (or + * Auto Scaling Group of instances) + * + * If you are defining new infrastructure in CDK, there is a good chance you + * won't have to interact with this class at all. Like IAM Roles, Security + * Groups need to exist to control access between AWS resources, but CDK will + * automatically generate and populate them with least-privilege permissions + * for you so you can concentrate on your business logic. + * + * All Constructs that require Security Groups will create one for you if you + * don't specify one at construction. After construction, you can selectively + * allow connections to and between constructs via--for example-- the `instance.connections` + * object. Think of it as "allowing connections to your instance", rather than + * "adding ingress rules a security group". See the [Allowing + * Connections](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-ec2-readme.html#allowing-connections) + * section in the library documentation for examples. + * + * Direct manipulation of the Security Group through `addIngressRule` and + * `addEgressRule` is possible, but mutation through the `.connections` object + * is recommended. If you peer two constructs with security groups this way, + * appropriate rules will be created in both. + * + * If you have an existing security group you want to use in your CDK application, + * you would import it like this: + * + * ```ts + * const securityGroup = SecurityGroup.fromSecurityGroupId(this, 'SG', 'sg-12345', { + * mutable: false + * }); + * ``` */ export class SecurityGroup extends SecurityGroupBase { @@ -262,6 +300,7 @@ export class SecurityGroup extends SecurityGroupBase { public static fromSecurityGroupId(scope: Construct, id: string, securityGroupId: string, options: SecurityGroupImportOptions = {}): ISecurityGroup { class MutableImport extends SecurityGroupBase { public securityGroupId = securityGroupId; + public allowAllOutbound = options.allowAllOutbound ?? true; public addEgressRule(peer: IPeer, connection: Port, description?: string, remoteRule?: boolean) { // Only if allowAllOutbound has been disabled @@ -273,6 +312,7 @@ export class SecurityGroup extends SecurityGroupBase { class ImmutableImport extends SecurityGroupBase { public securityGroupId = securityGroupId; + public allowAllOutbound = options.allowAllOutbound ?? true; public addEgressRule(_peer: IPeer, _connection: Port, _description?: string, _remoteRule?: boolean) { // do nothing @@ -309,12 +349,15 @@ export class SecurityGroup extends SecurityGroupBase { */ public readonly securityGroupVpcId: string; + /** + * Whether the SecurityGroup has been configured to allow all outbound traffic + */ + public readonly allowAllOutbound: boolean; + private readonly securityGroup: CfnSecurityGroup; private readonly directIngressRules: CfnSecurityGroup.IngressProperty[] = []; private readonly directEgressRules: CfnSecurityGroup.EgressProperty[] = []; - private readonly allowAllOutbound: boolean; - constructor(scope: Construct, id: string, props: SecurityGroupProps) { super(scope, id, { physicalName: props.securityGroupName diff --git a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint-service.ts b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint-service.ts new file mode 100644 index 0000000000000..cf3ead96cac0c --- /dev/null +++ b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint-service.ts @@ -0,0 +1,115 @@ +import { ArnPrincipal } from '@aws-cdk/aws-iam'; +import { Construct, IResource, Resource } from '@aws-cdk/core'; +import { CfnVPCEndpointService, CfnVPCEndpointServicePermissions } from './ec2.generated'; + +/** + * A load balancer that can host a VPC Endpoint Service + * + */ +export interface IVpcEndpointServiceLoadBalancer { + /** + * The ARN of the load balancer that hosts the VPC Endpoint Service + */ + readonly loadBalancerArn: string; +} + +/** + * A VPC endpoint service. + * @experimental + */ +export interface IVpcEndpointService extends IResource { + /** + * Name of the Vpc Endpoint Service + * @experimental + */ + readonly vpcEndpointServiceName?: string; +} + +/** + * A VPC endpoint service + * @resource AWS::EC2::VPCEndpointService + * @experimental + */ +export class VpcEndpointService extends Resource implements IVpcEndpointService { + + /** + * One or more network load balancer ARNs to host the service. + * @attribute + */ + public readonly vpcEndpointServiceLoadBalancers: IVpcEndpointServiceLoadBalancer[]; + + /** + * Whether to require manual acceptance of new connections to the service. + * @experimental + */ + public readonly acceptanceRequired: boolean; + + /** + * One or more Principal ARNs to allow inbound connections to. + * @experimental + */ + public readonly whitelistedPrincipals: ArnPrincipal[]; + + private readonly endpointService: CfnVPCEndpointService; + + constructor(scope: Construct, id: string, props: VpcEndpointServiceProps) { + super(scope, id); + + if (props.vpcEndpointServiceLoadBalancers === undefined || props.vpcEndpointServiceLoadBalancers.length === 0) { + throw new Error("VPC Endpoint Service must have at least one load balancer specified."); + } + + this.vpcEndpointServiceLoadBalancers = props.vpcEndpointServiceLoadBalancers; + this.acceptanceRequired = props.acceptanceRequired !== undefined ? props.acceptanceRequired : true; + this.whitelistedPrincipals = props.whitelistedPrincipals !== undefined ? props.whitelistedPrincipals : []; + + this.endpointService = new CfnVPCEndpointService(this, id, { + networkLoadBalancerArns: this.vpcEndpointServiceLoadBalancers.map(lb => lb.loadBalancerArn), + acceptanceRequired: this.acceptanceRequired + }); + + if (this.whitelistedPrincipals.length > 0) { + new CfnVPCEndpointServicePermissions(this, "Permissions", { + serviceId: this.endpointService.ref, + allowedPrincipals: this.whitelistedPrincipals.map(x => x.arn) + }); + } + } +} + +/** + * Construction properties for a VpcEndpointService. + * @experimental + */ +export interface VpcEndpointServiceProps { + + /** + * Name of the Vpc Endpoint Service + * @default - CDK generated name + * @experimental + */ + readonly vpcEndpointServiceName?: string; + + /** + * One or more load balancers to host the VPC Endpoint Service. + * @experimental + */ + readonly vpcEndpointServiceLoadBalancers: IVpcEndpointServiceLoadBalancer[]; + + /** + * Whether requests from service consumers to connect to the service through + * an endpoint must be accepted. + * @default true + * @experimental + */ + readonly acceptanceRequired?: boolean; + + /** + * IAM users, IAM roles, or AWS accounts to allow inbound connections from. + * These principals can connect to your service using VPC endpoints. Takes a + * list of one or more ArnPrincipal. + * @default - no principals + * @experimental + */ + readonly whitelistedPrincipals?: ArnPrincipal[]; +} diff --git a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts index 16510f853325c..6285f94966929 100644 --- a/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts +++ b/packages/@aws-cdk/aws-ec2/lib/vpc-endpoint.ts @@ -203,6 +203,27 @@ export interface IInterfaceVpcEndpointService { readonly port: number; } +/** + * A custom-hosted service for an interface VPC endpoint. + */ +export class InterfaceVpcEndpointService implements IInterfaceVpcEndpointService { + + /** + * The name of the service. + */ + public readonly name: string; + + /** + * The port of the service. + */ + public readonly port: number; + + constructor(name: string, port?: number) { + this.name = name; + this.port = port || 443; + } +} + /** * An AWS service for an interface VPC endpoint. */ diff --git a/packages/@aws-cdk/aws-ec2/package.json b/packages/@aws-cdk/aws-ec2/package.json index 34a32ea870e69..f4dd3983e898f 100644 --- a/packages/@aws-cdk/aws-ec2/package.json +++ b/packages/@aws-cdk/aws-ec2/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ec2", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS EC2", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,28 +62,28 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -466,4 +466,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint-service.expected.json b/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint-service.expected.json new file mode 100644 index 0000000000000..72c6f6bf0df9a --- /dev/null +++ b/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint-service.expected.json @@ -0,0 +1,33 @@ +{ + "Resources": { + "MyVpcEndpointServiceWithNoPrincipals9B24276E": { + "Type": "AWS::EC2::VPCEndpointService", + "Properties": { + "NetworkLoadBalancerArns": [ + "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a" + ], + "AcceptanceRequired": false + } + }, + "MyVpcEndpointServiceWithPrincipals41EE2DF2": { + "Type": "AWS::EC2::VPCEndpointService", + "Properties": { + "NetworkLoadBalancerArns": [ + "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/1jd81k39sa421ffs" + ], + "AcceptanceRequired": false + } + }, + "MyVpcEndpointServiceWithPrincipalsPermissions29F9BD5A": { + "Type": "AWS::EC2::VPCEndpointServicePermissions", + "Properties": { + "ServiceId": { + "Ref": "MyVpcEndpointServiceWithPrincipals41EE2DF2" + }, + "AllowedPrincipals": [ + "arn:aws:iam::123456789012:root" + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint-service.ts b/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint-service.ts new file mode 100644 index 0000000000000..9f3477c084244 --- /dev/null +++ b/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint-service.ts @@ -0,0 +1,46 @@ +import { ArnPrincipal } from '@aws-cdk/aws-iam'; +import * as cdk from '@aws-cdk/core'; +import * as ec2 from '../lib'; + +const app = new cdk.App(); + +/** + * A load balancer that can host a VPC Endpoint Service + */ +class DummyEndpointLoadBalacer implements ec2.IVpcEndpointServiceLoadBalancer { + /** + * The ARN of the load balancer that hosts the VPC Endpoint Service + */ + public readonly loadBalancerArn: string; + constructor(arn: string) { + this.loadBalancerArn = arn; + } +} + +class VpcEndpointServiceStack extends cdk.Stack { + constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { + super(scope, id, props); + + const nlbNoPrincipals = new DummyEndpointLoadBalacer( + "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"); + + new ec2.VpcEndpointService(this, "MyVpcEndpointServiceWithNoPrincipals", { + vpcEndpointServiceLoadBalancers: [nlbNoPrincipals], + acceptanceRequired: false, + whitelistedPrincipals: [] + }); + + const nlbWithPrincipals = new DummyEndpointLoadBalacer( + "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/1jd81k39sa421ffs"); + const principalArn = new ArnPrincipal("arn:aws:iam::123456789012:root"); + + new ec2.VpcEndpointService(this, "MyVpcEndpointServiceWithPrincipals", { + vpcEndpointServiceLoadBalancers: [nlbWithPrincipals], + acceptanceRequired: false, + whitelistedPrincipals: [principalArn] + }); + } +} + +new VpcEndpointServiceStack(app, 'aws-cdk-ec2-vpc-endpoint-service'); +app.synth(); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint-service.ts b/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint-service.ts new file mode 100644 index 0000000000000..15e85df6e4b5f --- /dev/null +++ b/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint-service.ts @@ -0,0 +1,106 @@ +import { expect, haveResource } from '@aws-cdk/assert'; +import { ArnPrincipal } from '@aws-cdk/aws-iam'; +import { Stack } from '@aws-cdk/core'; +import { Test } from 'nodeunit'; +// tslint:disable-next-line:max-line-length +import { IVpcEndpointServiceLoadBalancer, Vpc, VpcEndpointService } from '../lib'; + +/** + * A load balancer that can host a VPC Endpoint Service + */ +class DummyEndpointLoadBalacer implements IVpcEndpointServiceLoadBalancer { + /** + * The ARN of the load balancer that hosts the VPC Endpoint Service + */ + public readonly loadBalancerArn: string; + constructor(arn: string) { + this.loadBalancerArn = arn; + } +} + +export = { + 'test vpc endpoint service': { + 'create endpoint service with no principals'(test: Test) { + // GIVEN + const stack = new Stack(); + new Vpc(stack, "MyVPC"); + + // WHEN + const lb = new DummyEndpointLoadBalacer("arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"); + new VpcEndpointService(stack, "EndpointService", { + vpcEndpointServiceLoadBalancers: [lb], + acceptanceRequired: false, + whitelistedPrincipals: [new ArnPrincipal("arn:aws:iam::123456789012:root")] + }); + // THEN + expect(stack).to(haveResource('AWS::EC2::VPCEndpointService', { + NetworkLoadBalancerArns: ["arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"], + AcceptanceRequired: false + })); + + expect(stack).notTo(haveResource('AWS::EC2::VPCEndpointServicePermissions', { + ServiceId: { + Ref: "EndpointServiceED36BE1F" + }, + AllowedPrincipals: [] + })); + + test.done(); + }, + 'create endpoint service with a principal'(test: Test) { + // GIVEN + const stack = new Stack(); + + // WHEN + const lb = new DummyEndpointLoadBalacer("arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"); + new VpcEndpointService(stack, "EndpointService", { + vpcEndpointServiceLoadBalancers: [lb], + acceptanceRequired: false, + whitelistedPrincipals: [new ArnPrincipal("arn:aws:iam::123456789012:root")] + }); + + // THEN + expect(stack).to(haveResource('AWS::EC2::VPCEndpointService', { + NetworkLoadBalancerArns: ["arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"], + AcceptanceRequired: false + })); + + expect(stack).to(haveResource('AWS::EC2::VPCEndpointServicePermissions', { + ServiceId: { + Ref: "EndpointServiceED36BE1F" + }, + AllowedPrincipals: ["arn:aws:iam::123456789012:root"] + })); + + test.done(); + }, + + 'with acceptance requried'(test: Test) { + // GIVEN + const stack = new Stack(); + + // WHEN + const lb = new DummyEndpointLoadBalacer("arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"); + new VpcEndpointService(stack, "EndpointService", { + vpcEndpointServiceLoadBalancers: [lb], + acceptanceRequired: true, + whitelistedPrincipals: [new ArnPrincipal("arn:aws:iam::123456789012:root")] + }); + + // THEN + expect(stack).to(haveResource('AWS::EC2::VPCEndpointService', { + NetworkLoadBalancerArns: ["arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/Test/9bn6qkf4e9jrw77a"], + AcceptanceRequired: true + })); + + expect(stack).to(haveResource('AWS::EC2::VPCEndpointServicePermissions', { + ServiceId: { + Ref: "EndpointServiceED36BE1F" + }, + AllowedPrincipals: ["arn:aws:iam::123456789012:root"] + })); + + test.done(); + } + } +}; \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint.ts b/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint.ts index a2fcaa97b9164..fa538a49b67a6 100644 --- a/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint.ts +++ b/packages/@aws-cdk/aws-ec2/test/test.vpc-endpoint.ts @@ -3,7 +3,7 @@ import { AnyPrincipal, PolicyStatement } from '@aws-cdk/aws-iam'; import { Stack } from '@aws-cdk/core'; import { Test } from 'nodeunit'; // tslint:disable-next-line:max-line-length -import { GatewayVpcEndpoint, GatewayVpcEndpointAwsService, InterfaceVpcEndpoint, InterfaceVpcEndpointAwsService, SecurityGroup, SubnetType, Vpc } from '../lib'; +import { GatewayVpcEndpoint, GatewayVpcEndpointAwsService, InterfaceVpcEndpoint, InterfaceVpcEndpointAwsService, InterfaceVpcEndpointService, SecurityGroup, SubnetType, Vpc } from '../lib'; export = { 'gateway endpoint': { @@ -332,6 +332,23 @@ export = { }, )); test.done(); - } + }, + 'non-AWS service interface endpoint'(test: Test) { + // GIVEN + const stack = new Stack(); + const vpc = new Vpc(stack, 'VpcNetwork'); + + // WHEN + vpc.addInterfaceEndpoint('YourService', { + service: new InterfaceVpcEndpointService("com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc", 443) + }); + + // THEN + expect(stack).to(haveResource('AWS::EC2::VPCEndpoint', { + ServiceName: "com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc" + })); + + test.done(); + }, } }; diff --git a/packages/@aws-cdk/aws-ecr-assets/lib/adopt-repository/.gitignore b/packages/@aws-cdk/aws-ecr-assets/lib/adopt-repository/.gitignore deleted file mode 100644 index d4aa116a26c73..0000000000000 --- a/packages/@aws-cdk/aws-ecr-assets/lib/adopt-repository/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!*.js diff --git a/packages/@aws-cdk/aws-ecr-assets/lib/adopt-repository/handler.js b/packages/@aws-cdk/aws-ecr-assets/lib/adopt-repository/handler.js deleted file mode 100644 index 3d0cb009c8773..0000000000000 --- a/packages/@aws-cdk/aws-ecr-assets/lib/adopt-repository/handler.js +++ /dev/null @@ -1,131 +0,0 @@ -const AWS = require('aws-sdk'); -const ecr = new AWS.ECR(); - -exports.handler = async function(event, context, _callback, respond) { - respond = respond || respondCFN; - try { - console.log(JSON.stringify(event)); - - const markerStatement = { - Sid: event.StackId, - Effect: "Deny", - Action: "OwnedBy:CDKStack", - Principal: "*" - }; - - // The repository must already exist - async function getAdopter(name) { - try { - const policyResponse = await ecr.getRepositoryPolicy({ repositoryName: name }).promise(); - const policy = JSON.parse(policyResponse.policyText); - // Search the policy for an adopter marker - return (policy.Statement || []).find((x) => x.Action === markerStatement.Action) || {}; - } catch (e) { - if (e.code !== 'RepositoryPolicyNotFoundException') { throw e; } - return {}; - } - } - - let repo = event.ResourceProperties.RepositoryName; - if (!repo) { - throw new Error('Missing required property "RepositoryName"'); - } - const isRepoUri = repo.match(/^(\d+\.dkr\.ecr\.[^.]+\.[^/]+\/)(.+)$/i); - if (isRepoUri) { - repo = isRepoUri[2]; - } - - const adopter = await getAdopter(repo); - if (event.RequestType === 'Delete') { - if (!adopter.Sid) { - console.log(`Repository '${repo}' not found. Delete is no-op`); - } else { - if (adopter.Sid !== markerStatement.Sid) { - throw new Error(`This repository is already owned by another stack: ${adopter.Sid}`); - } - try { - console.log('Deleting', repo); - const ids = (await ecr.listImages({ repositoryName: repo }).promise()).imageIds; - await ecr.batchDeleteImage({ repositoryName: repo, imageIds: ids }).promise(); - await ecr.deleteRepository({ repositoryName: repo }).promise(); - } catch(e) { - if (e.code !== 'RepositoryNotFoundException') { throw e; } - } - } - } - - if (event.RequestType === 'Create' || event.RequestType === 'Update') { - if (adopter.Sid !== undefined && adopter.Sid !== markerStatement.Sid) { - throw new Error(`This repository is already owned by another stack: ${adopter.Sid}`); - } - console.log('Adopting', repo); - - const policy = event.ResourceProperties.PolicyDocument || { - Version: '2008-10-17', - Statement: [ ] - }; - - if (!policy.Version) { - policy.Version = '2008-10-17'; - } - - if (!policy.Statement) { - policy.Statement = [ ]; - } - - if (!Array.isArray(policy.Statement)) { - policy.Statement = [ policy.Statement ]; - } - - policy.Statement.push(markerStatement); - - console.log('policy document:', JSON.stringify(policy, undefined, 2)); - - await ecr.setRepositoryPolicy({ repositoryName: repo, policyText: JSON.stringify(policy) }).promise(); - } - - // we reflect back the repository name as a resource attribute - // this will allow taking an implicit dependency in this custom resource by - // referencing this attribute via { "Fn::GetAtt": [ ID, "RepositoryName" ] } - await respond("SUCCESS", "OK", repo, { - RepositoryName: repo - }); - } catch (e) { - console.log(e); - await respond("FAILED", e.message, context.logStreamName, {}); - } - - function respondCFN(responseStatus, reason, physId, data) { - const responseBody = JSON.stringify({ - Status: responseStatus, - Reason: reason, - PhysicalResourceId: physId, - StackId: event.StackId, - RequestId: event.RequestId, - LogicalResourceId: event.LogicalResourceId, - NoEcho: false, - Data: data - }); - - console.log('Responding', JSON.stringify(responseBody)); - - const parsedUrl = require('url').parse(event.ResponseURL); - const requestOptions = { - hostname: parsedUrl.hostname, - path: parsedUrl.path, - method: "PUT", - headers: { "content-type": "", "content-length": responseBody.length } - }; - - return new Promise((resolve, reject) => { - try { - const request = require('https').request(requestOptions, resolve); - request.on("error", reject); - request.write(responseBody); - request.end(); - } catch (e) { - reject(e); - } - }); - } -} diff --git a/packages/@aws-cdk/aws-ecr-assets/lib/adopted-repository.ts b/packages/@aws-cdk/aws-ecr-assets/lib/adopted-repository.ts deleted file mode 100644 index 6c68e1df64b6f..0000000000000 --- a/packages/@aws-cdk/aws-ecr-assets/lib/adopted-repository.ts +++ /dev/null @@ -1,94 +0,0 @@ -import * as cfn from '@aws-cdk/aws-cloudformation'; -import * as ecr from '@aws-cdk/aws-ecr'; -import * as iam from '@aws-cdk/aws-iam'; -import * as lambda from '@aws-cdk/aws-lambda'; -import * as cdk from '@aws-cdk/core'; -import * as path from 'path'; - -interface AdoptedRepositoryProps { - /** - * An ECR repository to adopt. Once adopted, the repository will - * practically become part of this stack, so it will be removed when - * the stack is deleted. - */ - repositoryName: string; -} - -/** - * An internal class used to adopt an ECR repository used for the locally built - * image into the stack. - * - * Since the repository is not created by the stack (but by the CDK toolkit), - * adopting will make the repository "owned" by the stack. It will be cleaned - * up when the stack gets deleted, to avoid leaving orphaned repositories on - * stack cleanup. - */ -export class AdoptedRepository extends ecr.RepositoryBase { - public readonly repositoryName: string; - public readonly repositoryArn: string; - - private readonly policyDocument = new iam.PolicyDocument(); - - constructor(scope: cdk.Construct, id: string, private readonly props: AdoptedRepositoryProps) { - super(scope, id); - - const fn = new lambda.SingletonFunction(this, 'Function', { - runtime: lambda.Runtime.NODEJS_10_X, - lambdaPurpose: 'AdoptEcrRepository', - handler: 'handler.handler', - code: lambda.Code.fromAsset(path.join(__dirname, 'adopt-repository')), - uuid: 'dbc60def-c595-44bc-aa5c-28c95d68f62c', - timeout: cdk.Duration.minutes(5) - }); - - fn.addToRolePolicy(new iam.PolicyStatement({ - resources: [ecr.Repository.arnForLocalRepository(props.repositoryName, this)], - actions: [ - 'ecr:GetRepositoryPolicy', - 'ecr:SetRepositoryPolicy', - 'ecr:DeleteRepository', - 'ecr:ListImages', - 'ecr:BatchDeleteImage' - ], - })); - - const adopter = new cfn.CustomResource(this, 'Resource', { - resourceType: 'Custom::ECRAdoptedRepository', - provider: cfn.CustomResourceProvider.lambda(fn), - properties: { - RepositoryName: props.repositoryName, - PolicyDocument: this.policyDocument - } - }); - if (fn.role) { - // Need to explicitly depend on the role's policies, so they are applied before we try to use them - adopter.node.addDependency(fn.role); - } - - // we use the Fn::GetAtt with the RepositoryName returned by the custom - // resource in order to implicitly create a dependency between consumers - // and the custom resource. - this.repositoryName = adopter.getAtt('RepositoryName').toString(); - - // this this repository is "local" to the stack (in the same region/account) - // we can render it's ARN from it's name. - this.repositoryArn = ecr.Repository.arnForLocalRepository(this.repositoryName, this); - } - - /** - * Export this repository from the stack - */ - public export() { - return this.props; - } - - /** - * Adds a statement to the repository resource policy. - * - * Contrary to normal imported repositories, which no-op here, we can - * use the custom resource to modify the ECR resource policy if needed. - */ - public addToResourcePolicy(statement: iam.PolicyStatement) { - this.policyDocument.addStatements(statement); - } -} diff --git a/packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts b/packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts index 1b733aafbab96..3a0cd48f2315c 100644 --- a/packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts +++ b/packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts @@ -3,9 +3,8 @@ import * as ecr from '@aws-cdk/aws-ecr'; import { Construct, Stack, Token } from '@aws-cdk/core'; import * as fs from 'fs'; import * as path from 'path'; -import { AdoptedRepository } from './adopted-repository'; -export interface DockerImageAssetProps extends assets.CopyOptions { +export interface DockerImageAssetProps extends assets.FingerprintOptions { /** * The directory where the Dockerfile is stored */ @@ -18,7 +17,10 @@ export interface DockerImageAssetProps extends assets.CopyOptions { * from a Kubernetes Pod. Note, this is only the repository name, without the * registry and the tag parts. * - * @default - automatically derived from the asset's ID. + * @default - the default ECR repository for CDK assets + * @deprecated to control the location of docker image assets, please override + * `Stack.addDockerImageAsset`. this feature will be removed in future + * releases. */ readonly repositoryName?: string; @@ -93,10 +95,30 @@ export class DockerImageAsset extends Construct implements assets.IAsset { exclude = [...exclude, ...fs.readFileSync(ignore).toString().split('\n').filter(e => !!e)]; } + if (props.repositoryName) { + this.node.addWarning(`DockerImageAsset.repositoryName is deprecated. Override "core.Stack.addDockerImageAsset" to control asset locations`); + } + + // include build context in "extra" so it will impact the hash + const extraHash: { [field: string]: any } = { }; + if (props.extraHash) { extraHash.user = props.extraHash; } + if (props.buildArgs) { extraHash.buildArgs = props.buildArgs; } + if (props.target) { extraHash.target = props.target; } + if (props.file) { extraHash.file = props.file; } + if (props.repositoryName) { extraHash.repositoryName = props.repositoryName; } + + // add "salt" to the hash in order to invalidate the image in the upgrade to + // 1.21.0 which removes the AdoptedRepository resource (and will cause the + // deletion of the ECR repository the app used). + extraHash.version = '1.21.0'; + const staging = new assets.Staging(this, 'Staging', { ...props, exclude, - sourcePath: dir + sourcePath: dir, + extraHash: Object.keys(extraHash).length === 0 + ? undefined + : JSON.stringify(extraHash) }); this.sourceHash = staging.sourceHash; @@ -106,18 +128,12 @@ export class DockerImageAsset extends Construct implements assets.IAsset { directoryName: staging.stagedPath, dockerBuildArgs: props.buildArgs, dockerBuildTarget: props.target, - dockerFile: file, - repositoryName: props.repositoryName || `cdk/${this.node.uniqueId.replace(/[:/]/g, '-').toLowerCase()}`, - sourceHash: staging.sourceHash + dockerFile: props.file, + repositoryName: props.repositoryName, + sourceHash: staging.sourceHash, }); - // Require that repository adoption happens first, so we route the - // input ARN into the Custom Resource and then get the URI which we use to - // refer to the image FROM the Custom Resource. - // - // If adoption fails (because the repository might be twice-adopted), we - // haven't already started using the image. - this.repository = new AdoptedRepository(this, 'AdoptRepository', { repositoryName: location.repositoryName }); + this.repository = ecr.Repository.fromRepositoryName(this, 'Repository', location.repositoryName); this.imageUri = location.imageUri; } } diff --git a/packages/@aws-cdk/aws-ecr-assets/package.json b/packages/@aws-cdk/aws-ecr-assets/package.json index 1fdd2ef71806b..be21f9ea40465 100644 --- a/packages/@aws-cdk/aws-ecr-assets/package.json +++ b/packages/@aws-cdk/aws-ecr-assets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ecr-assets", - "version": "1.19.0", + "version": "1.21.0", "description": "Docker image assets deployed to ECR", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -59,36 +59,36 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", "@types/proxyquire": "^1.3.28", - "aws-cdk": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "aws-cdk": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0", + "pkglint": "1.21.0", "proxyquire": "^2.1.3" }, "dependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "nyc": { "statements": 70 @@ -102,4 +102,4 @@ "docs-public-apis:@aws-cdk/aws-ecr-assets.DockerImageAssetProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecr-assets/test/demo-image-custom-docker-file/Dockerfile b/packages/@aws-cdk/aws-ecr-assets/test/demo-image-custom-docker-file/Dockerfile new file mode 100644 index 0000000000000..123b5670febc8 --- /dev/null +++ b/packages/@aws-cdk/aws-ecr-assets/test/demo-image-custom-docker-file/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.6 +EXPOSE 8000 +WORKDIR /src +ADD . /src +CMD python3 index.py diff --git a/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.expected.json b/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.expected.json index 01c97c292d139..1b289472b4cc1 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.expected.json +++ b/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.expected.json @@ -1,78 +1,18 @@ { "Resources": { - "DockerImageAdoptRepositoryA86481BC": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } + "MyUserDC45028B": { + "Type": "AWS::IAM::User" }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { + "MyUserDefaultPolicy7B897426": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyDocument": { "Statement": [ { "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" + "ecr:BatchCheckLayerAvailability", + "ecr:GetDownloadUrlForLayer", + "ecr:BatchGetImage" ], "Effect": "Allow", "Resource": { @@ -91,108 +31,26 @@ { "Ref": "AWS::AccountId" }, - ":repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } + ":repository/aws-cdk/assets" ] ] } + }, + { + "Action": "ecr:GetAuthorizationToken", + "Effect": "Allow", + "Resource": "*" } ], "Version": "2012-10-17" }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ + "PolicyName": "MyUserDefaultPolicy7B897426", + "Users": [ { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" + "Ref": "MyUserDC45028B" } ] } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - } - }, - "Parameters": { - "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" } }, "Outputs": { @@ -212,37 +70,10 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } + "/aws-cdk/assets:baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540" ] ] } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.ts b/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.ts index e9123cd842d84..b5d9347de5cc6 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.ts +++ b/packages/@aws-cdk/aws-ecr-assets/test/integ.assets-docker.ts @@ -1,3 +1,4 @@ +import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; import * as path from 'path'; import * as assets from '../lib'; @@ -9,6 +10,14 @@ const asset = new assets.DockerImageAsset(stack, 'DockerImage', { directory: path.join(__dirname, 'demo-image'), }); +const asset2 = new assets.DockerImageAsset(stack, 'DockerImage2', { + directory: path.join(__dirname, 'demo-image'), +}); + +const user = new iam.User(stack, 'MyUser'); +asset.repository.grantPull(user); +asset2.repository.grantPull(user); + new cdk.CfnOutput(stack, 'ImageUri', { value: asset.imageUri }); app.synth(); diff --git a/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.expected.json b/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.expected.json index 39ad3e28fc6ce..0a189b5e6d229 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.expected.json +++ b/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.expected.json @@ -17,7 +17,7 @@ }, "/", { - "Ref": "AssetParametersce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddcS3Bucket9C1F8CF3" + "Ref": "AssetParameters3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775S3Bucket6CE4FC69" }, "/", { @@ -27,7 +27,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddcS3VersionKeyD34A6061" + "Ref": "AssetParameters3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775S3VersionKey5FE1DA58" } ] } @@ -40,7 +40,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddcS3VersionKeyD34A6061" + "Ref": "AssetParameters3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775S3VersionKey5FE1DA58" } ] } @@ -48,49 +48,22 @@ } ] ] - }, - "Parameters": { - "referencetonestedstacksdockerAssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName6A10D714Ref": { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - }, - "referencetonestedstacksdockerAssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketDC016D33Ref": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "referencetonestedstacksdockerAssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey3A8B3E45Ref": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } } } } }, "Parameters": { - "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3": { + "AssetParameters3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775S3Bucket6CE4FC69": { "Type": "String", - "Description": "ECR repository name and tag for asset \"1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c\"" + "Description": "S3 bucket for asset \"3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775\"" }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { + "AssetParameters3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775S3VersionKey5FE1DA58": { "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" + "Description": "S3 key for asset version \"3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775\"" }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { + "AssetParameters3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775ArtifactHash5D96BEC9": { "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddcS3Bucket9C1F8CF3": { - "Type": "String", - "Description": "S3 bucket for asset \"ce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddc\"" - }, - "AssetParametersce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddcS3VersionKeyD34A6061": { - "Type": "String", - "Description": "S3 key for asset version \"ce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddc\"" - }, - "AssetParametersce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddcArtifactHash3F66D1AC": { - "Type": "String", - "Description": "Artifact hash for asset \"ce471cbd591a9b42ec50b0bb34562bf37cf4e3c95f4ba7d4cf79a4a6b7d11ddc\"" + "Description": "Artifact hash for asset \"3e9c40a6bf877a4b814d5ca4817c057400e4f8f661cd52c8951bf40f5763b775\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts b/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts index 16a334a2e9e03..69484c7da852a 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts +++ b/packages/@aws-cdk/aws-ecr-assets/test/integ.nested-stacks-docker.ts @@ -1,4 +1,5 @@ import * as cfn from '@aws-cdk/aws-cloudformation'; +import * as iam from '@aws-cdk/aws-iam'; import { App, CfnOutput, Construct, Stack, StackProps } from '@aws-cdk/core'; import * as path from 'path'; import * as ecr_assets from '../lib'; @@ -11,6 +12,9 @@ class TheNestedStack extends cfn.NestedStack { directory: path.join(__dirname, 'demo-image') }); + const user = new iam.User(this, 'User'); + asset.repository.grantPull(user); + new CfnOutput(this, 'output', { value: asset.imageUri }); } } diff --git a/packages/@aws-cdk/aws-ecr-assets/test/test.adpot-repo.ts b/packages/@aws-cdk/aws-ecr-assets/test/test.adpot-repo.ts deleted file mode 100644 index 8ea9e093cd766..0000000000000 --- a/packages/@aws-cdk/aws-ecr-assets/test/test.adpot-repo.ts +++ /dev/null @@ -1,371 +0,0 @@ -import { Test } from 'nodeunit'; -import * as path from 'path'; -import * as proxyquire from 'proxyquire'; - -let ecrMock: any; - -export = { - async 'exercise handler create with policy'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { - '@noCallThru': true, - "ECR": ECRWithEmptyPolicy, - } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - PolicyDocument: { - Version: '2008-10-01', - My: 'Document' - } - }, - RequestType: 'Create', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(JSON.parse(ecrMock.lastSetRepositoryPolicyRequest.policyText), { - My: "Document", - Version: '2008-10-01', - Statement: [ - { Sid: "StackId", Effect: "Deny", Action: "OwnedBy:CDKStack", Principal: "*" } - ] - }); - - test.deepEqual(output, { - responseStatus: 'SUCCESS', - reason: 'OK', - physId: 'RepositoryName', - data: { - RepositoryName: 'RepositoryName' - } - }); - - test.done(); - }, - - async 'exercise handler create with policy with object statement'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { - '@noCallThru': true, - "ECR": ECRWithEmptyPolicy, - } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - PolicyDocument: { - Statement: { Action: 'boom' } - } - }, - RequestType: 'Create', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(JSON.parse(ecrMock.lastSetRepositoryPolicyRequest.policyText), { - Version: '2008-10-17', - Statement: [ - { Action: 'boom' }, - { Sid: "StackId", Effect: "Deny", Action: "OwnedBy:CDKStack", Principal: "*" } - ] - }); - - test.deepEqual(output, { - responseStatus: 'SUCCESS', - reason: 'OK', - physId: 'RepositoryName', - data: { - RepositoryName: 'RepositoryName' - } - }); - - test.done(); - }, - - async 'exercise handler create with policy with array statement'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { - '@noCallThru': true, - "ECR": ECRWithEmptyPolicy, - } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - PolicyDocument: { - Statement: [ { Action: 'boom' }, { Resource: "foo" } ] - } - }, - RequestType: 'Create', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(JSON.parse(ecrMock.lastSetRepositoryPolicyRequest.policyText), { - Version: '2008-10-17', - Statement: [ - { Action: "boom" }, - { Resource: "foo" }, - { Sid: "StackId", Effect: "Deny", Action: "OwnedBy:CDKStack", Principal: "*" } - ] - }); - - test.deepEqual(output, { - responseStatus: 'SUCCESS', - reason: 'OK', - physId: 'RepositoryName', - data: { - RepositoryName: 'RepositoryName' - } - }); - - test.done(); - }, - - async 'exercise handler create'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { - '@noCallThru': true, - "ECR": ECRWithEmptyPolicy, - } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - }, - RequestType: 'Create', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(output, { - responseStatus: 'SUCCESS', - reason: 'OK', - physId: 'RepositoryName', - data: { - RepositoryName: 'RepositoryName' - } - }); - - test.done(); - }, - - async 'exercise handler delete'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { '@noCallThru': true, "ECR": ECRWithOwningPolicy } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - }, - RequestType: 'Delete', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(output, { - responseStatus: 'SUCCESS', - reason: 'OK', - physId: 'RepositoryName', - data: { - RepositoryName: 'RepositoryName' - } - }); - - test.done(); - }, - - async 'exercise "delete" handler when repository doesnt exist'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { '@noCallThru': true, "ECR": ECRWithRepositoryNotFound } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - }, - RequestType: 'Delete', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(output, { - responseStatus: 'SUCCESS', - reason: 'OK', - physId: 'RepositoryName', - data: { - RepositoryName: 'RepositoryName' - } - }); - - test.done(); - }, - - async 'exercise "create" handler when repository doesnt exist'(test: Test) { - const handler = proxyquire(path.resolve(__dirname, '..', 'lib', 'adopt-repository', 'handler'), { - 'aws-sdk': { '@noCallThru': true, "ECR": ECRWithRepositoryNotFound } - }); - - let output; - async function response(responseStatus: string, reason: string, physId: string, data: any) { - output = { responseStatus, reason, physId, data }; - } - - await handler.handler({ - StackId: 'StackId', - ResourceProperties: { - RepositoryName: 'RepositoryName', - }, - RequestType: 'Create', - ResponseURL: 'https://localhost/test' - }, { - logStreamName: 'xyz', - }, undefined, response); - - test.deepEqual(output, { - responseStatus: 'FAILED', - reason: 'Simulated RepositoryPolicyNotFoundException', - physId: 'xyz', - data: { } - }); - - test.done(); - }, -}; - -function ECRWithEmptyPolicy() { - ecrMock = new ECR({ asdf: 'asdf' }); - return ecrMock; -} - -function ECRWithOwningPolicy() { - return new ECR({ - Statement: [ - { - Sid: 'StackId', - Effect: "Deny", - Action: "OwnedBy:CDKStack", - Principal: "*" - } - ] - }); -} - -function ECRWithRepositoryNotFound() { - const ecr = new ECR({}); - ecr.shouldThrowNotFound = true; - return ecr; -} - -class ECR { - public lastSetRepositoryPolicyRequest: any; - public shouldThrowNotFound = false; - - public constructor(private policy: any) { - } - - public getRepositoryPolicy() { - const self = this; - return { - async promise() { - if (self.shouldThrowNotFound) { return self.throwNotFound(); } - return { policyText: JSON.stringify(self.policy) }; - } - }; - } - - public setRepositoryPolicy(req: any) { - const self = this; - this.lastSetRepositoryPolicyRequest = req; - - return { - async promise() { - if (self.shouldThrowNotFound) { return self.throwNotFound(); } - return; - } - }; - } - - public listImages() { - return { - async promise() { - return { imageIds: [] }; - } - }; - } - - public batchDeleteImage() { - const self = this; - return { - async promise() { - if (self.shouldThrowNotFound) { return self.throwNotFound(); } - return {}; - } - }; - } - - public deleteRepository() { - const self = this; - return { - async promise() { - if (self.shouldThrowNotFound) { return self.throwNotFound(); } - return {}; - } - }; - } - - private throwNotFound() { - const err = new Error('Simulated RepositoryPolicyNotFoundException'); - (err as any).code = 'RepositoryPolicyNotFoundException'; - throw err; - } -} diff --git a/packages/@aws-cdk/aws-ecr-assets/test/test.image-asset.ts b/packages/@aws-cdk/aws-ecr-assets/test/test.image-asset.ts index 1d109532c433c..d704c3f00f5c7 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/test.image-asset.ts +++ b/packages/@aws-cdk/aws-ecr-assets/test/test.image-asset.ts @@ -1,6 +1,6 @@ -import { expect, haveResource, SynthUtils } from '@aws-cdk/assert'; +import { expect, haveResource } from '@aws-cdk/assert'; import * as iam from '@aws-cdk/aws-iam'; -import { App, Construct, Lazy, Resource, Stack } from '@aws-cdk/core'; +import { App, Lazy, Stack } from '@aws-cdk/core'; import { ASSET_METADATA } from '@aws-cdk/cx-api'; import * as fs from 'fs'; import { Test } from 'nodeunit'; @@ -12,7 +12,8 @@ import { DockerImageAsset } from '../lib'; export = { 'test instantiating Asset Image'(test: Test) { // GIVEN - const stack = new Stack(); + const app = new App(); + const stack = new Stack(app, 'test-stack'); // WHEN new DockerImageAsset(stack, 'Image', { @@ -20,33 +21,19 @@ export = { }); // THEN - const template = SynthUtils.synthesize(stack).template; - test.deepEqual(template.Parameters.AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3, { - Type: 'String', - Description: 'ECR repository name and tag for asset "1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c"' - }); - - test.done(); - }, - - 'repository name is derived from node unique id'(test: Test) { - // GIVEN - const stack = new Stack(); - class CoolConstruct extends Resource { - constructor(scope: Construct, id: string) { - super(scope, id); + const asm = app.synth(); + const artifact = asm.getStackArtifact(stack.artifactId); + test.deepEqual(artifact.template, {}, 'template is empty'); + test.deepEqual(artifact.assets, [ + { + repositoryName: 'aws-cdk/assets', + imageTag: 'baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540', + id: 'baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540', + packaging: 'container-image', + path: 'asset.baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540', + sourceHash: 'baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540' } - } - const coolConstruct = new CoolConstruct(stack, 'CoolConstruct'); - - // WHEN - new DockerImageAsset(coolConstruct, 'Image', { - directory: path.join(__dirname, 'demo-image'), - }); - - // THEN - const assetMetadata = stack.node.metadata.find(({ type }) => type === ASSET_METADATA); - test.deepEqual(assetMetadata && assetMetadata.data.repositoryName, 'cdk/coolconstructimage78ab38fc'); + ]); test.done(); }, @@ -100,7 +87,7 @@ export = { // THEN const assetMetadata = stack.node.metadata.find(({ type }) => type === ASSET_METADATA); - test.deepEqual(assetMetadata && assetMetadata.data.file, path.join(directoryPath, 'Dockerfile.Custom')); + test.deepEqual(assetMetadata && assetMetadata.data.file, 'Dockerfile.Custom'); test.done(); }, @@ -131,13 +118,18 @@ export = { "", [ "arn:", - { "Ref": "AWS::Partition" }, + { + "Ref": "AWS::Partition" + }, ":ecr:", - { "Ref": "AWS::Region" }, + { + "Ref": "AWS::Region" + }, ":", - { "Ref": "AWS::AccountId" }, - ":repository/", - { "Fn::GetAtt": ["ImageAdoptRepositoryE1E84E35", "RepositoryName"] } + { + "Ref": "AWS::AccountId" + }, + ":repository/aws-cdk/assets" ] ] } @@ -161,51 +153,6 @@ export = { test.done(); }, - 'asset.repository.addToResourcePolicy can be used to modify the ECR resource policy via the adoption custom resource'(test: Test) { - // GIVEN - const stack = new Stack(); - const asset = new DockerImageAsset(stack, 'Image', { - directory: path.join(__dirname, 'demo-image') - }); - - // WHEN - asset.repository.addToResourcePolicy(new iam.PolicyStatement({ - actions: ['BAM:BOOM'], - principals: [new iam.ServicePrincipal('test.service')] - })); - - // THEN - expect(stack).to(haveResource('Custom::ECRAdoptedRepository', { - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - }, - "PolicyDocument": { - "Statement": [ - { - "Action": "BAM:BOOM", - "Effect": "Allow", - "Principal": { - "Service": "test.service" - } - } - ], - "Version": "2012-10-17" - } - })); - - test.done(); - }, - 'fails if the directory does not exist'(test: Test) { // GIVEN const stack = new Stack(); @@ -334,6 +281,29 @@ export = { repositoryName: token }), /Cannot use Token as value of 'repositoryName'/); + test.done(); + }, + + 'docker build options are included in the asset id'(test: Test) { + // GIVEN + const stack = new Stack(); + const directory = path.join(__dirname, 'demo-image-custom-docker-file'); + + const asset1 = new DockerImageAsset(stack, 'Asset1', { directory }); + const asset2 = new DockerImageAsset(stack, 'Asset2', { directory, file: 'Dockerfile.Custom' }); + const asset3 = new DockerImageAsset(stack, 'Asset3', { directory, target: 'NonDefaultTarget' }); + const asset4 = new DockerImageAsset(stack, 'Asset4', { directory, buildArgs: { opt1: '123', opt2: 'boom' } }); + const asset5 = new DockerImageAsset(stack, 'Asset5', { directory, file: 'Dockerfile.Custom', target: 'NonDefaultTarget' }); + const asset6 = new DockerImageAsset(stack, 'Asset6', { directory, extraHash: 'random-extra' }); + const asset7 = new DockerImageAsset(stack, 'Asset7', { directory, repositoryName: 'foo' }); + + test.deepEqual(asset1.sourceHash, '31959f03fcdf1bddec1420d315dddedfccf559e87e95c85854a01f2cac103fc8'); + test.deepEqual(asset2.sourceHash, 'a42cd51ab2bc5e2a4399c4bc41f7df761ff19877b54bce52d69c6e8d628f16fd'); + test.deepEqual(asset3.sourceHash, '9efbc91d5c2f43782e49b27e784caad32d8619a0cecf806a6e55cf70f1cfbc22'); + test.deepEqual(asset4.sourceHash, '2907224e59cb720ba5810a624f1c1267f547377e8a23c50d72286dd81dc8435e'); + test.deepEqual(asset5.sourceHash, 'd718928111c650564240141b156188ebdbb93d3c5f1448dd1afe823ae7f742a5'); + test.deepEqual(asset6.sourceHash, 'fe3ef82c91b6321ac17bc3a14c75845fa1ddbafe550e0a04d5cf680015903a2d'); + test.deepEqual(asset7.sourceHash, '80f586ed82faacec8a285dd99c7ee52e06525fee1721bc80bc846d1a8266fe36'); test.done(); } }; diff --git a/packages/@aws-cdk/aws-ecr/package.json b/packages/@aws-cdk/aws-ecr/package.json index 373837ae3076d..4ee375356847b 100644 --- a/packages/@aws-cdk/aws-ecr/package.json +++ b/packages/@aws-cdk/aws-ecr/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ecr", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ECR", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -66,24 +66,24 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -104,4 +104,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts index b6a0980732b10..4d305ad2940c2 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts @@ -3,7 +3,7 @@ import { IVpc } from '@aws-cdk/aws-ec2'; import { AwsLogDriver, BaseService, CloudMapOptions, Cluster, ContainerImage, ICluster, LogDriver, PropagatedTagSource, Secret } from '@aws-cdk/aws-ecs'; import { ApplicationListener, ApplicationLoadBalancer, ApplicationProtocol, ApplicationTargetGroup, ListenerCertificate } from '@aws-cdk/aws-elasticloadbalancingv2'; import { IRole } from '@aws-cdk/aws-iam'; -import { AddressRecordTarget, ARecord, IHostedZone } from '@aws-cdk/aws-route53'; +import { ARecord, IHostedZone, RecordTarget } from '@aws-cdk/aws-route53'; import { LoadBalancerTarget } from '@aws-cdk/aws-route53-targets'; import * as cdk from '@aws-cdk/core'; @@ -342,7 +342,7 @@ export abstract class ApplicationLoadBalancedServiceBase extends cdk.Construct { const record = new ARecord(this, "DNS", { zone: props.domainZone, recordName: props.domainName, - target: AddressRecordTarget.fromAlias(new LoadBalancerTarget(this.loadBalancer)), + target: RecordTarget.fromAlias(new LoadBalancerTarget(this.loadBalancer)), }); domainName = record.domainName; diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts index c29c56a5de8cc..803846f1d7b68 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts @@ -4,7 +4,7 @@ import { AwsLogDriver, BaseService, CloudMapOptions, Cluster, ContainerDefinitio Protocol, Secret } from '@aws-cdk/aws-ecs'; import { ApplicationListener, ApplicationLoadBalancer, ApplicationProtocol, ApplicationTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2'; import { IRole } from '@aws-cdk/aws-iam'; -import { AddressRecordTarget, ARecord, IHostedZone } from '@aws-cdk/aws-route53'; +import { ARecord, IHostedZone, RecordTarget } from '@aws-cdk/aws-route53'; import { LoadBalancerTarget } from '@aws-cdk/aws-route53-targets'; import { CfnOutput, Construct, Duration, Stack } from '@aws-cdk/core'; @@ -561,7 +561,7 @@ export abstract class ApplicationMultipleTargetGroupsServiceBase extends Constru const record = new ARecord(this, `DNS${loadBalancer.node.id}`, { zone, recordName: name, - target: AddressRecordTarget.fromAlias(new LoadBalancerTarget(loadBalancer)), + target: RecordTarget.fromAlias(new LoadBalancerTarget(loadBalancer)), }); domainName = record.domainName; diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts index 7e0e355b01b5b..b6dd6492edbef 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-load-balanced-service-base.ts @@ -2,7 +2,7 @@ import { IVpc } from '@aws-cdk/aws-ec2'; import { AwsLogDriver, BaseService, CloudMapOptions, Cluster, ContainerImage, ICluster, LogDriver, PropagatedTagSource, Secret } from '@aws-cdk/aws-ecs'; import { NetworkListener, NetworkLoadBalancer, NetworkTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2'; import { IRole } from '@aws-cdk/aws-iam'; -import { AddressRecordTarget, ARecord, IHostedZone } from '@aws-cdk/aws-route53'; +import { ARecord, IHostedZone, RecordTarget } from '@aws-cdk/aws-route53'; import { LoadBalancerTarget } from '@aws-cdk/aws-route53-targets'; import * as cdk from '@aws-cdk/core'; @@ -287,7 +287,7 @@ export abstract class NetworkLoadBalancedServiceBase extends cdk.Construct { new ARecord(this, "DNS", { zone: props.domainZone, recordName: props.domainName, - target: AddressRecordTarget.fromAlias(new LoadBalancerTarget(this.loadBalancer)), + target: RecordTarget.fromAlias(new LoadBalancerTarget(this.loadBalancer)), }); } diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts index 1ed2d0f6b353d..2fc26dcdb586e 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/base/network-multiple-target-groups-service-base.ts @@ -3,7 +3,7 @@ import { AwsLogDriver, BaseService, CloudMapOptions, Cluster, ContainerDefinitio PropagatedTagSource, Protocol, Secret } from '@aws-cdk/aws-ecs'; import { NetworkListener, NetworkLoadBalancer, NetworkTargetGroup } from '@aws-cdk/aws-elasticloadbalancingv2'; import { IRole } from '@aws-cdk/aws-iam'; -import { AddressRecordTarget, ARecord, IHostedZone } from '@aws-cdk/aws-route53'; +import { ARecord, IHostedZone, RecordTarget } from '@aws-cdk/aws-route53'; import { LoadBalancerTarget } from '@aws-cdk/aws-route53-targets'; import { CfnOutput, Construct, Duration, Stack } from '@aws-cdk/core'; @@ -430,7 +430,7 @@ export abstract class NetworkMultipleTargetGroupsServiceBase extends Construct { new ARecord(this, `DNS${loadBalancer.node.id}`, { zone, recordName: name, - target: AddressRecordTarget.fromAlias(new LoadBalancerTarget(loadBalancer)), + target: RecordTarget.fromAlias(new LoadBalancerTarget(loadBalancer)), }); } } diff --git a/packages/@aws-cdk/aws-ecs-patterns/package.json b/packages/@aws-cdk/aws-ecs-patterns/package.json index 99997f8a8dc8d..99d2b737d2ce3 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/package.json +++ b/packages/@aws-cdk/aws-ecs-patterns/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ecs-patterns", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS ECS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -60,45 +60,45 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -112,4 +112,4 @@ "docs-public-apis:@aws-cdk/aws-ecs-patterns.ScheduledTaskImageProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json index 7cf939ff66ebb..63e74d7cadb80 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.asset-image.expected.json @@ -491,34 +491,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } + "/aws-cdk/assets:baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540" ] ] }, @@ -564,36 +537,6 @@ } } }, - "FargateServiceTaskDefwebAssetImageAdoptRepositoryCDAFD419": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "FargateServiceTaskDefwebLogGroup71FAF541": { "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", @@ -644,13 +587,7 @@ { "Ref": "AWS::AccountId" }, - ":repository/", - { - "Fn::GetAtt": [ - "FargateServiceTaskDefwebAssetImageAdoptRepositoryCDAFD419", - "RepositoryName" - ] - } + ":repository/aws-cdk/assets" ] ] } @@ -773,152 +710,6 @@ }, "ToPort": 8000 } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] } }, "Outputs": { @@ -954,23 +745,5 @@ ] } } - }, - "Parameters": { - "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.scheduled-fargate-task.lit.expected.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.scheduled-fargate-task.lit.expected.json index d7456b3e52042..8b53d3042133f 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.scheduled-fargate-task.lit.expected.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.scheduled-fargate-task.lit.expected.json @@ -293,34 +293,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } + "/aws-cdk/assets:baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540" ] ] }, @@ -360,36 +333,6 @@ } } }, - "ScheduledFargateTaskScheduledTaskDefScheduledContainerAssetImageAdoptRepository49B45957": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "ScheduledFargateTaskScheduledTaskDefScheduledContainerLogGroup4134B16C": { "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", @@ -440,13 +383,7 @@ { "Ref": "AWS::AccountId" }, - ":repository/", - { - "Fn::GetAtt": [ - "ScheduledFargateTaskScheduledTaskDefScheduledContainerAssetImageAdoptRepository49B45957", - "RepositoryName" - ] - } + ":repository/aws-cdk/assets" ] ] } @@ -565,170 +502,6 @@ } ] } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - } - }, - "Parameters": { - "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/README.md b/packages/@aws-cdk/aws-ecs/README.md index 446fb8ed1dd63..80b299f670175 100644 --- a/packages/@aws-cdk/aws-ecs/README.md +++ b/packages/@aws-cdk/aws-ecs/README.md @@ -53,9 +53,9 @@ const ecsService = new ecs.Ec2Service(this, 'Service', { For a set of constructs defining common ECS architectural patterns, see the `@aws-cdk/aws-ecs-patterns` package. -## AWS Fargate vs Amazon ECS +## Launch Types: AWS Fargate vs Amazon EC2 -There are two sets of constructs in this library; one to run tasks on Amazon ECS and +There are two sets of constructs in this library; one to run tasks on Amazon EC2 and one to run tasks on AWS Fargate. - Use the `Ec2TaskDefinition` and `Ec2Service` constructs to run tasks on Amazon EC2 instances running in your account. diff --git a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts index 9220b2e4d5da6..13877c0785126 100644 --- a/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts +++ b/packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts @@ -1,5 +1,5 @@ import * as ec2 from '@aws-cdk/aws-ec2'; -import { Construct, Lazy, Resource } from '@aws-cdk/core'; +import { Construct, Lazy, Resource, Stack } from '@aws-cdk/core'; import { BaseService, BaseServiceOptions, IService, LaunchType, PropagatedTagSource } from '../base/base-service'; import { NetworkMode, TaskDefinition } from '../base/task-definition'; import { CfnService } from '../ecs.generated'; @@ -160,9 +160,16 @@ export class Ec2Service extends BaseService implements IEc2Service { if (props.taskDefinition.networkMode === NetworkMode.AWS_VPC) { this.configureAwsVpcNetworking(props.cluster.vpc, props.assignPublicIp, props.vpcSubnets, props.securityGroup); } else { - // Either None, Bridge or Host networking. Copy SecurityGroup from ASG. + // Either None, Bridge or Host networking. Copy SecurityGroups from ASG. + // We have to be smart here -- by default future Security Group rules would be created + // in the Cluster stack. However, if the Cluster is in a different stack than us, + // that will lead to a cyclic reference (we point to that stack for the cluster name, + // but that stack will point to the ALB probably created right next to us). + // + // In that case, reference the same security groups but make sure new rules are + // created in the current scope (i.e., this stack) validateNoNetworkingProps(props); - this.connections.addSecurityGroup(...props.cluster.connections.securityGroups); + this.connections.addSecurityGroup(...securityGroupsInThisStack(this, props.cluster.connections.securityGroups)); } this.addPlacementConstraints(...props.placementConstraints || []); @@ -218,6 +225,28 @@ function validateNoNetworkingProps(props: Ec2ServiceProps) { } } +/** + * Force security group rules to be created in this stack. + * + * For every security group, if the scope and the group are in different stacks, return + * a fake "imported" security group instead. This will behave as the original security group, + * but new Ingress and Egress rule resources will be added in the current stack instead of the + * other one. + */ +function securityGroupsInThisStack(scope: Construct, groups: ec2.ISecurityGroup[]): ec2.ISecurityGroup[] { + const thisStack = Stack.of(scope); + + let i = 1; + return groups.map(group => { + if (thisStack === Stack.of(group)) { return group; } // Simple case, just return the original one + + return ec2.SecurityGroup.fromSecurityGroupId(scope, `SecurityGroup${i++}`, group.securityGroupId, { + allowAllOutbound: group.allowAllOutbound, + mutable: true, + }); + }); +} + /** * The built-in container instance attributes */ diff --git a/packages/@aws-cdk/aws-ecs/package.json b/packages/@aws-cdk/aws-ecs/package.json index 571021085887c..08160d1cfb256 100644 --- a/packages/@aws-cdk/aws-ecs/package.json +++ b/packages/@aws-cdk/aws-ecs/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ecs", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ECS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,66 +62,66 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", "@types/proxyquire": "^1.3.28", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0", + "pkglint": "1.21.0", "proxyquire": "^2.1.3" }, "dependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling-hooktargets": "1.19.0", - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling-hooktargets": "1.21.0", + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling-hooktargets": "1.19.0", - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling-hooktargets": "1.21.0", + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -254,4 +254,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/test.cross-stack.ts b/packages/@aws-cdk/aws-ecs/test/ec2/test.cross-stack.ts new file mode 100644 index 0000000000000..fee694d75cd0f --- /dev/null +++ b/packages/@aws-cdk/aws-ecs/test/ec2/test.cross-stack.ts @@ -0,0 +1,100 @@ +import { expect, haveResource } from '@aws-cdk/assert'; +import * as ec2 from '@aws-cdk/aws-ec2'; +import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; +import { App, Stack } from '@aws-cdk/core'; +import { Test } from 'nodeunit'; +import * as ecs from '../../lib'; + +// Test various cross-stack Cluster/Service/ALB scenario's + +let app: App; +let stack1: Stack; +let stack2: Stack; +let cluster: ecs.Cluster; +let service: ecs.Ec2Service; + +export = { + "setUp"(cb: () => void) { + app = new App(); + + stack1 = new Stack(app, 'Stack1'); + const vpc = new ec2.Vpc(stack1, 'Vpc'); + cluster = new ecs.Cluster(stack1, 'Cluster', { + vpc, + capacity: { instanceType: new ec2.InstanceType('t2.micro'), } + }); + + stack2 = new Stack(app, 'Stack2'); + const taskDefinition = new ecs.Ec2TaskDefinition(stack2, 'TD'); + const container = taskDefinition.addContainer('Main', { + image: ecs.ContainerImage.fromRegistry('asdf'), + memoryLimitMiB: 512 + }); + container.addPortMappings({ containerPort: 8000 }); + + service = new ecs.Ec2Service(stack2, 'Service', { + cluster, + taskDefinition, + }); + + cb(); + }, + + "ALB next to Service"(test: Test) { + // WHEN + const lb = new elbv2.ApplicationLoadBalancer(stack2, "ALB", { vpc: cluster.vpc }); + const listener = lb.addListener("listener", { port: 80 }); + listener.addTargets("target", { + port: 80, + targets: [service] + }); + + // THEN: it shouldn't throw due to cyclic dependencies + expect(stack2).to(haveResource('AWS::ECS::Service')); + + expectIngress(stack2); + + test.done(); + }, + + "ALB next to Cluster"(test: Test) { + // WHEN + const lb = new elbv2.ApplicationLoadBalancer(stack1, "ALB", { vpc: cluster.vpc }); + const listener = lb.addListener("listener", { port: 80 }); + listener.addTargets("target", { + port: 80, + targets: [service] + }); + + // THEN: it shouldn't throw due to cyclic dependencies + expect(stack2).to(haveResource('AWS::ECS::Service')); + expectIngress(stack2); + + test.done(); + }, + + "ALB in its own stack"(test: Test) { + // WHEN + const stack3 = new Stack(app, 'Stack3'); + const lb = new elbv2.ApplicationLoadBalancer(stack3, "ALB", { vpc: cluster.vpc }); + const listener = lb.addListener("listener", { port: 80 }); + listener.addTargets("target", { + port: 80, + targets: [service] + }); + + // THEN: it shouldn't throw due to cyclic dependencies + expect(stack2).to(haveResource('AWS::ECS::Service')); + expectIngress(stack2); + + test.done(); + }, +}; + +function expectIngress(stack: Stack) { + expect(stack).to(haveResource('AWS::EC2::SecurityGroupIngress', { + FromPort: 32768, + ToPort: 65535, + GroupId: { "Fn::ImportValue": "Stack1:ExportsOutputFnGetAttClusterDefaultAutoScalingGroupInstanceSecurityGroup1D15236AGroupIdEAB9C5E1" }, + })); +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts index a7328ef2a3545..95399d83229b7 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts +++ b/packages/@aws-cdk/aws-ecs/test/ec2/test.ec2-task-definition.ts @@ -542,34 +542,7 @@ export = { { Ref: "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - Ref: "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - Ref: "AssetParameters1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439cImageName1ADCADB3" - } - ] - } - ] - } + "/aws-cdk/assets:baa2d6eb2a17c75424df631c8c70ff39f2d5f3bee8b9e1a109ee24ca17300540" ] ] }, diff --git a/packages/@aws-cdk/aws-efs/package.json b/packages/@aws-cdk/aws-efs/package.json index ab39ea9469292..9f902a00d9741 100644 --- a/packages/@aws-cdk/aws-efs/package.json +++ b/packages/@aws-cdk/aws-efs/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-efs", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::EFS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks-legacy/package.json b/packages/@aws-cdk/aws-eks-legacy/package.json index fa2694dae1197..723f7ab7b929c 100644 --- a/packages/@aws-cdk/aws-eks-legacy/package.json +++ b/packages/@aws-cdk/aws-eks-legacy/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-eks-legacy", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::EKS (Legacy)", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,32 +62,32 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -115,4 +115,4 @@ ] }, "stability": "deprecated" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eks/package.json b/packages/@aws-cdk/aws-eks/package.json index aaa7b46439d51..f53ba79b70010 100644 --- a/packages/@aws-cdk/aws-eks/package.json +++ b/packages/@aws-cdk/aws-eks/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-eks", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::EKS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,35 +62,35 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/custom-resources": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/custom-resources": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/custom-resources": "1.19.0" + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/custom-resources": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -108,4 +108,4 @@ ] }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticache/package.json b/packages/@aws-cdk/aws-elasticache/package.json index 01560727b09cc..93eb2b0694f14 100644 --- a/packages/@aws-cdk/aws-elasticache/package.json +++ b/packages/@aws-cdk/aws-elasticache/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-elasticache", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ElastiCache", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticbeanstalk/package.json b/packages/@aws-cdk/aws-elasticbeanstalk/package.json index e430db3a8d3d8..57abc201cec70 100644 --- a/packages/@aws-cdk/aws-elasticbeanstalk/package.json +++ b/packages/@aws-cdk/aws-elasticbeanstalk/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-elasticbeanstalk", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ElasticBeanstalk", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancing/package.json b/packages/@aws-cdk/aws-elasticloadbalancing/package.json index 8383e5e045b19..0791d0b10045d 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancing/package.json +++ b/packages/@aws-cdk/aws-elasticloadbalancing/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-elasticloadbalancing", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS ElasticLoadBalancing", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,22 +62,22 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -108,4 +108,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/package.json b/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/package.json index bdda11641af17..7076e5607e9df 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/package.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2-targets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-elasticloadbalancingv2-targets", - "version": "1.19.0", + "version": "1.21.0", "description": "Integration targets for AWS ElasticLoadBalancingV2", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -77,29 +77,28 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -111,4 +110,4 @@ "docs-public-apis:@aws-cdk/aws-elasticloadbalancingv2-targets.LambdaTarget" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts index aaad5fc6bc43b..64f8782ee8d98 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts @@ -227,11 +227,7 @@ export class NetworkLoadBalancer extends BaseLoadBalancer implements INetworkLoa /** * A network load balancer */ -export interface INetworkLoadBalancer extends ILoadBalancerV2 { - /** - * The ARN of this load balancer - */ - readonly loadBalancerArn: string; +export interface INetworkLoadBalancer extends ILoadBalancerV2, ec2.IVpcEndpointServiceLoadBalancer { /** * The VPC this load balancer has been created in (if available) 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 d05a44bfb7f94..0a4cb0ac3eaeb 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 @@ -29,7 +29,9 @@ export interface BaseLoadBalancerProps { /** * Where in the VPC to place the load balancer * - * @default - Public subnets if internetFacing, otherwise private subnets. + * @default - Public subnets if internetFacing, Private subnets if internal and + * there are Private subnets, Isolated subnets if internal and there are no + * Private subnets. */ readonly vpcSubnets?: ec2.SubnetSelection; @@ -128,8 +130,7 @@ export abstract class BaseLoadBalancer extends Resource { const internetFacing = ifUndefined(baseProps.internetFacing, false); const vpcSubnets = ifUndefined(baseProps.vpcSubnets, - { subnetType: internetFacing ? ec2.SubnetType.PUBLIC : ec2.SubnetType.PRIVATE }); - + (internetFacing ? {subnetType: ec2.SubnetType.PUBLIC} : {}) ); const { subnetIds, internetConnectivityEstablished } = baseProps.vpc.selectSubnets(vpcSubnets); this.vpc = baseProps.vpc; diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json b/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json index 3e8abaafe285d..2656015c43eaf 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-elasticloadbalancingv2", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ElasticLoadBalancingV2", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,32 +62,32 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -124,4 +124,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/test.load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/test.load-balancer.ts index 1977dd8425ce5..5c0046e186013 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/test.load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/test.load-balancer.ts @@ -90,6 +90,174 @@ export = { Name: 'myLoadBalancer' })); test.done(); - } + }, + + 'Trivial construction: internal with Isolated subnets only'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC', { + subnetConfiguration: [{ + cidrMask: 20, + name: 'Isolated', + subnetType: ec2.SubnetType.ISOLATED, + }] + }); + + // WHEN + new elbv2.NetworkLoadBalancer(stack, 'LB', { + vpc, + internetFacing: false, + }); + + // THEN + expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', { + Scheme: "internal", + Subnets: [ + { Ref: "VPCIsolatedSubnet1SubnetEBD00FC6" }, + { Ref: "VPCIsolatedSubnet2Subnet4B1C8CAA" }, + ], + Type: "network" + })); + + test.done(); + }, + 'Internal with Public, Private, and Isolated subnets'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC', { + subnetConfiguration: [{ + cidrMask: 24, + name: 'Public', + subnetType: ec2.SubnetType.PUBLIC, + }, { + cidrMask: 24, + name: 'Private', + subnetType: ec2.SubnetType.PRIVATE, + }, { + cidrMask: 28, + name: 'Isolated', + subnetType: ec2.SubnetType.ISOLATED, + } + ] + }); + // WHEN + new elbv2.NetworkLoadBalancer(stack, 'LB', { + vpc, + internetFacing: false, + }); + + // THEN + expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', { + Scheme: "internal", + Subnets: [ + { Ref: "VPCPrivateSubnet1Subnet8BCA10E0" }, + { Ref: "VPCPrivateSubnet2SubnetCFCDAA7A" }, + ], + Type: "network" + })); + + test.done(); + }, + 'Internet-facing with Public, Private, and Isolated subnets'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC', { + subnetConfiguration: [{ + cidrMask: 24, + name: 'Public', + subnetType: ec2.SubnetType.PUBLIC, + }, { + cidrMask: 24, + name: 'Private', + subnetType: ec2.SubnetType.PRIVATE, + }, { + cidrMask: 28, + name: 'Isolated', + subnetType: ec2.SubnetType.ISOLATED, + } + ] + }); + + // WHEN + new elbv2.NetworkLoadBalancer(stack, 'LB', { + vpc, + internetFacing: true, + }); + + // THEN + expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', { + Scheme: "internet-facing", + Subnets: [ + { Ref: "VPCPublicSubnet1SubnetB4246D30" }, + { Ref: "VPCPublicSubnet2Subnet74179F39" }, + ], + Type: "network" + })); + + test.done(); + }, + 'Internal load balancer supplying public subnets'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + + // WHEN + new elbv2.NetworkLoadBalancer(stack, 'LB', { + vpc, + internetFacing: false, + vpcSubnets: {subnetType: ec2.SubnetType.PUBLIC} + }); + + // THEN + expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', { + Scheme: "internal", + Subnets: [ + { Ref: "VPCPublicSubnet1SubnetB4246D30" }, + { Ref: "VPCPublicSubnet2Subnet74179F39" }, + ], + Type: "network" + })); + + test.done(); + }, + 'Internal load balancer supplying isolated subnets'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC', { + subnetConfiguration: [{ + cidrMask: 24, + name: 'Public', + subnetType: ec2.SubnetType.PUBLIC, + }, { + cidrMask: 24, + name: 'Private', + subnetType: ec2.SubnetType.PRIVATE, + }, { + cidrMask: 28, + name: 'Isolated', + subnetType: ec2.SubnetType.ISOLATED, + } + ] + }); + + // WHEN + new elbv2.NetworkLoadBalancer(stack, 'LB', { + vpc, + internetFacing: false, + vpcSubnets: {subnetType: ec2.SubnetType.ISOLATED} + }); + + // THEN + expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::LoadBalancer', { + Scheme: "internal", + Subnets: [ + { Ref: "VPCIsolatedSubnet1SubnetEBD00FC6" }, + { Ref: "VPCIsolatedSubnet2Subnet4B1C8CAA" }, + ], + Type: "network" + })); + + test.done(); + } }; diff --git a/packages/@aws-cdk/aws-elasticsearch/package.json b/packages/@aws-cdk/aws-elasticsearch/package.json index a373c5679480c..67a7f8a5a3606 100644 --- a/packages/@aws-cdk/aws-elasticsearch/package.json +++ b/packages/@aws-cdk/aws-elasticsearch/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-elasticsearch", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Elasticsearch", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-emr/package.json b/packages/@aws-cdk/aws-emr/package.json index c275448a18915..86864e79fea83 100644 --- a/packages/@aws-cdk/aws-emr/package.json +++ b/packages/@aws-cdk/aws-emr/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-emr", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::EMR", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events-targets/package.json b/packages/@aws-cdk/aws-events-targets/package.json index 7ecc8e45506de..2fc2f9718cd1e 100644 --- a/packages/@aws-cdk/aws-events-targets/package.json +++ b/packages/@aws-cdk/aws-events-targets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-events-targets", - "version": "1.19.0", + "version": "1.21.0", "description": "Event targets for AWS CloudWatch Events", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -48,7 +48,7 @@ }, "cdk-build": { "pre": [ - "cp -f $(node -p 'require.resolve(\"aws-sdk/apis/metadata.json\")') lib/sdk-api-metadata.json" + "cp -f $(node -p 'require.resolve(\"aws-sdk/apis/metadata.json\")') lib/sdk-api-metadata.json && rm -f lib/sdk-api-metadata.d.ts" ] }, "jest": { @@ -84,45 +84,45 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-codecommit": "1.19.0", - "aws-sdk": "^2.597.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-codecommit": "1.21.0", + "aws-sdk": "^2.601.0", "aws-sdk-mock": "^5.0.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -139,4 +139,4 @@ "props-default-doc:@aws-cdk/aws-events-targets.EcsTaskProps.containerOverrides" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json b/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json index 88cdef93cf952..00d6fb582078a 100644 --- a/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json +++ b/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-ec2-task.lit.expected.json @@ -678,34 +678,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } + "/aws-cdk/assets:1f37178655533422f6654c973b99eadec99a723c7181c912e4fb0976187c687c" ] ] }, @@ -744,36 +717,6 @@ } } }, - "TaskDefTheContainerAssetImageAdoptRepository997406C3": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "TaskDefTheContainerLogGroupD94C8EF5": { "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", @@ -824,13 +767,7 @@ { "Ref": "AWS::AccountId" }, - ":repository/", - { - "Fn::GetAtt": [ - "TaskDefTheContainerAssetImageAdoptRepository997406C3", - "RepositoryName" - ] - } + ":repository/aws-cdk/assets" ] ] } @@ -924,152 +861,6 @@ ] } }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - }, "Rule4C995B7F": { "Type": "AWS::Events::Rule", "Properties": { @@ -1106,22 +897,6 @@ "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - }, - "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-fargate-task.expected.json b/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-fargate-task.expected.json index 6cffa13533c6c..4039dbafddaf1 100644 --- a/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-fargate-task.expected.json +++ b/packages/@aws-cdk/aws-events-targets/test/ecs/integ.event-fargate-task.expected.json @@ -237,34 +237,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } + "/aws-cdk/assets:1f37178655533422f6654c973b99eadec99a723c7181c912e4fb0976187c687c" ] ] }, @@ -304,36 +277,6 @@ } } }, - "TaskDefTheContainerAssetImageAdoptRepository997406C3": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "TaskDefTheContainerLogGroupD94C8EF5": { "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", @@ -384,13 +327,7 @@ { "Ref": "AWS::AccountId" }, - ":repository/", - { - "Fn::GetAtt": [ - "TaskDefTheContainerAssetImageAdoptRepository997406C3", - "RepositoryName" - ] - } + ":repository/aws-cdk/assets" ] ] } @@ -510,152 +447,6 @@ ] } }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:", - { - "Ref": "AWS::Region" - }, - ":", - { - "Ref": "AWS::AccountId" - }, - ":repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - }, "Rule4C995B7F": { "Type": "AWS::Events::Rule", "Properties": { @@ -706,23 +497,5 @@ ] } } - }, - "Parameters": { - "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/package.json b/packages/@aws-cdk/aws-events/package.json index 31a4156d38edd..7caa5cc4343c1 100644 --- a/packages/@aws-cdk/aws-events/package.json +++ b/packages/@aws-cdk/aws-events/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-events", - "version": "1.19.0", + "version": "1.21.0", "description": "AWS CloudWatch Events Construct Library", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -63,21 +63,21 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -104,4 +104,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-eventschemas/package.json b/packages/@aws-cdk/aws-eventschemas/package.json index 250689291f93e..b91f7b08ba91e 100644 --- a/packages/@aws-cdk/aws-eventschemas/package.json +++ b/packages/@aws-cdk/aws-eventschemas/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-eventschemas", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::EventSchemas", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-fsx/package.json b/packages/@aws-cdk/aws-fsx/package.json index 6f96289a46ed5..20fde7c08c1cb 100644 --- a/packages/@aws-cdk/aws-fsx/package.json +++ b/packages/@aws-cdk/aws-fsx/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-fsx", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::FSx", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/package.json b/packages/@aws-cdk/aws-gamelift/package.json index ce050ed3d042a..f559b373c491e 100644 --- a/packages/@aws-cdk/aws-gamelift/package.json +++ b/packages/@aws-cdk/aws-gamelift/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-gamelift", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::GameLift", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-glue/lib/table.ts b/packages/@aws-cdk/aws-glue/lib/table.ts index d204cbdafb1b3..92532d22b564e 100644 --- a/packages/@aws-cdk/aws-glue/lib/table.ts +++ b/packages/@aws-cdk/aws-glue/lib/table.ts @@ -236,7 +236,7 @@ export class Table extends Resource implements ITable { this.database = props.database; this.dataFormat = props.dataFormat; - this.s3Prefix = props.s3Prefix || 'data/'; + this.s3Prefix = (props.s3Prefix !== undefined && props.s3Prefix !== null) ? props.s3Prefix : 'data/'; validateSchema(props.columns, props.partitionKeys); this.columns = props.columns; diff --git a/packages/@aws-cdk/aws-glue/package.json b/packages/@aws-cdk/aws-glue/package.json index b610d765bb419..8036380594423 100644 --- a/packages/@aws-cdk/aws-glue/package.json +++ b/packages/@aws-cdk/aws-glue/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-glue", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Glue", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,26 +62,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -121,4 +121,4 @@ "docs-public-apis:@aws-cdk/aws-glue.SerializationLibrary.className" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-glue/test/test.table.ts b/packages/@aws-cdk/aws-glue/test/test.table.ts index 357f27135dc95..69701ea2924be 100644 --- a/packages/@aws-cdk/aws-glue/test/test.table.ts +++ b/packages/@aws-cdk/aws-glue/test/test.table.ts @@ -1079,6 +1079,74 @@ export = { test.done(); }, + 'explicit s3 bucket and with empty prefix'(test: Test) { + const app = new cdk.App(); + const dbStack = new cdk.Stack(app, 'db'); + const stack = new cdk.Stack(app, 'app'); + const bucket = new s3.Bucket(stack, 'ExplicitBucket'); + const database = new glue.Database(dbStack, 'Database', { + databaseName: 'database', + }); + + new glue.Table(stack, 'Table', { + database, + bucket, + s3Prefix: '', + tableName: 'table', + columns: [{ + name: 'col', + type: glue.Schema.STRING + }], + dataFormat: glue.DataFormat.Json, + }); + + expect(stack).to(haveResource('AWS::Glue::Table', { + CatalogId: { + Ref: "AWS::AccountId" + }, + DatabaseName: { + "Fn::ImportValue": "db:ExportsOutputRefDatabaseB269D8BB88F4B1C4" + }, + TableInput: { + Description: "table generated by CDK", + Name: "table", + Parameters: { + has_encrypted_data: false + }, + StorageDescriptor: { + Columns: [ + { + Name: "col", + Type: "string" + } + ], + Compressed: false, + InputFormat: "org.apache.hadoop.mapred.TextInputFormat", + Location: { + "Fn::Join": [ + "", + [ + "s3://", + { + Ref: "ExplicitBucket0AA51A3F" + }, + "/" + ] + ] + }, + OutputFormat: "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", + SerdeInfo: { + SerializationLibrary: "org.openx.data.jsonserde.JsonSerDe" + }, + StoredAsSubDirectories: false + }, + TableType: "EXTERNAL_TABLE" + } + })); + + test.done(); + }, + 'grants': { 'read only'(test: Test) { const stack = new cdk.Stack(); diff --git a/packages/@aws-cdk/aws-greengrass/package.json b/packages/@aws-cdk/aws-greengrass/package.json index db4c346afc5df..f316cb0ce8969 100644 --- a/packages/@aws-cdk/aws-greengrass/package.json +++ b/packages/@aws-cdk/aws-greengrass/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-greengrass", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Greengrass", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-guardduty/package.json b/packages/@aws-cdk/aws-guardduty/package.json index a0c570e213d4c..12861a9547654 100644 --- a/packages/@aws-cdk/aws-guardduty/package.json +++ b/packages/@aws-cdk/aws-guardduty/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-guardduty", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::GuardDuty", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/README.md b/packages/@aws-cdk/aws-iam/README.md index aefeaef3c028d..1e783fb628870 100644 --- a/packages/@aws-cdk/aws-iam/README.md +++ b/packages/@aws-cdk/aws-iam/README.md @@ -47,9 +47,78 @@ The `grant*` methods accept an `IGrantable` object. This interface is implemente You can find which `grant*` methods exist for a resource in the [AWS CDK API Reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html). +### Roles + +Many AWS resources require *Roles* to operate. These Roles define the AWS API +calls an instance or other AWS service is allowed to make. + +Creating Roles and populating them with the right permissions *Statements* is +a necessary but tedious part of setting up AWS infrastructure. In order to +help you focus on your business logic, CDK will take care of creating +roles and populating them with least-privilege permissions automatically. + +All constructs that require Roles will create one for you if don't specify +one at construction time. Permissions will be added to that role +automatically if you associate the construct with other constructs from the +AWS Construct Library (for example, if you tell an *AWS CodePipeline* to trigger +an *AWS Lambda Function*, the Pipeline's Role will automatically get +`lambda:InvokeFunction` permissions on that particular Lambda Function), +or if you explicitly grant permissions using `grant` functions (see the +previous section). + +#### Opting out of automatic permissions management + +You may prefer to manage a Role's permissions yourself instead of having the +CDK automatically manage them for you. This may happen in one of the +following cases: + +* You don't like the permissions that CDK automatically generates and + want to substitute your own set. +* The least-permissions policy that the CDK generates is becoming too + big for IAM to store, and you need to add some wildcards to keep the + policy size down. + +To prevent constructs from updating your Role's policy, pass the object +returned by `myRole.withoutPolicyUpdates()` instead of `myRole` itself. + +For example, to have an AWS CodePipeline *not* automatically add the required +permissions to trigger the expected targets, do the following: + +```ts +const role = new iam.Role(this, 'Role', { + assumedBy: new iam.ServicePrincipal('codepipeline.amazonaws.com'), +}); + +new codepipeline.Pipeline(this, 'Pipeline', { + // Give the Pipeline an immutable view of the Role + role: role.withoutPolicyUpdates(), +}); + +// You now have to manage the Role policies yourself +role.addToPolicy(new iam.PolicyStatement({ + action: [/* whatever actions you want */], + resource: [/* whatever resources you intend to touch */], +}); +``` + +#### Using existing roles + +If there are Roles in your account that have already been created which you +would like to use in your CDK application, you can use `Role.fromRoleArn` to +import them, as follows: + +```ts +const role = iam.Role.fromRoleArn(this, 'Role', 'arn:aws:iam::123456789012:role/MyExistingRole', { + // Set 'mutable' to 'false' to use the role as-is and prevent adding new + // policies to it. The default is 'true', which means the role may be + // modified as part of the deployment. + mutable: false, +}); +``` + ### Configuring an ExternalId -If you need to create roles that will be assumed by 3rd parties, it is generally a good idea to [require an `ExternalId` +If you need to create Roles that will be assumed by 4rd parties, it is generally a good idea to [require an `ExternalId` to assume them](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html). Configuring an `ExternalId` works like this: diff --git a/packages/@aws-cdk/aws-iam/lib/private/immutable-role.ts b/packages/@aws-cdk/aws-iam/lib/private/immutable-role.ts new file mode 100644 index 0000000000000..d894cc8dbc722 --- /dev/null +++ b/packages/@aws-cdk/aws-iam/lib/private/immutable-role.ts @@ -0,0 +1,58 @@ +import { DependableTrait } from '@aws-cdk/core'; +import { Grant } from '../grant'; +import { IManagedPolicy } from '../managed-policy'; +import { Policy } from '../policy'; +import { PolicyStatement } from '../policy-statement'; +import { IPrincipal } from '../principals'; +import { IRole } from '../role'; + +/** + * An immutable wrapper around an IRole + * + * This wrapper ignores all mutating operations, like attaching policies or + * adding policy statements. + * + * Useful in cases where you want to turn off CDK's automatic permissions + * management, and instead have full control over all permissions. + * + * Note: if you want to ignore all mutations for an externally defined role + * which was imported into the CDK with {@link Role.fromRoleArn}, you don't have to use this class - + * simply pass the property mutable = false when calling {@link Role.fromRoleArn}. + */ +export class ImmutableRole implements IRole { + public readonly assumeRoleAction = this.role.assumeRoleAction; + public readonly policyFragment = this.role.policyFragment; + public readonly grantPrincipal = this.role.grantPrincipal; + public readonly roleArn = this.role.roleArn; + public readonly roleName = this.role.roleName; + public readonly node = this.role.node; + public readonly stack = this.role.stack; + + constructor(private readonly role: IRole) { + // implement IDependable privately + DependableTrait.implement(this, { + dependencyRoots: [ role ] + }); + } + + public attachInlinePolicy(_policy: Policy): void { + // do nothing + } + + public addManagedPolicy(_policy: IManagedPolicy): void { + // do nothing + } + + public addToPolicy(_statement: PolicyStatement): boolean { + // Not really added, but for the purposes of consumer code pretend that it was. + return true; + } + + public grant(grantee: IPrincipal, ...actions: string[]): Grant { + return this.role.grant(grantee, ...actions); + } + + public grantPassRole(grantee: IPrincipal): Grant { + return this.role.grantPassRole(grantee); + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/lib/role.ts b/packages/@aws-cdk/aws-iam/lib/role.ts index 88ee7151c1f6e..7d3398da3a197 100644 --- a/packages/@aws-cdk/aws-iam/lib/role.ts +++ b/packages/@aws-cdk/aws-iam/lib/role.ts @@ -7,6 +7,7 @@ import { Policy } from './policy'; import { PolicyDocument } from './policy-document'; import { PolicyStatement } from './policy-statement'; import { ArnPrincipal, IPrincipal, PrincipalPolicyFragment } from './principals'; +import { ImmutableRole } from './private/immutable-role'; import { AttachedPolicies } from './util'; export interface RoleProps { @@ -155,18 +156,39 @@ export class Role extends Resource implements IRole { public static fromRoleArn(scope: Construct, id: string, roleArn: string, options: FromRoleArnOptions = {}): IRole { const scopeStack = Stack.of(scope); const parsedArn = scopeStack.parseArn(roleArn); - const roleName = parsedArn.resourceName!; - - abstract class Import extends Resource implements IRole { + const resourceName = parsedArn.resourceName!; + // service roles have an ARN like 'arn:aws:iam:::role/service-role/' + // we want to support these as well, so strip out the 'service-role/' prefix if we see it + const roleName = resourceName.startsWith('service-role/') + ? resourceName.slice('service-role/'.length) + : resourceName; + + class Import extends Resource implements IRole { public readonly grantPrincipal: IPrincipal = this; public readonly assumeRoleAction: string = 'sts:AssumeRole'; public readonly policyFragment = new ArnPrincipal(roleArn).policyFragment; public readonly roleArn = roleArn; public readonly roleName = roleName; + private readonly attachedPolicies = new AttachedPolicies(); + private defaultPolicy?: Policy; - public abstract addToPolicy(statement: PolicyStatement): boolean; + public addToPolicy(statement: PolicyStatement): boolean { + if (!this.defaultPolicy) { + this.defaultPolicy = new Policy(this, 'Policy'); + this.attachInlinePolicy(this.defaultPolicy); + } + this.defaultPolicy.addStatements(statement); + return true; + } - public abstract attachInlinePolicy(policy: Policy): void; + public attachInlinePolicy(policy: Policy): void { + const policyAccount = Stack.of(policy).account; + + if (accountsAreEqualOrOneIsUnresolved(policyAccount, roleAccount)) { + this.attachedPolicies.attach(policy); + policy.attachToRole(this); + } + } public addManagedPolicy(_policy: IManagedPolicy): void { // FIXME: Add warning that we're ignoring this @@ -194,44 +216,11 @@ export class Role extends Resource implements IRole { const roleAccount = parsedArn.account; - class MutableImport extends Import { - private readonly attachedPolicies = new AttachedPolicies(); - private defaultPolicy?: Policy; - - public addToPolicy(statement: PolicyStatement): boolean { - if (!this.defaultPolicy) { - this.defaultPolicy = new Policy(this, 'Policy'); - this.attachInlinePolicy(this.defaultPolicy); - } - this.defaultPolicy.addStatements(statement); - return true; - } - - public attachInlinePolicy(policy: Policy): void { - const policyAccount = Stack.of(policy).account; - - if (accountsAreEqualOrOneIsUnresolved(policyAccount, roleAccount)) { - this.attachedPolicies.attach(policy); - policy.attachToRole(this); - } - } - } - - class ImmutableImport extends Import { - public addToPolicy(_statement: PolicyStatement): boolean { - return true; - } - - public attachInlinePolicy(_policy: Policy): void { - // do nothing - } - } - const scopeAccount = scopeStack.account; return options.mutable !== false && accountsAreEqualOrOneIsUnresolved(scopeAccount, roleAccount) - ? new MutableImport(scope, id) - : new ImmutableImport(scope, id); + ? new Import(scope, id) + : new ImmutableRole(new Import(scope, id)); function accountsAreEqualOrOneIsUnresolved(account1: string | undefined, account2: string | undefined): boolean { @@ -380,6 +369,19 @@ export class Role extends Resource implements IRole { public grantPassRole(identity: IPrincipal) { return this.grant(identity, 'iam:PassRole'); } + + /** + * Return a copy of this Role object whose Policies will not be updated + * + * Use the object returned by this method if you want this Role to be used by + * a construct without it automatically updating the Role's Policies. + * + * If you do, you are responsible for adding the correct statements to the + * Role's policies yourself. + */ + public withoutPolicyUpdates(): IRole { + return new ImmutableRole(this); + } } /** @@ -412,7 +414,7 @@ export interface IRole extends IIdentity { } function createAssumeRolePolicy(principal: IPrincipal, externalIds: string[]) { - const statement = new PolicyStatement(); + const statement = new AwsStarStatement(); statement.addPrincipals(principal); statement.addActions(principal.assumeRoleAction); @@ -434,3 +436,21 @@ function validateMaxSessionDuration(duration?: number) { throw new Error(`maxSessionDuration is set to ${duration}, but must be >= 3600sec (1hr) and <= 43200sec (12hrs)`); } } + +/** + * A PolicyStatement that normalizes its Principal field differently + * + * Normally, "anyone" is normalized to "Principal: *", but this statement + * normalizes to "Principal: { AWS: * }". + */ +class AwsStarStatement extends PolicyStatement { + public toStatementJson(): any { + const stat = super.toStatementJson(); + + if (stat.Principal === '*') { + stat.Principal = { AWS: '*' }; + } + + return stat; + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/package.json b/packages/@aws-cdk/aws-iam/package.json index 54050ed1808ef..e4a13fe4567c7 100644 --- a/packages/@aws-cdk/aws-iam/package.json +++ b/packages/@aws-cdk/aws-iam/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-iam", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK routines for easily assigning correct and minimal IAM permissions", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -64,20 +64,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0", - "@aws-cdk/region-info": "1.19.0" + "@aws-cdk/core": "1.21.0", + "@aws-cdk/region-info": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0", - "@aws-cdk/region-info": "1.19.0" + "@aws-cdk/core": "1.21.0", + "@aws-cdk/region-info": "1.21.0" }, "jest": { "moduleFileExtensions": [ @@ -157,4 +157,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/test/immutable-role.test.ts b/packages/@aws-cdk/aws-iam/test/immutable-role.test.ts new file mode 100644 index 0000000000000..7a39b761bbb7f --- /dev/null +++ b/packages/@aws-cdk/aws-iam/test/immutable-role.test.ts @@ -0,0 +1,87 @@ +import '@aws-cdk/assert/jest'; +import { Stack } from '@aws-cdk/core'; +import * as iam from '../lib'; + +// tslint:disable:object-literal-key-quotes + +describe('ImmutableRole', () => { + let stack: Stack; + let mutableRole: iam.Role; + let immutableRole: iam.IRole; + + beforeEach(() => { + stack = new Stack(); + mutableRole = new iam.Role(stack, 'MutableRole', { + assumedBy: new iam.AnyPrincipal(), + }); + immutableRole = mutableRole.withoutPolicyUpdates(); + }); + + test('ignores calls to attachInlinePolicy', () => { + const user = new iam.User(stack, 'User'); + const policy = new iam.Policy(stack, 'Policy', { + statements: [new iam.PolicyStatement({ + resources: ['*'], + actions: ['s3:*'], + })], + users: [user], + }); + + immutableRole.attachInlinePolicy(policy); + + expect(stack).toHaveResource('AWS::IAM::Policy', { + "PolicyDocument": { + "Statement": [ + { + "Action": "s3:*", + "Resource": "*", + "Effect": "Allow", + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "Policy23B91518", + "Users": [ + { + "Ref": "User00B015A1", + }, + ], + }); + }); + + test('ignores calls to addManagedPolicy', () => { + mutableRole.addManagedPolicy({ managedPolicyArn: 'Arn1' }); + + immutableRole.addManagedPolicy({ managedPolicyArn: 'Arn2' }); + + expect(stack).toHaveResourceLike('AWS::IAM::Role', { + "ManagedPolicyArns": [ + 'Arn1', + ], + }); + }); + + test('ignores calls to addToPolicy', () => { + mutableRole.addToPolicy(new iam.PolicyStatement({ + resources: ['*'], + actions: ['s3:*'], + })); + + immutableRole.addToPolicy(new iam.PolicyStatement({ + resources: ['*'], + actions: ['iam:*'], + })); + + expect(stack).toHaveResourceLike('AWS::IAM::Policy', { + "PolicyDocument": { + "Statement": [ + { + "Resource": "*", + "Action": "s3:*", + "Effect": "Allow", + }, + ], + }, + }); + }); +}); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/test/integ.role.expected.json b/packages/@aws-cdk/aws-iam/test/integ.role.expected.json index 21aa4898932ab..0e2dbd39d9e93 100644 --- a/packages/@aws-cdk/aws-iam/test/integ.role.expected.json +++ b/packages/@aws-cdk/aws-iam/test/integ.role.expected.json @@ -95,6 +95,28 @@ "Version": "2012-10-17" } } + }, + "TestRole3C1F30727": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Condition": { + "StringEquals": { + "aws:PrincipalOrgID": "o-1234" + } + }, + "Effect": "Allow", + "Principal": { + "AWS": "*" + } + } + ], + "Version": "2012-10-17" + } + } } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iam/test/integ.role.ts b/packages/@aws-cdk/aws-iam/test/integ.role.ts index e5708b9823b49..91d7e30fb9bba 100644 --- a/packages/@aws-cdk/aws-iam/test/integ.role.ts +++ b/packages/@aws-cdk/aws-iam/test/integ.role.ts @@ -1,5 +1,5 @@ import { App, Stack } from "@aws-cdk/core"; -import { AccountRootPrincipal, Policy, PolicyStatement, Role, ServicePrincipal } from "../lib"; +import { AccountRootPrincipal, OrganizationPrincipal, Policy, PolicyStatement, Role, ServicePrincipal } from "../lib"; const app = new App(); @@ -21,4 +21,9 @@ new Role(stack, 'TestRole2', { externalIds: ['supply-me'], }); +// Role with an org +new Role(stack, 'TestRole3', { + assumedBy: new OrganizationPrincipal('o-1234'), +}); + app.synth(); diff --git a/packages/@aws-cdk/aws-iam/test/role.from-role-arn.test.ts b/packages/@aws-cdk/aws-iam/test/role.from-role-arn.test.ts index 759d6bd98fe4a..ffd29715c14f6 100644 --- a/packages/@aws-cdk/aws-iam/test/role.from-role-arn.test.ts +++ b/packages/@aws-cdk/aws-iam/test/role.from-role-arn.test.ts @@ -476,6 +476,27 @@ describe('IAM Role.fromRoleArn', () => { }); }); }); + + describe('imported with the ARN of a service role', () => { + beforeEach(() => { + roleStack = new Stack(); + importedRole = Role.fromRoleArn(roleStack, 'Role', + `arn:aws:iam::${roleAccount}:role/service-role/codebuild-role`); + }); + + it("correctly strips the 'service-role' prefix from the role name", () => { + new Policy(roleStack, 'Policy', { + statements: [somePolicyStatement()], + roles: [importedRole], + }); + + expect(roleStack).toHaveResourceLike('AWS::IAM::Policy', { + "Roles": [ + "codebuild-role", + ], + }); + }); + }); }); function somePolicyStatement() { diff --git a/packages/@aws-cdk/aws-iam/test/role.test.ts b/packages/@aws-cdk/aws-iam/test/role.test.ts index 1aafc2e7e5f21..80d5e70dc860d 100644 --- a/packages/@aws-cdk/aws-iam/test/role.test.ts +++ b/packages/@aws-cdk/aws-iam/test/role.test.ts @@ -1,6 +1,6 @@ import '@aws-cdk/assert/jest'; import { Duration, Stack } from '@aws-cdk/core'; -import { ArnPrincipal, CompositePrincipal, FederatedPrincipal, ManagedPolicy, PolicyStatement, Role, ServicePrincipal, User } from '../lib'; +import { AnyPrincipal, ArnPrincipal, CompositePrincipal, FederatedPrincipal, ManagedPolicy, PolicyStatement, Role, ServicePrincipal, User } from '../lib'; describe('IAM role', () => { test('default role', () => { @@ -319,4 +319,30 @@ describe('IAM role', () => { } }); }); + + test('Principal-* in an AssumeRolePolicyDocument gets translated to { "AWS": "*" }', () => { + // The docs say that "Principal: *" and "Principal: { AWS: * }" are equivalent + // (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html) + // but in practice CreateRole errors out if you use "Principal: *" in an AssumeRolePolicyDocument: + // An error occurred (MalformedPolicyDocument) when calling the CreateRole operation: AssumeRolepolicy contained an invalid principal: "STAR":"*". + + // Make sure that we handle this case specially. + const stack = new Stack(); + new Role(stack, 'Role', { + assumedBy: new AnyPrincipal(), + }); + + expect(stack).toHaveResource('AWS::IAM::Role', { + AssumeRolePolicyDocument: { + Statement: [ + { + Action: "sts:AssumeRole", + Effect: "Allow", + Principal: { AWS: "*" }, + } + ], + Version: "2012-10-17" + } + }); + }); }); diff --git a/packages/@aws-cdk/aws-inspector/package.json b/packages/@aws-cdk/aws-inspector/package.json index 308c61723bdc3..9fc5fc538e652 100644 --- a/packages/@aws-cdk/aws-inspector/package.json +++ b/packages/@aws-cdk/aws-inspector/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-inspector", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Inspector", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iot/package.json b/packages/@aws-cdk/aws-iot/package.json index 0280504332ab4..6bbbae4bc5862 100644 --- a/packages/@aws-cdk/aws-iot/package.json +++ b/packages/@aws-cdk/aws-iot/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-iot", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::IoT", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iot1click/package.json b/packages/@aws-cdk/aws-iot1click/package.json index 6693a61129cad..6d50e69f0b41a 100644 --- a/packages/@aws-cdk/aws-iot1click/package.json +++ b/packages/@aws-cdk/aws-iot1click/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-iot1click", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::IoT1Click", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iotanalytics/package.json b/packages/@aws-cdk/aws-iotanalytics/package.json index 5902d2b56c8c3..50b15a936d259 100644 --- a/packages/@aws-cdk/aws-iotanalytics/package.json +++ b/packages/@aws-cdk/aws-iotanalytics/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-iotanalytics", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::IoTAnalytics", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iotevents/package.json b/packages/@aws-cdk/aws-iotevents/package.json index e5cd450b1bda5..2bb91a75ad669 100644 --- a/packages/@aws-cdk/aws-iotevents/package.json +++ b/packages/@aws-cdk/aws-iotevents/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-iotevents", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::IoTEvents", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-iotthingsgraph/package.json b/packages/@aws-cdk/aws-iotthingsgraph/package.json index d95a2af201d0c..1538b0ac08b17 100644 --- a/packages/@aws-cdk/aws-iotthingsgraph/package.json +++ b/packages/@aws-cdk/aws-iotthingsgraph/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-iotthingsgraph", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::IoTThingsGraph", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesis/package.json b/packages/@aws-cdk/aws-kinesis/package.json index ddcf2898141d8..6123976c37b4a 100644 --- a/packages/@aws-cdk/aws-kinesis/package.json +++ b/packages/@aws-cdk/aws-kinesis/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-kinesis", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS Kinesis", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -61,25 +61,25 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -93,4 +93,4 @@ "docs-public-apis:@aws-cdk/aws-kinesis.StreamProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesisanalytics/package.json b/packages/@aws-cdk/aws-kinesisanalytics/package.json index 2555d0d3276ae..feb3b663d52c6 100644 --- a/packages/@aws-cdk/aws-kinesisanalytics/package.json +++ b/packages/@aws-cdk/aws-kinesisanalytics/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-kinesisanalytics", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::KinesisAnalytics", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -82,20 +82,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kinesisfirehose/package.json b/packages/@aws-cdk/aws-kinesisfirehose/package.json index 51b73a7a0b546..3e2020cbbdad8 100644 --- a/packages/@aws-cdk/aws-kinesisfirehose/package.json +++ b/packages/@aws-cdk/aws-kinesisfirehose/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-kinesisfirehose", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::KinesisFirehose", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-kms/package.json b/packages/@aws-cdk/aws-kms/package.json index 592e5151d1d83..fc51f0d43d211 100644 --- a/packages/@aws-cdk/aws-kms/package.json +++ b/packages/@aws-cdk/aws-kms/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-kms", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS KMS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,22 +62,22 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -92,4 +92,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lakeformation/package.json b/packages/@aws-cdk/aws-lakeformation/package.json index 73f076f32e047..090a04c6653ac 100644 --- a/packages/@aws-cdk/aws-lakeformation/package.json +++ b/packages/@aws-cdk/aws-lakeformation/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-lakeformation", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::LakeFormation", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-destinations/package.json b/packages/@aws-cdk/aws-lambda-destinations/package.json index 835925fa6534e..966daa59141b0 100644 --- a/packages/@aws-cdk/aws-lambda-destinations/package.json +++ b/packages/@aws-cdk/aws-lambda-destinations/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-lambda-destinations", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Destinations Constructs for AWS Lambda", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,27 +76,27 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -105,4 +105,4 @@ "awslint": { "exclude": [] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda-event-sources/package.json b/packages/@aws-cdk/aws-lambda-event-sources/package.json index 6fc63e8fde910..636c35306f1cc 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/package.json +++ b/packages/@aws-cdk/aws-lambda-event-sources/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-lambda-event-sources", - "version": "1.19.0", + "version": "1.21.0", "description": "Event sources for AWS Lambda", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -58,41 +58,41 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-apigateway": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kinesis": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-notifications": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-apigateway": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kinesis": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-notifications": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-apigateway": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kinesis": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-notifications": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-apigateway": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kinesis": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-notifications": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -112,4 +112,4 @@ "docs-public-apis:@aws-cdk/aws-lambda-event-sources.SqsEventSourceProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/README.md b/packages/@aws-cdk/aws-lambda/README.md index 8ea9bd8563ea0..9038b5f0d37af 100644 --- a/packages/@aws-cdk/aws-lambda/README.md +++ b/packages/@aws-cdk/aws-lambda/README.md @@ -107,7 +107,7 @@ setting the `deadLetterQueueEnabled: true` configuration. import lambda = require('@aws-cdk/aws-lambda'); const fn = new lambda.Function(this, 'MyFunction', { - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'), deadLetterQueueEnabled: true @@ -122,7 +122,7 @@ import sqs = require('@aws-cdk/aws-sqs'); const dlq = new sqs.Queue(this, 'DLQ'); const fn = new lambda.Function(this, 'MyFunction', { - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'), deadLetterQueue: dlq @@ -138,7 +138,7 @@ to learn more about AWS Lambdas and DLQs. import lambda = require('@aws-cdk/aws-lambda'); const fn = new lambda.Function(this, 'MyFunction', { - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'), tracing: lambda.Tracing.ACTIVE @@ -153,7 +153,7 @@ to learn more about AWS Lambda's X-Ray support. import lambda = require('@aws-cdk/aws-lambda'); const fn = new lambda.Function(this, 'MyFunction', { - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'), reservedConcurrentExecutions: 100 diff --git a/packages/@aws-cdk/aws-lambda/lib/runtime.ts b/packages/@aws-cdk/aws-lambda/lib/runtime.ts index 57b6f3d160c85..29f1d0358b977 100644 --- a/packages/@aws-cdk/aws-lambda/lib/runtime.ts +++ b/packages/@aws-cdk/aws-lambda/lib/runtime.ts @@ -35,7 +35,7 @@ export class Runtime { /** @deprecated Use {@link NODEJS_10_X} */ public static readonly NODEJS_8_10 = new Runtime('nodejs8.10', RuntimeFamily.NODEJS, { supportsInlineCode: true }); public static readonly NODEJS_10_X = new Runtime('nodejs10.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }); - public static readonly NODEJS_12_X = new Runtime('nodejs12.x', RuntimeFamily.NODEJS); + public static readonly NODEJS_12_X = new Runtime('nodejs12.x', RuntimeFamily.NODEJS, { supportsInlineCode: true }); public static readonly PYTHON_2_7 = new Runtime('python2.7', RuntimeFamily.PYTHON, { supportsInlineCode: true }); public static readonly PYTHON_3_6 = new Runtime('python3.6', RuntimeFamily.PYTHON, { supportsInlineCode: true }); public static readonly PYTHON_3_7 = new Runtime('python3.7', RuntimeFamily.PYTHON, { supportsInlineCode: true }); diff --git a/packages/@aws-cdk/aws-lambda/package.json b/packages/@aws-cdk/aws-lambda/package.json index 1d77fc7ff21d3..b3d12dcf9c4d2 100644 --- a/packages/@aws-cdk/aws-lambda/package.json +++ b/packages/@aws-cdk/aws-lambda/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-lambda", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS Lambda", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -66,46 +66,46 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/aws-lambda": "^8.10.39", "@types/lodash": "^4.14.149", "@types/nodeunit": "^0.0.30", "@types/sinon": "^7.5.0", - "aws-sdk": "^2.597.0", + "aws-sdk": "^2.601.0", "aws-sdk-mock": "^5.0.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "lodash": "^4.17.15", - "nock": "^11.7.1", + "nock": "^11.7.2", "nodeunit": "^0.11.3", - "pkglint": "1.19.0", - "sinon": "^8.0.2" + "pkglint": "1.21.0", + "sinon": "^8.1.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -186,4 +186,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json new file mode 100644 index 0000000000000..8bbe8cdef572a --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json @@ -0,0 +1,281 @@ +{ + "Resources": { + "NODEJS10XServiceRole2FD24B65": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "NODEJS10XF3831960": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function(event) { return \"success\" }" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "NODEJS10XServiceRole2FD24B65", + "Arn" + ] + }, + "Runtime": "nodejs10.x" + }, + "DependsOn": [ + "NODEJS10XServiceRole2FD24B65" + ] + }, + "NODEJS12XServiceRole59E71436": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "NODEJS12X8B8075A4": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function(event) { return \"success\" }" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "NODEJS12XServiceRole59E71436", + "Arn" + ] + }, + "Runtime": "nodejs12.x" + }, + "DependsOn": [ + "NODEJS12XServiceRole59E71436" + ] + }, + "PYTHON27ServiceRoleF484A17D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "PYTHON27F8E941FA": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "def handler(event, context):\n return \"success\"" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "PYTHON27ServiceRoleF484A17D", + "Arn" + ] + }, + "Runtime": "python2.7" + }, + "DependsOn": [ + "PYTHON27ServiceRoleF484A17D" + ] + }, + "PYTHON36ServiceRole814B3AD9": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "PYTHON364935EF15": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "def handler(event, context):\n return \"success\"" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "PYTHON36ServiceRole814B3AD9", + "Arn" + ] + }, + "Runtime": "python3.6" + }, + "DependsOn": [ + "PYTHON36ServiceRole814B3AD9" + ] + }, + "PYTHON37ServiceRoleDE7E561E": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "PYTHON37D3A10E04": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "def handler(event, context):\n return \"success\"" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "PYTHON37ServiceRoleDE7E561E", + "Arn" + ] + }, + "Runtime": "python3.7" + }, + "DependsOn": [ + "PYTHON37ServiceRoleDE7E561E" + ] + } + }, + "Outputs": { + "NODEJS10XfunctionName": { + "Value": { + "Ref": "NODEJS10XF3831960" + } + }, + "NODEJS12XfunctionName": { + "Value": { + "Ref": "NODEJS12X8B8075A4" + } + }, + "PYTHON27functionName": { + "Value": { + "Ref": "PYTHON27F8E941FA" + } + }, + "PYTHON36functionName": { + "Value": { + "Ref": "PYTHON364935EF15" + } + }, + "PYTHON37functionName": { + "Value": { + "Ref": "PYTHON37D3A10E04" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts new file mode 100644 index 0000000000000..aa4ef06e6a5e1 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts @@ -0,0 +1,53 @@ +import { App, CfnOutput, Stack } from '@aws-cdk/core'; +import { Function, InlineCode, Runtime } from '../lib'; + +// CloudFormation supports InlineCode only for a subset of runtimes. This integration test +// is used to verify that the ones marked in the CDK are in fact supported by CloudFormation. +// Running `cdk deploy` on this stack will confirm if all the runtimes here are supported. +// +// To verify that the lambda function works correctly, use the function names that are part +// of the stack output (printed on the console at the end of 'cdk deploy') and run the command - +// aws lambda invoke --function-name +// +// If successful, the output will contain "success" + +const app = new App(); + +const stack = new Stack(app, 'aws-cdk-lambda-runtime-inlinecode'); + +const node10xfn = new Function(stack, 'NODEJS_10_X', { + code: new InlineCode('exports.handler = async function(event) { return "success" }'), + handler: 'index.handler', + runtime: Runtime.NODEJS_10_X, +}); +new CfnOutput(stack, 'NODEJS_10_X-functionName', { value: node10xfn.functionName }); + +const node12xfn = new Function(stack, 'NODEJS_12_X', { + code: new InlineCode('exports.handler = async function(event) { return "success" }'), + handler: 'index.handler', + runtime: Runtime.NODEJS_12_X, +}); +new CfnOutput(stack, 'NODEJS_12_X-functionName', { value: node12xfn.functionName }); + +const python27 = new Function(stack, 'PYTHON_2_7', { + code: new InlineCode('def handler(event, context):\n return "success"'), + handler: 'index.handler', + runtime: Runtime.PYTHON_2_7, +}); +new CfnOutput(stack, 'PYTHON_2_7-functionName', { value: python27.functionName }); + +const python36 = new Function(stack, 'PYTHON_3_6', { + code: new InlineCode('def handler(event, context):\n return "success"'), + handler: 'index.handler', + runtime: Runtime.PYTHON_3_6, +}); +new CfnOutput(stack, 'PYTHON_3_6-functionName', { value: python36.functionName }); + +const python37 = new Function(stack, 'PYTHON_3_7', { + code: new InlineCode('def handler(event, context):\n return "success"'), + handler: 'index.handler', + runtime: Runtime.PYTHON_3_7, +}); +new CfnOutput(stack, 'PYTHON_3_7-functionName', { value: python37.functionName }); + +app.synth(); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/test.lambda.ts b/packages/@aws-cdk/aws-lambda/test/test.lambda.ts index 89ed61bf93eb6..513203ecee1a3 100644 --- a/packages/@aws-cdk/aws-lambda/test/test.lambda.ts +++ b/packages/@aws-cdk/aws-lambda/test/test.lambda.ts @@ -17,7 +17,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, }); expect(stack).toMatch({ @@ -52,7 +52,7 @@ export = { Code: { ZipFile: 'foo' }, Handler: 'index.handler', Role: { 'Fn::GetAtt': ['MyLambdaServiceRole4539ECB6', 'Arn'] }, - Runtime: 'nodejs8.10' + Runtime: 'nodejs10.x' }, DependsOn: ['MyLambdaServiceRole4539ECB6'] } @@ -66,7 +66,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, initialPolicy: [new iam.PolicyStatement({ actions: ["*"], resources: ["*"] })] }); expect(stack).toMatch({ @@ -121,7 +121,7 @@ export = { Code: { ZipFile: 'foo' }, Handler: 'index.handler', Role: { 'Fn::GetAtt': ['MyLambdaServiceRole4539ECB6', 'Arn'] }, - Runtime: 'nodejs8.10' + Runtime: 'nodejs10.x' }, DependsOn: ['MyLambdaServiceRoleDefaultPolicy5BBC6F68', 'MyLambdaServiceRole4539ECB6'] } @@ -327,7 +327,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, functionName: 'OneFunctionToRuleThemAll', deadLetterQueueEnabled: true }); @@ -411,7 +411,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10", + "Runtime": "nodejs10.x", "DeadLetterConfig": { "TargetArn": { "Fn::GetAtt": [ @@ -439,7 +439,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, deadLetterQueueEnabled: true, }); @@ -522,7 +522,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10", + "Runtime": "nodejs10.x", "DeadLetterConfig": { "TargetArn": { "Fn::GetAtt": [ @@ -549,7 +549,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, deadLetterQueueEnabled: false, }); @@ -600,7 +600,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10" + "Runtime": "nodejs10.x" }, "DependsOn": [ "MyLambdaServiceRole4539ECB6" @@ -623,7 +623,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, deadLetterQueue: dlQueue, }); @@ -700,7 +700,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10", + "Runtime": "nodejs10.x", "DeadLetterConfig": { "TargetArn": { "Fn::GetAtt": [ @@ -732,7 +732,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, deadLetterQueueEnabled: true, deadLetterQueue: dlQueue, }); @@ -810,7 +810,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10", + "Runtime": "nodejs10.x", "DeadLetterConfig": { "TargetArn": { "Fn::GetAtt": [ @@ -856,7 +856,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, tracing: lambda.Tracing.ACTIVE }); @@ -894,7 +894,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10", + "Runtime": "nodejs10.x", "TracingConfig": { "Mode": "Active" } @@ -914,7 +914,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, tracing: lambda.Tracing.PASS_THROUGH }); @@ -952,7 +952,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10", + "Runtime": "nodejs10.x", "TracingConfig": { "Mode": "PassThrough" } @@ -972,7 +972,7 @@ export = { new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, tracing: lambda.Tracing.DISABLED }); @@ -1010,7 +1010,7 @@ export = { "Arn" ] }, - "Runtime": "nodejs8.10" + "Runtime": "nodejs10.x" }, "DependsOn": [ "MyLambdaServiceRole4539ECB6" @@ -1236,17 +1236,17 @@ export = { const stack = new cdk.Stack(undefined, 'TestStack'); const layer = lambda.LayerVersion.fromLayerVersionAttributes(stack, 'TestLayer', { layerVersionArn: 'arn:aws:...', - compatibleRuntimes: [lambda.Runtime.NODEJS_8_10], + compatibleRuntimes: [lambda.Runtime.NODEJS_12_X], }); // THEN test.throws(() => new lambda.Function(stack, 'Function', { layers: [layer], - runtime: lambda.Runtime.NODEJS_6_10, + runtime: lambda.Runtime.NODEJS_10_X, code: lambda.Code.fromInline('exports.main = function() { console.log("DONE"); }'), handler: 'index.main' }), - /nodejs6.10 is not in \[nodejs8.10\]/); + /nodejs10.x is not in \[nodejs12.x\]/); test.done(); }, diff --git a/packages/@aws-cdk/aws-lambda/test/test.layers.ts b/packages/@aws-cdk/aws-lambda/test/test.layers.ts index d7103f44c7bdb..48c23b9d907a5 100644 --- a/packages/@aws-cdk/aws-lambda/test/test.layers.ts +++ b/packages/@aws-cdk/aws-lambda/test/test.layers.ts @@ -16,7 +16,7 @@ export = testCase({ // WHEN new lambda.LayerVersion(stack, 'LayerVersion', { code, - compatibleRuntimes: [lambda.Runtime.NODEJS_8_10] + compatibleRuntimes: [lambda.Runtime.NODEJS_10_X] }); // THEN @@ -25,7 +25,7 @@ export = testCase({ S3Bucket: stack.resolve(bucket.bucketName), S3Key: 'ObjectKey', }, - CompatibleRuntimes: ['nodejs8.10'] + CompatibleRuntimes: ['nodejs10.x'] })); test.done(); diff --git a/packages/@aws-cdk/aws-lambda/test/test.vpc-lambda.ts b/packages/@aws-cdk/aws-lambda/test/test.vpc-lambda.ts index b03fe157b9ba9..0db9148dbe4f2 100644 --- a/packages/@aws-cdk/aws-lambda/test/test.vpc-lambda.ts +++ b/packages/@aws-cdk/aws-lambda/test/test.vpc-lambda.ts @@ -49,7 +49,7 @@ export = { new lambda.Function(this.stack, 'LambdaWithCustomSG', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, vpc: this.vpc, securityGroup: new ec2.SecurityGroup(this.stack, 'CustomSecurityGroupX', { vpc: this.vpc }), }); @@ -74,7 +74,7 @@ export = { new lambda.Function(this.stack, 'LambdaWithCustomSGList', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, vpc: this.vpc, securityGroups: [ new ec2.SecurityGroup(this.stack, 'CustomSecurityGroupA', { vpc: this.vpc }), @@ -104,7 +104,7 @@ export = { new lambda.Function(this.stack, 'LambdaWithWrongProps', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, vpc: this.vpc, securityGroup: new ec2.SecurityGroup(this.stack, 'CustomSecurityGroupB', { vpc: this.vpc }), securityGroups: [ diff --git a/packages/@aws-cdk/aws-logs-destinations/package.json b/packages/@aws-cdk/aws-logs-destinations/package.json index 7ba930640337c..5e320aadd315b 100644 --- a/packages/@aws-cdk/aws-logs-destinations/package.json +++ b/packages/@aws-cdk/aws-logs-destinations/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-logs-destinations", - "version": "1.19.0", + "version": "1.21.0", "description": "Log Destinations for AWS CloudWatch Logs", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,30 +76,30 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kinesis": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kinesis": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kinesis": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kinesis": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-logs/package.json b/packages/@aws-cdk/aws-logs/package.json index 333a5aa119f98..2f6330a5c27b5 100644 --- a/packages/@aws-cdk/aws-logs/package.json +++ b/packages/@aws-cdk/aws-logs/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-logs", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Logs", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,24 +62,24 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -102,4 +102,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-managedblockchain/package.json b/packages/@aws-cdk/aws-managedblockchain/package.json index fa0653abd706b..a085b7416f22c 100644 --- a/packages/@aws-cdk/aws-managedblockchain/package.json +++ b/packages/@aws-cdk/aws-managedblockchain/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-managedblockchain", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ManagedBlockchain", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-mediaconvert/package.json b/packages/@aws-cdk/aws-mediaconvert/package.json index f4667776086be..573fb4369d040 100644 --- a/packages/@aws-cdk/aws-mediaconvert/package.json +++ b/packages/@aws-cdk/aws-mediaconvert/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-mediaconvert", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::MediaConvert", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-medialive/package.json b/packages/@aws-cdk/aws-medialive/package.json index 714c3199724da..77e94dd276cda 100644 --- a/packages/@aws-cdk/aws-medialive/package.json +++ b/packages/@aws-cdk/aws-medialive/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-medialive", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::MediaLive", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-mediastore/package.json b/packages/@aws-cdk/aws-mediastore/package.json index f2ade0c637867..97dce5d17195d 100644 --- a/packages/@aws-cdk/aws-mediastore/package.json +++ b/packages/@aws-cdk/aws-mediastore/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-mediastore", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::MediaStore", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk/package.json b/packages/@aws-cdk/aws-msk/package.json index d3a39ad58de41..716d196a0e18c 100644 --- a/packages/@aws-cdk/aws-msk/package.json +++ b/packages/@aws-cdk/aws-msk/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-msk", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::MSK", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-neptune/package.json b/packages/@aws-cdk/aws-neptune/package.json index 2d001220fafe7..96ddd5eb00779 100644 --- a/packages/@aws-cdk/aws-neptune/package.json +++ b/packages/@aws-cdk/aws-neptune/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-neptune", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Neptune", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-opsworks/package.json b/packages/@aws-cdk/aws-opsworks/package.json index 731ab872bbd93..c87befe73d8bf 100644 --- a/packages/@aws-cdk/aws-opsworks/package.json +++ b/packages/@aws-cdk/aws-opsworks/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-opsworks", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::OpsWorks", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-opsworkscm/package.json b/packages/@aws-cdk/aws-opsworkscm/package.json index 7cc725f8f3b1e..9d2c58c3f6dc8 100644 --- a/packages/@aws-cdk/aws-opsworkscm/package.json +++ b/packages/@aws-cdk/aws-opsworkscm/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-opsworkscm", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::OpsWorksCM", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-pinpoint/package.json b/packages/@aws-cdk/aws-pinpoint/package.json index 8715b4c3e57cb..2c62fe4630f25 100644 --- a/packages/@aws-cdk/aws-pinpoint/package.json +++ b/packages/@aws-cdk/aws-pinpoint/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-pinpoint", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Pinpoint", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-pinpointemail/package.json b/packages/@aws-cdk/aws-pinpointemail/package.json index 606327a4f909c..44743fc3e2833 100644 --- a/packages/@aws-cdk/aws-pinpointemail/package.json +++ b/packages/@aws-cdk/aws-pinpointemail/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-pinpointemail", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::PinpointEmail", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-qldb/package.json b/packages/@aws-cdk/aws-qldb/package.json index 63c6c8c5cbb63..6c640bfefed2d 100644 --- a/packages/@aws-cdk/aws-qldb/package.json +++ b/packages/@aws-cdk/aws-qldb/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-qldb", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::QLDB", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ram/package.json b/packages/@aws-cdk/aws-ram/package.json index db028d47a13f3..cce7216b73885 100644 --- a/packages/@aws-cdk/aws-ram/package.json +++ b/packages/@aws-cdk/aws-ram/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ram", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::RAM", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/lib/cluster.ts b/packages/@aws-cdk/aws-rds/lib/cluster.ts index 79e1264a682cc..3cb4fd321e05c 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster.ts @@ -102,11 +102,9 @@ export interface DatabaseClusterProps { readonly kmsKey?: kms.IKey; /** - * A daily time range in 24-hours UTC format in which backups preferably execute. + * A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). * - * Must be at least 30 minutes long. - * - * Example: '01:00-02:00' + * Example: 'Sun:23:45-Mon:00:15' * * @default - 30-minute window selected at random from an 8-hour block of time for * each AWS Region, occurring on a random day of the week. diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index 32e8f6e0ba4e4..d26c14b8f8e22 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -965,7 +965,8 @@ export class DatabaseInstanceReadReplica extends DatabaseInstanceNew implements const instance = new CfnDBInstance(this, 'Resource', { ...this.newCfnProps, - sourceDbInstanceIdentifier: props.sourceDatabaseInstance.instanceIdentifier, + // this must be ARN, not ID, because of https://github.com/terraform-providers/terraform-provider-aws/issues/528#issuecomment-391169012 + sourceDbInstanceIdentifier: props.sourceDatabaseInstance.instanceArn, kmsKeyId: props.kmsKey && props.kmsKey.keyArn, storageEncrypted: props.kmsKey ? true : props.storageEncrypted, }); diff --git a/packages/@aws-cdk/aws-rds/package.json b/packages/@aws-cdk/aws-rds/package.json index eeeab965a30ba..cbd32cc2e842b 100644 --- a/packages/@aws-cdk/aws-rds/package.json +++ b/packages/@aws-cdk/aws-rds/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-rds", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS RDS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,37 +62,37 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -136,4 +136,4 @@ ] }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/test.instance.ts b/packages/@aws-cdk/aws-rds/test/test.instance.ts index 30b519d4432f7..35876e9afa3e0 100644 --- a/packages/@aws-cdk/aws-rds/test/test.instance.ts +++ b/packages/@aws-cdk/aws-rds/test/test.instance.ts @@ -301,7 +301,7 @@ export = { test.done(); }, - 'create a read replica'(test: Test) { + 'create a read replica in the same region - with the subnet group name'(test: Test) { // GIVEN const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); @@ -323,8 +323,20 @@ export = { // THEN expect(stack).to(haveResource('AWS::RDS::DBInstance', { SourceDBInstanceIdentifier: { - Ref: 'InstanceC1063A87' - } + "Fn::Join": ["", [ + "arn:", + { Ref: "AWS::Partition" }, + ":rds:", + { Ref: "AWS::Region" }, + ":", + { Ref: "AWS::AccountId" }, + ":db:", + { Ref: "InstanceC1063A87" }, + ]], + }, + DBSubnetGroupName: { + Ref: 'ReadReplicaSubnetGroup680C605C', + }, })); test.done(); diff --git a/packages/@aws-cdk/aws-redshift/package.json b/packages/@aws-cdk/aws-redshift/package.json index 7f10baae9817e..3203700c4dfa4 100644 --- a/packages/@aws-cdk/aws-redshift/package.json +++ b/packages/@aws-cdk/aws-redshift/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-redshift", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Redshift", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-robomaker/package.json b/packages/@aws-cdk/aws-robomaker/package.json index 582a3843cd7b5..82f8260088e2a 100644 --- a/packages/@aws-cdk/aws-robomaker/package.json +++ b/packages/@aws-cdk/aws-robomaker/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-robomaker", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::RoboMaker", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-patterns/package.json b/packages/@aws-cdk/aws-route53-patterns/package.json index 656a19196e5a0..1ce88ca217e77 100644 --- a/packages/@aws-cdk/aws-route53-patterns/package.json +++ b/packages/@aws-cdk/aws-route53-patterns/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-route53-patterns", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS Route53 patterns", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,33 +76,33 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/region-info": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/region-info": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/region-info": "1.19.0" + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/region-info": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -114,4 +114,4 @@ "docs-public-apis:@aws-cdk/aws-route53-patterns.HttpsRedirectProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-targets/package.json b/packages/@aws-cdk/aws-route53-targets/package.json index fbbbdb7dbabbd..1b102a05e2e68 100644 --- a/packages/@aws-cdk/aws-route53-targets/package.json +++ b/packages/@aws-cdk/aws-route53-targets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-route53-targets", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS Route53 Alias Targets", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,41 +76,41 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-apigateway": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/region-info": "1.19.0" + "@aws-cdk/aws-apigateway": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/region-info": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-apigateway": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/region-info": "1.19.0" + "@aws-cdk/aws-apigateway": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/region-info": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53-targets/test/classic-load-balancer-target.test.ts b/packages/@aws-cdk/aws-route53-targets/test/classic-load-balancer-target.test.ts index adae96db257ed..46ae09ccdff7b 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/classic-load-balancer-target.test.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/classic-load-balancer-target.test.ts @@ -22,7 +22,7 @@ test('use classic ELB as record target', () => { new route53.ARecord(zone, 'Alias', { zone, recordName: '_foo', - target: route53.AddressRecordTarget.fromAlias(new targets.ClassicLoadBalancerTarget(lb)) + target: route53.RecordTarget.fromAlias(new targets.ClassicLoadBalancerTarget(lb)) }); // THEN diff --git a/packages/@aws-cdk/aws-route53-targets/test/cloudfront-target.test.ts b/packages/@aws-cdk/aws-route53-targets/test/cloudfront-target.test.ts index bacb38bd7ac88..d00cdeeb72ef2 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/cloudfront-target.test.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/cloudfront-target.test.ts @@ -27,7 +27,7 @@ test('use CloudFront as record target', () => { new route53.ARecord(zone, 'Alias', { zone, recordName: '_foo', - target: route53.AddressRecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)) + target: route53.RecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)) }); // THEN diff --git a/packages/@aws-cdk/aws-route53-targets/test/integ.alb-alias-target.ts b/packages/@aws-cdk/aws-route53-targets/test/integ.alb-alias-target.ts index 2a31a12bfcbd3..fec83da47b9e1 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/integ.alb-alias-target.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/integ.alb-alias-target.ts @@ -22,7 +22,7 @@ const zone = new route53.PublicHostedZone(stack, 'HostedZone', { zoneName: 'test new route53.ARecord(zone, 'Alias', { zone, recordName: '_foo', - target: route53.AddressRecordTarget.fromAlias(new targets.LoadBalancerTarget(lb)) + target: route53.RecordTarget.fromAlias(new targets.LoadBalancerTarget(lb)) }); app.synth(); diff --git a/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts b/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts index 4601caf8e14dd..b2ecd1bc75879 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/integ.api-gateway-domain-name.ts @@ -43,7 +43,7 @@ class TestStack extends Stack { new route53.ARecord(this, 'Alias', { zone, - target: route53.AddressRecordTarget.fromAlias(new targets.ApiGateway(api)) + target: route53.RecordTarget.fromAlias(new targets.ApiGateway(api)) }); } } diff --git a/packages/@aws-cdk/aws-route53-targets/test/integ.cloudfront-alias-target.ts b/packages/@aws-cdk/aws-route53-targets/test/integ.cloudfront-alias-target.ts index 6152c17b7ccfe..09b2a64644440 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/integ.cloudfront-alias-target.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/integ.cloudfront-alias-target.ts @@ -28,7 +28,7 @@ const distribution = new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribu new route53.ARecord(zone, 'Alias', { zone, recordName: '_foo', - target: route53.AddressRecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)) + target: route53.RecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)) }); app.synth(); diff --git a/packages/@aws-cdk/aws-route53-targets/test/load-balancer-target.test.ts b/packages/@aws-cdk/aws-route53-targets/test/load-balancer-target.test.ts index 4ca6115c3ca6d..e49ff542428c3 100644 --- a/packages/@aws-cdk/aws-route53-targets/test/load-balancer-target.test.ts +++ b/packages/@aws-cdk/aws-route53-targets/test/load-balancer-target.test.ts @@ -22,7 +22,7 @@ test('use ALB as record target', () => { new route53.ARecord(zone, 'Alias', { zone, recordName: '_foo', - target: route53.AddressRecordTarget.fromAlias(new targets.LoadBalancerTarget(lb)) + target: route53.RecordTarget.fromAlias(new targets.LoadBalancerTarget(lb)) }); // THEN diff --git a/packages/@aws-cdk/aws-route53/README.md b/packages/@aws-cdk/aws-route53/README.md index 2f4418c710c05..3007b51ae9184 100644 --- a/packages/@aws-cdk/aws-route53/README.md +++ b/packages/@aws-cdk/aws-route53/README.md @@ -63,7 +63,7 @@ import route53 = require('@aws-cdk/aws-route53'); new route53.ARecord(this, 'ARecord', { zone: myZone, - target: route53.AddressRecordTarget.fromIpAddresses('1.2.3.4', '5.6.7.8') + target: route53.RecordTarget.fromIpAddresses('1.2.3.4', '5.6.7.8') }); ``` @@ -74,7 +74,7 @@ import targets = require('@aws-cdk/aws-route53-targets'); new route53.AaaaRecord(this, 'Alias', { zone: myZone, - target: route53.AddressRecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)) + target: route53.RecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)) }); ``` diff --git a/packages/@aws-cdk/aws-route53/lib/record-set.ts b/packages/@aws-cdk/aws-route53/lib/record-set.ts index 3137825e85bf0..d41b8456b8564 100644 --- a/packages/@aws-cdk/aws-route53/lib/record-set.ts +++ b/packages/@aws-cdk/aws-route53/lib/record-set.ts @@ -171,7 +171,7 @@ export interface AaaaRecordProps extends RecordSetOptions { /** * The target. */ - readonly target: AddressRecordTarget; + readonly target: RecordTarget; } /** diff --git a/packages/@aws-cdk/aws-route53/package.json b/packages/@aws-cdk/aws-route53/package.json index 23b8e5198112b..bcb6be5b649c2 100644 --- a/packages/@aws-cdk/aws-route53/package.json +++ b/packages/@aws-cdk/aws-route53/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-route53", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS Route53", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,27 +62,27 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -137,4 +137,4 @@ "lines": 60, "branches": 60 } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-route53/test/integ.route53.ts b/packages/@aws-cdk/aws-route53/test/integ.route53.ts index 8a59e5a44f707..6e48977b62ac9 100644 --- a/packages/@aws-cdk/aws-route53/test/integ.route53.ts +++ b/packages/@aws-cdk/aws-route53/test/integ.route53.ts @@ -1,6 +1,6 @@ import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; -import { AddressRecordTarget, ARecord, CaaAmazonRecord, CnameRecord, PrivateHostedZone, PublicHostedZone, TxtRecord } from '../lib'; +import { ARecord, CaaAmazonRecord, CnameRecord, PrivateHostedZone, PublicHostedZone, RecordTarget, TxtRecord } from '../lib'; const app = new cdk.App(); @@ -39,7 +39,7 @@ new CnameRecord(stack, 'CNAME', { new ARecord(stack, 'A', { zone: privateZone, recordName: 'test', - target: AddressRecordTarget.fromIpAddresses('1.2.3.4', '5.6.7.8') + target: RecordTarget.fromIpAddresses('1.2.3.4', '5.6.7.8') }); new CaaAmazonRecord(stack, 'CaaAmazon', { diff --git a/packages/@aws-cdk/aws-route53/test/test.record-set.ts b/packages/@aws-cdk/aws-route53/test/test.record-set.ts index 68ff1a47bd69e..a96663a2b7239 100644 --- a/packages/@aws-cdk/aws-route53/test/test.record-set.ts +++ b/packages/@aws-cdk/aws-route53/test/test.record-set.ts @@ -108,7 +108,7 @@ export = { new route53.ARecord(stack, 'A', { zone, recordName: 'www', - target: route53.AddressRecordTarget.fromIpAddresses('1.2.3.4', '5.6.7.8'), + target: route53.RecordTarget.fromIpAddresses('1.2.3.4', '5.6.7.8'), }); // THEN @@ -179,7 +179,7 @@ export = { new route53.AaaaRecord(stack, 'AAAA', { zone, recordName: 'www', - target: route53.AddressRecordTarget.fromIpAddresses('2001:0db8:85a3:0000:0000:8a2e:0370:7334'), + target: route53.RecordTarget.fromIpAddresses('2001:0db8:85a3:0000:0000:8a2e:0370:7334'), }); // THEN diff --git a/packages/@aws-cdk/aws-route53resolver/package.json b/packages/@aws-cdk/aws-route53resolver/package.json index 59df469cdeebb..e14b1f74ec796 100644 --- a/packages/@aws-cdk/aws-route53resolver/package.json +++ b/packages/@aws-cdk/aws-route53resolver/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-route53resolver", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Route53Resolver", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-assets/package.json b/packages/@aws-cdk/aws-s3-assets/package.json index 49affe9fcb96f..f89a35cc4bd63 100644 --- a/packages/@aws-cdk/aws-s3-assets/package.json +++ b/packages/@aws-cdk/aws-s3-assets/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-s3-assets", - "version": "1.19.0", + "version": "1.21.0", "description": "Deploy local files and directories to S3", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -59,31 +59,31 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", "@types/sinon": "^7.5.0", - "aws-cdk": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "aws-cdk": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0", - "sinon": "^8.0.2", + "pkglint": "1.21.0", + "sinon": "^8.1.0", "ts-mock-imports": "^1.2.6" }, "dependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -95,4 +95,4 @@ "docs-public-apis:@aws-cdk/aws-s3-assets.AssetProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts b/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts index 17cd6d8c38c94..79488eaaf7370 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts +++ b/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts @@ -162,8 +162,6 @@ export class BucketDeployment extends cdk.Construct { } const sourceHash = calcSourceHash(handlerSourceDirectory); - // tslint:disable-next-line: no-console - console.error({sourceHash}); const handler = new lambda.SingletonFunction(this, 'CustomResourceHandler', { uuid: this.renderSingletonUuid(props.memoryLimit), diff --git a/packages/@aws-cdk/aws-s3-deployment/package.json b/packages/@aws-cdk/aws-s3-deployment/package.json index 0dcf2e4c3f594..d689ce19534b3 100644 --- a/packages/@aws-cdk/aws-s3-deployment/package.json +++ b/packages/@aws-cdk/aws-s3-deployment/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-s3-deployment", - "version": "1.19.0", + "version": "1.21.0", "description": "Constructs for deploying contents to S3 buckets", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,31 +76,31 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -135,4 +135,4 @@ "docs-public-apis:@aws-cdk/aws-s3-deployment.StorageClass.DEEP_ARCHIVE" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3-notifications/package.json b/packages/@aws-cdk/aws-s3-notifications/package.json index 0e2492396baa7..797d868d54e7e 100644 --- a/packages/@aws-cdk/aws-s3-notifications/package.json +++ b/packages/@aws-cdk/aws-s3-notifications/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-s3-notifications", - "version": "1.19.0", + "version": "1.21.0", "description": "Bucket Notifications API for AWS S3", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -75,31 +75,31 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3/README.md b/packages/@aws-cdk/aws-s3/README.md index db6bd71b9de75..ecf645d4c55cd 100644 --- a/packages/@aws-cdk/aws-s3/README.md +++ b/packages/@aws-cdk/aws-s3/README.md @@ -192,6 +192,28 @@ When `blockPublicPolicy` is set to `true`, `grantPublicRead()` throws an error. [block public access settings]: https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html +### Logging configuration + +Use `serverAccessLogsBucket` to describe where server access logs are to be stored. + +```ts +const accessLogsBucket = new Bucket(this, 'AccessLogsBucket'); + +const bucket = new Bucket(this, 'MyBucket', { + serverAccessLogsBucket: accessLogsBucket, +}); +``` + +It's also possible to specify a prefix for Amazon S3 to assign to all log object keys. + +```ts +const bucket = new Bucket(this, 'MyBucket', { + serverAccessLogsBucket: accessLogsBucket, + serverAccessLogsPrefix: 'logs' +}); +``` + +[S3 Server access logging]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerLogs.html ### Website redirection diff --git a/packages/@aws-cdk/aws-s3/lib/bucket.ts b/packages/@aws-cdk/aws-s3/lib/bucket.ts index 206aac0d1d97e..505471d510289 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket.ts @@ -901,6 +901,18 @@ export interface BucketProps { * @default - No CORS configuration. */ readonly cors?: CorsRule[]; + + /** + * Destination bucket for the server access logs. + * @default - Access logs are disabled + */ + readonly serverAccessLogsBucket?: IBucket; + + /** + * Optional log file prefix to use for the bucket's access logs. + * @default - No log file prefix + */ + readonly serverAccessLogsPrefix?: string; } /** @@ -982,6 +994,7 @@ export class Bucket extends BucketBase { public policy?: BucketPolicy; protected autoCreatePolicy = true; protected disallowPublicAccess?: boolean; + private accessControl?: BucketAccessControl; private readonly lifecycleRules: LifecycleRule[] = []; private readonly versioned?: boolean; private readonly notifications: BucketNotifications; @@ -1006,7 +1019,8 @@ export class Bucket extends BucketBase { publicAccessBlockConfiguration: props.blockPublicAccess, metricsConfigurations: Lazy.anyValue({ produce: () => this.parseMetricConfiguration() }), corsConfiguration: Lazy.anyValue({ produce: () => this.parseCorsConfiguration() }), - accessControl: props.accessControl, + accessControl: Lazy.stringValue({ produce: () => this.accessControl }), + loggingConfiguration: this.parseServerAccessLogs(props), }); resource.applyRemovalPolicy(props.removalPolicy); @@ -1029,6 +1043,11 @@ export class Bucket extends BucketBase { this.bucketRegionalDomainName = resource.attrRegionalDomainName; this.disallowPublicAccess = props.blockPublicAccess && props.blockPublicAccess.blockPublicPolicy; + this.accessControl = props.accessControl; + + if (props.serverAccessLogsBucket instanceof Bucket) { + props.serverAccessLogsBucket.allowLogDelivery(); + } // Add all bucket metric configurations rules (props.metrics || []).forEach(this.addMetric.bind(this)); @@ -1273,6 +1292,21 @@ export class Bucket extends BucketBase { } } + private parseServerAccessLogs(props: BucketProps): CfnBucket.LoggingConfigurationProperty | undefined { + if (props.serverAccessLogsPrefix && !props.serverAccessLogsBucket) { + throw new Error(`"serverAccessLogsBucket" is required if "serverAccessLogsPrefix" is set`); + } + + if (!props.serverAccessLogsBucket) { + return undefined; + } + + return { + destinationBucketName: props.serverAccessLogsBucket.bucketName, + logFilePrefix: props.serverAccessLogsPrefix, + }; + } + private parseMetricConfiguration(): CfnBucket.MetricsConfigurationProperty[] | undefined { if (!this.metrics || this.metrics.length === 0) { return undefined; @@ -1358,6 +1392,20 @@ export class Bucket extends BucketBase { routingRules }; } + + /** + * Allows the LogDelivery group to write, fails if ACL was set differently. + * + * @see + * https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl + */ + private allowLogDelivery() { + if (this.accessControl && this.accessControl !== BucketAccessControl.LOG_DELIVERY_WRITE) { + throw new Error("Cannot enable log delivery to this bucket because the bucket's ACL has been set and can't be changed"); + } + + this.accessControl = BucketAccessControl.LOG_DELIVERY_WRITE; + } } /** diff --git a/packages/@aws-cdk/aws-s3/package.json b/packages/@aws-cdk/aws-s3/package.json index d9253b9193e44..effb9cd9e8a80 100644 --- a/packages/@aws-cdk/aws-s3/package.json +++ b/packages/@aws-cdk/aws-s3/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-s3", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS S3", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,26 +62,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -136,4 +136,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3/test/integ.bucket.server-access-logs.expected.json b/packages/@aws-cdk/aws-s3/test/integ.bucket.server-access-logs.expected.json new file mode 100644 index 0000000000000..87fe6aa792b63 --- /dev/null +++ b/packages/@aws-cdk/aws-s3/test/integ.bucket.server-access-logs.expected.json @@ -0,0 +1,25 @@ +{ + "Resources": { + "MyAccessLogsBucketF7FE6635": { + "Type": "AWS::S3::Bucket", + "Properties": { + "AccessControl": "LogDeliveryWrite" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "MyBucketF68F3FF0": { + "Type": "AWS::S3::Bucket", + "Properties": { + "LoggingConfiguration": { + "DestinationBucketName": { + "Ref": "MyAccessLogsBucketF7FE6635" + }, + "LogFilePrefix": "example" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-s3/test/integ.bucket.server-access-logs.ts b/packages/@aws-cdk/aws-s3/test/integ.bucket.server-access-logs.ts new file mode 100644 index 0000000000000..3373257e5529c --- /dev/null +++ b/packages/@aws-cdk/aws-s3/test/integ.bucket.server-access-logs.ts @@ -0,0 +1,19 @@ +#!/usr/bin/env node +import * as cdk from '@aws-cdk/core'; +import * as s3 from '../lib'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'aws-cdk-s3-access-logs'); + +const accessLogBucket = new s3.Bucket(stack, 'MyAccessLogsBucket', { + removalPolicy: cdk.RemovalPolicy.DESTROY, +}); + +new s3.Bucket(stack, 'MyBucket', { + serverAccessLogsBucket: accessLogBucket, + serverAccessLogsPrefix: 'example', + removalPolicy: cdk.RemovalPolicy.DESTROY, +}); + +app.synth(); diff --git a/packages/@aws-cdk/aws-s3/test/test.bucket.ts b/packages/@aws-cdk/aws-s3/test/test.bucket.ts index 07d5df2eb6f57..a5e05f4b6e56a 100644 --- a/packages/@aws-cdk/aws-s3/test/test.bucket.ts +++ b/packages/@aws-cdk/aws-s3/test/test.bucket.ts @@ -1723,5 +1723,82 @@ export = { // THEN new s3.Bucket(stack, 'b', { encryptionKey: key }); test.done(); - } + }, + + 'Bucket with Server Access Logs'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const accessLogBucket = new s3.Bucket(stack, 'AccessLogs'); + new s3.Bucket(stack, 'MyBucket', { + serverAccessLogsBucket: accessLogBucket, + }); + + // THEN + expect(stack).to(haveResource('AWS::S3::Bucket', { + LoggingConfiguration: { + DestinationBucketName: { + Ref: 'AccessLogs8B620ECA', + }, + } + })); + + test.done(); + }, + + 'Bucket with Server Access Logs with Prefix'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const accessLogBucket = new s3.Bucket(stack, 'AccessLogs'); + new s3.Bucket(stack, 'MyBucket', { + serverAccessLogsBucket: accessLogBucket, + serverAccessLogsPrefix: 'hello', + }); + + // THEN + expect(stack).to(haveResource('AWS::S3::Bucket', { + LoggingConfiguration: { + DestinationBucketName: { + Ref: 'AccessLogs8B620ECA', + }, + LogFilePrefix: 'hello' + } + })); + + test.done(); + }, + + 'Access log prefix given without bucket'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // THEN + test.throws(() => new s3.Bucket(stack, 'MyBucket', { + serverAccessLogsPrefix: 'hello' + }), /"serverAccessLogsBucket" is required if "serverAccessLogsPrefix" is set/); + + test.done(); + }, + + 'Bucket Allow Log delivery changes bucket Access Control should fail'(test: Test) { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const accessLogBucket = new s3.Bucket(stack, 'AccessLogs', { + accessControl: s3.BucketAccessControl.AUTHENTICATED_READ, + }); + test.throws(() => + new s3.Bucket(stack, 'MyBucket', { + serverAccessLogsBucket: accessLogBucket, + serverAccessLogsPrefix: 'hello', + accessControl: s3.BucketAccessControl.AUTHENTICATED_READ, + }) + , /Cannot enable log delivery to this bucket because the bucket's ACL has been set and can't be changed/); + + test.done(); + }, }; diff --git a/packages/@aws-cdk/aws-sagemaker/package.json b/packages/@aws-cdk/aws-sagemaker/package.json index 2b59a6909495b..93b48d810f845 100644 --- a/packages/@aws-cdk/aws-sagemaker/package.json +++ b/packages/@aws-cdk/aws-sagemaker/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sagemaker", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::SageMaker", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -80,19 +80,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sam/package.json b/packages/@aws-cdk/aws-sam/package.json index e6cebaa1673cb..f16ffe2707a11 100644 --- a/packages/@aws-cdk/aws-sam/package.json +++ b/packages/@aws-cdk/aws-sam/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sam", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for the AWS Serverless Application Model (SAM) resources", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -63,19 +63,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@types/jest": "^24.0.25", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@types/jest": "^24.9.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0", - "ts-jest": "^24.2.0" + "pkglint": "1.21.0", + "ts-jest": "^24.3.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "jest": { "collectCoverage": true, @@ -100,4 +100,4 @@ "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sdb/package.json b/packages/@aws-cdk/aws-sdb/package.json index e94c0d17171d6..007e313a9700e 100644 --- a/packages/@aws-cdk/aws-sdb/package.json +++ b/packages/@aws-cdk/aws-sdb/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sdb", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::SDB", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-secretsmanager/package.json b/packages/@aws-cdk/aws-secretsmanager/package.json index 5921ac870aaa8..2e37645c9266f 100644 --- a/packages/@aws-cdk/aws-secretsmanager/package.json +++ b/packages/@aws-cdk/aws-secretsmanager/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-secretsmanager", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::SecretsManager", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -63,29 +63,29 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -106,4 +106,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-securityhub/package.json b/packages/@aws-cdk/aws-securityhub/package.json index 4df247e1e698e..8132a6b185c46 100644 --- a/packages/@aws-cdk/aws-securityhub/package.json +++ b/packages/@aws-cdk/aws-securityhub/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-securityhub", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::SecurityHub", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicecatalog/package.json b/packages/@aws-cdk/aws-servicecatalog/package.json index 0ca625ed1f2b8..f74312ac1540c 100644 --- a/packages/@aws-cdk/aws-servicecatalog/package.json +++ b/packages/@aws-cdk/aws-servicecatalog/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-servicecatalog", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ServiceCatalog", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicediscovery/package.json b/packages/@aws-cdk/aws-servicediscovery/package.json index 46df877961277..612839ad50f08 100644 --- a/packages/@aws-cdk/aws-servicediscovery/package.json +++ b/packages/@aws-cdk/aws-servicediscovery/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-servicediscovery", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::ServiceDiscovery", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,26 +62,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -145,4 +145,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ses-actions/package.json b/packages/@aws-cdk/aws-ses-actions/package.json index 6e83c5fa3958a..a762a3fb22930 100644 --- a/packages/@aws-cdk/aws-ses-actions/package.json +++ b/packages/@aws-cdk/aws-ses-actions/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ses-actions", - "version": "1.19.0", + "version": "1.21.0", "description": "Receipt rule actions for AWS SES", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -77,31 +77,31 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-ses": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-ses": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-ses": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-ses": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -119,4 +119,4 @@ "props-default-doc:@aws-cdk/aws-ses-actions.StopProps.topic" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ses/package.json b/packages/@aws-cdk/aws-ses/package.json index 34ec92dce974f..a28e1057cc9a0 100644 --- a/packages/@aws-cdk/aws-ses/package.json +++ b/packages/@aws-cdk/aws-ses/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ses", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::SES", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,24 +62,24 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -99,4 +99,4 @@ "props-default-doc:@aws-cdk/aws-ses.ReceiptRuleActionConfig.lambdaAction" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sns-subscriptions/package.json b/packages/@aws-cdk/aws-sns-subscriptions/package.json index 9a51797096c00..7143b6a008922 100644 --- a/packages/@aws-cdk/aws-sns-subscriptions/package.json +++ b/packages/@aws-cdk/aws-sns-subscriptions/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sns-subscriptions", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Subscription Constructs for AWS SNS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -76,27 +76,27 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -111,4 +111,4 @@ "docs-public-apis:@aws-cdk/aws-sns-subscriptions.SubscriptionProps" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sns-subscriptions/test/subs.test.ts b/packages/@aws-cdk/aws-sns-subscriptions/test/subs.test.ts index 9ba2f61e6c7c4..d7bfe9c6d6c21 100644 --- a/packages/@aws-cdk/aws-sns-subscriptions/test/subs.test.ts +++ b/packages/@aws-cdk/aws-sns-subscriptions/test/subs.test.ts @@ -202,7 +202,7 @@ test('queue subscription (with raw delivery)', () => { test('lambda subscription', () => { const fction = new lambda.Function(stack, 'MyFunc', { - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.fromInline('exports.handler = function(e, c, cb) { return cb() }') }); @@ -262,7 +262,7 @@ test('lambda subscription', () => { "Arn" ] }, - "Runtime": "nodejs8.10" + "Runtime": "nodejs10.x" }, "DependsOn": [ "MyFuncServiceRole54065130" @@ -332,7 +332,7 @@ test('email subscription', () => { test('multiple subscriptions', () => { const queue = new sqs.Queue(stack, 'MyQueue'); const func = new lambda.Function(stack, 'MyFunc', { - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.fromInline('exports.handler = function(e, c, cb) { return cb() }') }); @@ -446,7 +446,7 @@ test('multiple subscriptions', () => { "Arn" ] }, - "Runtime": "nodejs8.10" + "Runtime": "nodejs10.x" }, "DependsOn": [ "MyFuncServiceRole54065130" diff --git a/packages/@aws-cdk/aws-sns/package.json b/packages/@aws-cdk/aws-sns/package.json index 9a7151e399eef..5ab2bfc05c69d 100644 --- a/packages/@aws-cdk/aws-sns/package.json +++ b/packages/@aws-cdk/aws-sns/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sns", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS SNS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -65,29 +65,29 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -121,4 +121,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-sqs/package.json b/packages/@aws-cdk/aws-sqs/package.json index 048ab2248ecac..775c591447e06 100644 --- a/packages/@aws-cdk/aws-sqs/package.json +++ b/packages/@aws-cdk/aws-sqs/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-sqs", - "version": "1.19.0", + "version": "1.21.0", "description": "CDK Constructs for AWS SQS", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,28 +62,28 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", "@types/nodeunit": "^0.0.30", - "aws-sdk": "^2.597.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "aws-sdk": "^2.601.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -100,4 +100,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ssm/package.json b/packages/@aws-cdk/aws-ssm/package.json index 4e4877c35ff19..2b719d3cf620a 100644 --- a/packages/@aws-cdk/aws-ssm/package.json +++ b/packages/@aws-cdk/aws-ssm/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-ssm", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::SSM", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,26 +62,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -102,4 +102,4 @@ ] }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json index fdb48ab10989d..414893f425e52 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/package.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-stepfunctions-tasks", - "version": "1.19.0", + "version": "1.21.0", "description": "Task integrations for AWS StepFunctions", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,44 +79,44 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -182,4 +182,4 @@ "props-default-doc:@aws-cdk/aws-stepfunctions-tasks.VpcConfig.subnets" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.ec2-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.ec2-task.expected.json index 879684a397616..0a57d22dc1fb6 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.ec2-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.ec2-task.expected.json @@ -465,34 +465,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } + "/aws-cdk/assets:1f37178655533422f6654c973b99eadec99a723c7181c912e4fb0976187c687c" ] ] }, @@ -529,36 +502,6 @@ } } }, - "TaskDefTheContainerAssetImageAdoptRepository997406C3": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "TaskDefTheContainerLogGroupD94C8EF5": { "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", @@ -601,13 +544,7 @@ { "Ref": "AWS::Partition" }, - ":ecr:test-region:12345678:repository/", - { - "Fn::GetAtt": [ - "TaskDefTheContainerAssetImageAdoptRepository997406C3", - "RepositoryName" - ] - } + ":ecr:test-region:12345678:repository/aws-cdk/assets" ] ] } @@ -641,144 +578,6 @@ ] } }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:test-region:12345678:repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - }, "StateMachineRoleB840431D": { "Type": "AWS::IAM::Role", "Properties": { @@ -908,22 +707,6 @@ "SsmParameterValueawsserviceecsoptimizedamiamazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" - }, - "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.fargate-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.fargate-task.expected.json index 8a4cde77c2fcd..c99f991489a69 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.fargate-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/integ.fargate-task.expected.json @@ -34,34 +34,7 @@ { "Ref": "AWS::URLSuffix" }, - "/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - }, - "@sha256:", - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } + "/aws-cdk/assets:1f37178655533422f6654c973b99eadec99a723c7181c912e4fb0976187c687c" ] ] }, @@ -100,36 +73,6 @@ } } }, - "TaskDefTheContainerAssetImageAdoptRepository997406C3": { - "Type": "Custom::ECRAdoptedRepository", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9", - "Arn" - ] - }, - "RepositoryName": { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "TaskDefTheContainerLogGroupD94C8EF5": { "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", @@ -172,13 +115,7 @@ { "Ref": "AWS::Partition" }, - ":ecr:test-region:12345678:repository/", - { - "Fn::GetAtt": [ - "TaskDefTheContainerAssetImageAdoptRepository997406C3", - "RepositoryName" - ] - } + ":ecr:test-region:12345678:repository/aws-cdk/assets" ] ] } @@ -212,144 +149,6 @@ ] } }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "ecr:GetRepositoryPolicy", - "ecr:SetRepositoryPolicy", - "ecr:DeleteRepository", - "ecr:ListImages", - "ecr:BatchDeleteImage" - ], - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":ecr:test-region:12345678:repository/", - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "@sha256:", - { - "Ref": "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A" - } - ] - } - ] - } - ] - ] - } - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "Roles": [ - { - "Ref": "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - } - ] - } - }, - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62c52BE89E9": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB" - }, - "S3Key": { - "Fn::Join": [ - "", - [ - { - "Fn::Select": [ - 0, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - }, - { - "Fn::Select": [ - 1, - { - "Fn::Split": [ - "||", - { - "Ref": "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7" - } - ] - } - ] - } - ] - ] - } - }, - "Handler": "handler.handler", - "Role": { - "Fn::GetAtt": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17", - "Arn" - ] - }, - "Runtime": "nodejs10.x", - "Timeout": 300 - }, - "DependsOn": [ - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleDefaultPolicy6BC8737C", - "AdoptEcrRepositorydbc60defc59544bcaa5c28c95d68f62cServiceRoleD788AA17" - ] - }, "FargateTaskSecurityGroup0BBB27CB": { "Type": "AWS::EC2::SecurityGroup", "Properties": { @@ -495,23 +294,5 @@ "StateMachineRoleB840431D" ] } - }, - "Parameters": { - "AssetParameters849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3ImageName999B381A": { - "Type": "String", - "Description": "ECR repository name and tag for asset \"849429eca8deea448d1c953aea3403a3d05d598c09880305dde8e99010d05db3\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3BucketE797C7BB": { - "Type": "String", - "Description": "S3 bucket for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1S3VersionKey56C3F6D7": { - "Type": "String", - "Description": "S3 key for asset version \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - }, - "AssetParametersea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1ArtifactHash7E5AE478": { - "Type": "String", - "Description": "Artifact hash for asset \"ea7034d81c091be1158bcd85b4958dc86ec6672c345be27607d68fdfcf26b1c1\"" - } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions/package.json b/packages/@aws-cdk/aws-stepfunctions/package.json index aad589ca8dd21..987d4c746eb6e 100644 --- a/packages/@aws-cdk/aws-stepfunctions/package.json +++ b/packages/@aws-cdk/aws-stepfunctions/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-stepfunctions", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::StepFunctions", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -62,26 +62,26 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", + "@aws-cdk/assert": "1.21.0", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" @@ -106,4 +106,4 @@ ] }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-transfer/package.json b/packages/@aws-cdk/aws-transfer/package.json index e6b4b52039232..9822c9dfcfc2d 100644 --- a/packages/@aws-cdk/aws-transfer/package.json +++ b/packages/@aws-cdk/aws-transfer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-transfer", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::Transfer", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-waf/package.json b/packages/@aws-cdk/aws-waf/package.json index 02a9352657bd9..037ea44840f63 100644 --- a/packages/@aws-cdk/aws-waf/package.json +++ b/packages/@aws-cdk/aws-waf/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-waf", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::WAF", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-wafregional/package.json b/packages/@aws-cdk/aws-wafregional/package.json index 3419ab17419a0..1d77783a880ec 100644 --- a/packages/@aws-cdk/aws-wafregional/package.json +++ b/packages/@aws-cdk/aws-wafregional/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-wafregional", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::WAFRegional", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-wafv2/package.json b/packages/@aws-cdk/aws-wafv2/package.json index 70487956b4f56..db6406fd82f69 100644 --- a/packages/@aws-cdk/aws-wafv2/package.json +++ b/packages/@aws-cdk/aws-wafv2/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-wafv2", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::WAFv2", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -81,19 +81,19 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-workspaces/package.json b/packages/@aws-cdk/aws-workspaces/package.json index 45afad03f9ac8..88f2a89a33b11 100644 --- a/packages/@aws-cdk/aws-workspaces/package.json +++ b/packages/@aws-cdk/aws-workspaces/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/aws-workspaces", - "version": "1.19.0", + "version": "1.21.0", "description": "The CDK Construct Library for AWS::WorkSpaces", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -79,20 +79,20 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", - "pkglint": "1.19.0" + "@aws-cdk/assert": "1.21.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/core": "1.19.0" + "@aws-cdk/core": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "experimental" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/cfnspec/package.json b/packages/@aws-cdk/cfnspec/package.json index 3d8b27dc7abce..379e57272be17 100644 --- a/packages/@aws-cdk/cfnspec/package.json +++ b/packages/@aws-cdk/cfnspec/package.json @@ -1,7 +1,7 @@ { "name": "@aws-cdk/cfnspec", "description": "The CloudFormation resource specification used by @aws-cdk packages", - "version": "1.19.0", + "version": "1.21.0", "scripts": { "update": "cdk-build && /bin/bash build-tools/update.sh", "build": "cdk-build && node build-tools/build", @@ -25,12 +25,12 @@ "@types/fs-extra": "^8.0.1", "@types/md5": "^2.1.33", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", + "cdk-build-tools": "1.21.0", "fast-json-patch": "^2.2.1", "fs-extra": "^8.1.0", "json-diff": "^0.5.4", "nodeunit": "^0.11.3", - "pkglint": "1.19.0", + "pkglint": "1.21.0", "sort-json": "^2.0.0" }, "dependencies": { diff --git a/packages/@aws-cdk/cloudformation-diff/package.json b/packages/@aws-cdk/cloudformation-diff/package.json index 04962b280828e..a36aa54a76e35 100644 --- a/packages/@aws-cdk/cloudformation-diff/package.json +++ b/packages/@aws-cdk/cloudformation-diff/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/cloudformation-diff", - "version": "1.19.0", + "version": "1.21.0", "description": "Utilities to diff CDK stacks against CloudFormation templates", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -41,23 +41,23 @@ }, "license": "Apache-2.0", "dependencies": { - "@aws-cdk/cfnspec": "1.19.0", - "@aws-cdk/cx-api": "1.19.0", + "@aws-cdk/cfnspec": "1.21.0", + "@aws-cdk/cx-api": "1.21.0", "colors": "^1.4.0", - "diff": "^4.0.1", + "diff": "^4.0.2", "fast-deep-equal": "^3.1.1", "string-width": "^4.2.0", "table": "^5.4.6" }, "devDependencies": { - "@types/jest": "^24.0.25", + "@types/jest": "^24.9.0", "@types/string-width": "^4.0.1", "@types/table": "^4.0.7", - "cdk-build-tools": "1.19.0", + "cdk-build-tools": "1.21.0", "fast-check": "^1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0", - "ts-jest": "^24.2.0" + "pkglint": "1.21.0", + "ts-jest": "^24.3.0" }, "repository": { "url": "https://github.com/aws/aws-cdk.git", diff --git a/packages/@aws-cdk/core/lib/assets.ts b/packages/@aws-cdk/core/lib/assets.ts index ed2e59cd94d0f..a397a8aa6624a 100644 --- a/packages/@aws-cdk/core/lib/assets.ts +++ b/packages/@aws-cdk/core/lib/assets.ts @@ -72,6 +72,7 @@ export interface DockerImageAssetSource { * registry and the tag parts. * * @default - automatically derived from the asset's ID. + * @deprecated repository name should be specified at the environment-level and not at the image level */ readonly repositoryName?: string; } diff --git a/packages/@aws-cdk/core/lib/private/asset-parameters.ts b/packages/@aws-cdk/core/lib/private/asset-parameters.ts index cc74067bccc37..727491de55159 100644 --- a/packages/@aws-cdk/core/lib/private/asset-parameters.ts +++ b/packages/@aws-cdk/core/lib/private/asset-parameters.ts @@ -29,16 +29,3 @@ export class FileAssetParameters extends Construct { }); } } - -export class DockerImageAssetParameters extends Construct { - public readonly imageNameParameter: CfnParameter; - - constructor(scope: Construct, id: string) { - super(scope, id); - - this.imageNameParameter = new CfnParameter(this, 'ImageName', { - type: 'String', - description: `ECR repository name and tag for asset "${id}"`, - }); - } -} diff --git a/packages/@aws-cdk/core/lib/private/cloudformation-lang.ts b/packages/@aws-cdk/core/lib/private/cloudformation-lang.ts index a6b184bb0cd5e..941f33155ff31 100644 --- a/packages/@aws-cdk/core/lib/private/cloudformation-lang.ts +++ b/packages/@aws-cdk/core/lib/private/cloudformation-lang.ts @@ -1,6 +1,6 @@ import { Lazy } from "../lazy"; import { Reference } from "../reference"; -import { DefaultTokenResolver, IFragmentConcatenator, IPostProcessor, IResolvable, IResolveContext } from "../resolvable"; +import { DefaultTokenResolver, IFragmentConcatenator, IPostProcessor, IResolvable, IResolveContext } from "../resolvable"; import { TokenizedStringFragments } from "../string-fragments"; import { Token } from "../token"; import { Intrinsic } from "./intrinsic"; @@ -171,9 +171,16 @@ export function minimalCloudFormationJoin(delimiter: string, values: any[]): any } function isSplicableFnJoinIntrinsic(obj: any): boolean { - return isIntrinsic(obj) - && Object.keys(obj)[0] === 'Fn::Join' - && obj['Fn::Join'][0] === delimiter; + if (!isIntrinsic(obj)) { return false; } + if (Object.keys(obj)[0] !== 'Fn::Join') { return false; } + + const [ delim, list ] = obj['Fn::Join']; + if (delim !== delimiter) { return false; } + + if (Token.isUnresolved(list)) { return false; } + if (!Array.isArray(list)) { return false; } + + return true; } } diff --git a/packages/@aws-cdk/core/lib/stack.ts b/packages/@aws-cdk/core/lib/stack.ts index 1683063020163..30a0119cbebd8 100644 --- a/packages/@aws-cdk/core/lib/stack.ts +++ b/packages/@aws-cdk/core/lib/stack.ts @@ -6,7 +6,7 @@ import { DockerImageAssetLocation, DockerImageAssetSource, FileAssetLocation , F import { Construct, ConstructNode, IConstruct, ISynthesisSession } from './construct'; import { ContextProvider } from './context-provider'; import { Environment } from './environment'; -import { DockerImageAssetParameters, FileAssetParameters } from './private/asset-parameters'; +import { FileAssetParameters } from './private/asset-parameters'; import { CLOUDFORMATION_TOKEN_RESOLVER, CloudFormationLang } from './private/cloudformation-lang'; import { LogicalIDs } from './private/logical-id'; import { findTokens , resolve } from './private/resolve'; @@ -17,6 +17,21 @@ const MY_STACK_CACHE = Symbol.for('@aws-cdk/core.Stack.myStack'); const VALID_STACK_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/; +/** + * The well-known name for the docker image asset ECR repository. All docker + * image assets will be pushed into this repository with an image tag based on + * the source hash. + */ +const ASSETS_ECR_REPOSITORY_NAME = "aws-cdk/assets"; + +/** + * This allows users to work around the fact that the ECR repository is + * (currently) not configurable by setting this context key to their desired + * repository name. The CLI will auto-create this ECR repository if it's not + * already created. + */ +const ASSETS_ECR_REPOSITORY_NAME_OVERRIDE_CONTEXT_KEY = "assets-ecr-repository-name"; + export interface StackProps { /** * A description of the stack. @@ -220,6 +235,12 @@ export class Stack extends Construct implements ITaggable { private _templateUrl?: string; private readonly _stackName: string; + /** + * The image ID of all the docker image assets that were already added to this + * stack (to avoid duplication). + */ + private readonly addedImageAssets = new Set(); + /** * Creates a new stack. * @@ -551,34 +572,33 @@ export class Stack extends Construct implements ITaggable { return this.nestedStackParent.addDockerImageAsset(asset); } - let params = this.assetParameters.node.tryFindChild(asset.sourceHash) as DockerImageAssetParameters; - if (!params) { - params = new DockerImageAssetParameters(this.assetParameters, asset.sourceHash); + // check if we have an override from context + const repositoryNameOverride = this.node.tryGetContext(ASSETS_ECR_REPOSITORY_NAME_OVERRIDE_CONTEXT_KEY); + const repositoryName = asset.repositoryName ?? repositoryNameOverride ?? ASSETS_ECR_REPOSITORY_NAME; + const imageTag = asset.sourceHash; + const assetId = asset.sourceHash; + // only add every image (identified by source hash) once for each stack that uses it. + if (!this.addedImageAssets.has(assetId)) { const metadata: cxapi.ContainerImageAssetMetadataEntry = { - id: asset.sourceHash, + repositoryName, + imageTag, + id: assetId, packaging: 'container-image', path: asset.directoryName, sourceHash: asset.sourceHash, - imageNameParameter: params.imageNameParameter.logicalId, - repositoryName: asset.repositoryName, buildArgs: asset.dockerBuildArgs, target: asset.dockerBuildTarget, file: asset.dockerFile, }; this.node.addMetadata(cxapi.ASSET_METADATA, metadata); + this.addedImageAssets.add(assetId); } - // Parse repository name and tag from the parameter (@sha256:) - // Example: cdk/cdkexampleimageb2d7f504@sha256:72c4f956379a43b5623d529ddd969f6826dde944d6221f445ff3e7add9875500 - const components = Fn.split('@sha256:', params.imageNameParameter.valueAsString); - const repositoryName = Fn.select(0, components).toString(); - const imageSha = Fn.select(1, components).toString(); - const imageUri = `${this.account}.dkr.ecr.${this.region}.${this.urlSuffix}/${repositoryName}@sha256:${imageSha}`; - return { - imageUri, repositoryName + imageUri: `${this.account}.dkr.ecr.${this.region}.${this.urlSuffix}/${repositoryName}:${imageTag}`, + repositoryName }; } diff --git a/packages/@aws-cdk/core/package.json b/packages/@aws-cdk/core/package.json index 026db296ebce5..40eda2285f200 100644 --- a/packages/@aws-cdk/core/package.json +++ b/packages/@aws-cdk/core/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/core", - "version": "1.19.0", + "version": "1.21.0", "description": "AWS Cloud Development Kit Core Library", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -149,22 +149,22 @@ "devDependencies": { "@types/lodash": "^4.14.149", "@types/nodeunit": "^0.0.30", - "cdk-build-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cfn2ts": "1.21.0", "fast-check": "^1.21.0", "lodash": "^4.17.15", "nodeunit": "^0.11.3", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/cx-api": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/cx-api": "1.19.0" + "@aws-cdk/cx-api": "1.21.0" }, "engines": { "node": ">= 10.3.0" }, "stability": "stable" -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/core/test/test.assets.ts b/packages/@aws-cdk/core/test/test.assets.ts index 4ad3d906147ec..f29f264a4837d 100644 --- a/packages/@aws-cdk/core/test/test.assets.ts +++ b/packages/@aws-cdk/core/test/test.assets.ts @@ -44,7 +44,7 @@ export = { }, - 'addDockerImageAsset correctly sets metadata and creates an ECR parameter'(test: Test) { + 'addDockerImageAsset correctly sets metadata'(test: Test) { // GIVEN const stack = new Stack(); @@ -62,16 +62,56 @@ export = { test.equal(assetMetadata && assetMetadata.data.path, 'directory-name'); test.equal(assetMetadata && assetMetadata.data.sourceHash, 'source-hash'); test.equal(assetMetadata && assetMetadata.data.repositoryName, 'repository-name'); + test.equal(assetMetadata && assetMetadata.data.imageTag, 'source-hash'); - test.deepEqual(toCloudFormation(stack), { - Parameters: { - AssetParameterssourcehashImageName3B572B12: { - Type: 'String', - Description: 'ECR repository name and tag for asset "source-hash"' - } - } + test.deepEqual(toCloudFormation(stack), { }); + test.done(); + }, + + 'addDockerImageAsset uses the default repository name'(test: Test) { + // GIVEN + const stack = new Stack(); + + // WHEN + stack.addDockerImageAsset({ + sourceHash: 'source-hash', + directoryName: 'directory-name', }); + // THEN + const assetMetadata = stack.node.metadata.find(({ type }) => type === cxapi.ASSET_METADATA); + + test.equal(assetMetadata && assetMetadata.data.packaging, 'container-image'); + test.equal(assetMetadata && assetMetadata.data.path, 'directory-name'); + test.equal(assetMetadata && assetMetadata.data.sourceHash, 'source-hash'); + test.equal(assetMetadata && assetMetadata.data.repositoryName, 'aws-cdk/assets'); + test.equal(assetMetadata && assetMetadata.data.imageTag, 'source-hash'); + + test.deepEqual(toCloudFormation(stack), { }); + test.done(); + }, + + 'addDockerImageAsset supports overriding repository name through a context key as a workaround until we have API for that'(test: Test) { + // GIVEN + const stack = new Stack(); + stack.node.setContext('assets-ecr-repository-name', 'my-custom-repo-name'); + + // WHEN + stack.addDockerImageAsset({ + sourceHash: 'source-hash', + directoryName: 'directory-name', + }); + + // THEN + const assetMetadata = stack.node.metadata.find(({ type }) => type === cxapi.ASSET_METADATA); + + test.equal(assetMetadata && assetMetadata.data.packaging, 'container-image'); + test.equal(assetMetadata && assetMetadata.data.path, 'directory-name'); + test.equal(assetMetadata && assetMetadata.data.sourceHash, 'source-hash'); + test.equal(assetMetadata && assetMetadata.data.repositoryName, 'my-custom-repo-name'); + test.equal(assetMetadata && assetMetadata.data.imageTag, 'source-hash'); + + test.deepEqual(toCloudFormation(stack), { }); test.done(); }, }; diff --git a/packages/@aws-cdk/core/test/test.fn.ts b/packages/@aws-cdk/core/test/test.fn.ts index 7a5b05e08524f..05b513a03dc95 100644 --- a/packages/@aws-cdk/core/test/test.fn.ts +++ b/packages/@aws-cdk/core/test/test.fn.ts @@ -176,7 +176,22 @@ export = nodeunit.testCase({ }); test.done(); } - } + }, + 'nested Fn::Join with list token'(test: nodeunit.Test) { + const stack = new Stack(); + const inner = Fn.join(',', Token.asList({ NotReallyList: true })); + const outer = Fn.join(',', [ inner, 'Foo' ]); + test.deepEqual(stack.resolve(outer), { + 'Fn::Join': [ + ',', + [ + { 'Fn::Join': [ ',', { NotReallyList: true } ] }, + 'Foo' + ] + ] + }); + test.done(); + }, }); function stringListToken(o: any): string[] { diff --git a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts index 47e7e03319485..7a6288d285e5a 100644 --- a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts +++ b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts @@ -115,7 +115,7 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent physicalResourceId = call.physicalResourceIdPath ? flatData[call.physicalResourceIdPath] - : call.physicalResourceId; + : call.physicalResourceId || (event as any).PhysicalResourceId; } await respond('SUCCESS', 'OK', physicalResourceId, data); diff --git a/packages/@aws-cdk/custom-resources/package.json b/packages/@aws-cdk/custom-resources/package.json index 36373158ac9a1..bf96e4b295009 100644 --- a/packages/@aws-cdk/custom-resources/package.json +++ b/packages/@aws-cdk/custom-resources/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/custom-resources", - "version": "1.19.0", + "version": "1.21.0", "description": "Constructs for implementing CDK custom resources", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -66,41 +66,41 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/assert": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", + "@aws-cdk/assert": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", "@types/aws-lambda": "^8.10.39", "@types/fs-extra": "^8.0.1", "@types/sinon": "^7.5.0", - "aws-sdk": "^2.597.0", + "aws-sdk": "^2.601.0", "aws-sdk-mock": "^5.0.0", - "cdk-build-tools": "1.19.0", - "cdk-integ-tools": "1.19.0", - "cfn2ts": "1.19.0", + "cdk-build-tools": "1.21.0", + "cdk-integ-tools": "1.21.0", + "cfn2ts": "1.21.0", "fs-extra": "^8.1.0", - "nock": "^11.7.1", - "pkglint": "1.19.0", - "sinon": "^8.0.2" + "nock": "^11.7.2", + "pkglint": "1.21.0", + "sinon": "^8.1.0" }, "dependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/aws-stepfunctions-tasks": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/aws-stepfunctions-tasks": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "homepage": "https://github.com/aws/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/aws-stepfunctions-tasks": "1.19.0", - "@aws-cdk/core": "1.19.0" + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/aws-stepfunctions-tasks": "1.21.0", + "@aws-cdk/core": "1.21.0" }, "jest": { "moduleFileExtensions": [ @@ -132,4 +132,4 @@ "props-default-doc:@aws-cdk/custom-resources.AwsSdkCall.parameters" ] } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts b/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts index 8a5b4da815271..e613eccc879bc 100644 --- a/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts +++ b/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts @@ -151,6 +151,41 @@ test('delete event', async () => { expect(request.isDone()).toBeTruthy(); }); +test('delete event with Delete call and no physical resource id in call', async () => { + const deleteParameterFake = sinon.fake.resolves({}); + + AWS.mock('SSM', 'deleteParameter', deleteParameterFake); + + const event: AWSLambda.CloudFormationCustomResourceDeleteEvent = { + ...eventCommon, + RequestType: 'Delete', + PhysicalResourceId: 'physicalResourceId', + ResourceProperties: { + ServiceToken: 'token', + Delete: { + service: 'SSM', + action: 'deleteParameter', + parameters: { + Name: 'my-param' + }, + } as AwsSdkCall + } + }; + + const request = createRequest(body => + body.Status === 'SUCCESS' && + body.PhysicalResourceId === 'physicalResourceId' + ); + + await handler(event, {} as AWSLambda.Context); + + sinon.assert.calledWith(deleteParameterFake, { + Name: 'my-param' + }); + + expect(request.isDone()).toBeTruthy(); +}); + test('catch errors', async () => { const error: NodeJS.ErrnoException = new Error(); error.code = 'NoSuchBucket'; diff --git a/packages/@aws-cdk/custom-resources/test/aws-custom-resource/integ.aws-custom-resource.expected.json b/packages/@aws-cdk/custom-resources/test/aws-custom-resource/integ.aws-custom-resource.expected.json index f22e625ffa0b6..880c33b630c11 100644 --- a/packages/@aws-cdk/custom-resources/test/aws-custom-resource/integ.aws-custom-resource.expected.json +++ b/packages/@aws-cdk/custom-resources/test/aws-custom-resource/integ.aws-custom-resource.expected.json @@ -109,7 +109,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2S3Bucket8CF060C1" + "Ref": "AssetParametersc6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999S3Bucket38F49C79" }, "S3Key": { "Fn::Join": [ @@ -122,7 +122,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2S3VersionKey2F6385AE" + "Ref": "AssetParametersc6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999S3VersionKey9906BC0C" } ] } @@ -135,7 +135,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2S3VersionKey2F6385AE" + "Ref": "AssetParametersc6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999S3VersionKey9906BC0C" } ] } @@ -230,17 +230,17 @@ } }, "Parameters": { - "AssetParameters1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2S3Bucket8CF060C1": { + "AssetParametersc6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999S3Bucket38F49C79": { "Type": "String", - "Description": "S3 bucket for asset \"1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2\"" + "Description": "S3 bucket for asset \"c6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999\"" }, - "AssetParameters1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2S3VersionKey2F6385AE": { + "AssetParametersc6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999S3VersionKey9906BC0C": { "Type": "String", - "Description": "S3 key for asset version \"1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2\"" + "Description": "S3 key for asset version \"c6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999\"" }, - "AssetParameters1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2ArtifactHash2B344D8E": { + "AssetParametersc6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999ArtifactHash5595423D": { "Type": "String", - "Description": "Artifact hash for asset \"1e957dd8cdd272089cd3aab5aa7cf195406aa84f4234b0cdab8553fe0268a3c2\"" + "Description": "Artifact hash for asset \"c6841f16fc6689f1b3a9ae6e91f18d4e6cc06c23c2b1e7b7155625c258cb8999\"" } }, "Outputs": { diff --git a/packages/@aws-cdk/cx-api/lib/assets.ts b/packages/@aws-cdk/cx-api/lib/assets.ts index b19730973daf7..9e99f95eed9c5 100644 --- a/packages/@aws-cdk/cx-api/lib/assets.ts +++ b/packages/@aws-cdk/cx-api/lib/assets.ts @@ -78,21 +78,36 @@ export interface ContainerImageAssetMetadataEntry extends BaseAssetMetadataEntry readonly packaging: 'container-image'; /** - * ECR Repository name and repo digest (separated by "@sha256:") where this image is stored. + * ECR Repository name and repo digest (separated by "@sha256:") where this + * image is stored. + * + * @default undefined If not specified, `repositoryName` and `imageTag` are + * required because otherwise how will the stack know where to find the asset, + * ha? + * @deprecated specify `repositoryName` and `imageTag` instead, and then you + * know where the image will go. */ - readonly imageNameParameter: string; + readonly imageNameParameter?: string; /** - * ECR repository name, if omitted a default name based on the asset's - * ID is used instead. Specify this property if you need to statically - * address the image, e.g. from a Kubernetes Pod. - * Note, this is only the repository name, without the registry and - * the tag parts. + * ECR repository name, if omitted a default name based on the asset's ID is + * used instead. Specify this property if you need to statically address the + * image, e.g. from a Kubernetes Pod. Note, this is only the repository name, + * without the registry and the tag parts. * - * @default automatically derived from the asset's ID. + * @default - this parameter is REQUIRED after 1.21.0 */ readonly repositoryName?: string; + /** + * The docker image tag to use for tagging pushed images. This field is + * required if `imageParameterName` is ommited (otherwise, the app won't be + * able to find the image). + * + * @default - this parameter is REQUIRED after 1.21.0 + */ + readonly imageTag?: string; + /** * Build args to pass to the `docker build` command * diff --git a/packages/@aws-cdk/cx-api/lib/versioning.ts b/packages/@aws-cdk/cx-api/lib/versioning.ts index e5ab25656305e..a35747216548d 100644 --- a/packages/@aws-cdk/cx-api/lib/versioning.ts +++ b/packages/@aws-cdk/cx-api/lib/versioning.ts @@ -31,7 +31,7 @@ import { AssemblyManifest } from './cloud-assembly'; * Note that the versions are not compared in a semver way, they are used as * opaque ordered tokens. */ -export const CLOUD_ASSEMBLY_VERSION = '1.16.0'; +export const CLOUD_ASSEMBLY_VERSION = '1.21.0'; /** * Look at the type of response we get and upgrade it to the latest expected version @@ -71,6 +71,13 @@ export function upgradeAssemblyManifest(manifest: AssemblyManifest): AssemblyMan manifest = justUpgradeVersion(manifest, '1.16.0'); } + if (manifest.version === '1.16.0') { + // Backwards compatible changes to ContainerImageAssetMetadataEntry: + // * Make `imageNameParameter` optional (new apps do not require it anymore because container images go to a well-known repository) + // * Add optional `imageTag` to allow apps to specify exactly where to store the image (required if `imageNameParameter` is not defined) + manifest = justUpgradeVersion(manifest, '1.21.0'); + } + return manifest; } diff --git a/packages/@aws-cdk/cx-api/package.json b/packages/@aws-cdk/cx-api/package.json index 6868c3450db60..0f2df80f2d0ba 100644 --- a/packages/@aws-cdk/cx-api/package.json +++ b/packages/@aws-cdk/cx-api/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/cx-api", - "version": "1.19.0", + "version": "1.21.0", "description": "Cloud executable protocol", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -66,11 +66,11 @@ }, "license": "Apache-2.0", "devDependencies": { - "@types/jest": "^24.0.25", + "@types/jest": "^24.9.0", "@types/semver": "^6.2.0", - "cdk-build-tools": "1.19.0", + "cdk-build-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "repository": { "url": "https://github.com/aws/aws-cdk.git", diff --git a/packages/@aws-cdk/cx-api/test/__snapshots__/cloud-assembly.test.js.snap b/packages/@aws-cdk/cx-api/test/__snapshots__/cloud-assembly.test.js.snap index 3ae076caa47ba..3889ac3a1825e 100644 --- a/packages/@aws-cdk/cx-api/test/__snapshots__/cloud-assembly.test.js.snap +++ b/packages/@aws-cdk/cx-api/test/__snapshots__/cloud-assembly.test.js.snap @@ -48,7 +48,7 @@ Array [ exports[`empty assembly 1`] = ` Object { - "version": "1.16.0", + "version": "1.21.0", } `; diff --git a/packages/@aws-cdk/region-info/package.json b/packages/@aws-cdk/region-info/package.json index 8f2e9dec6e488..ea7cbf04547ec 100644 --- a/packages/@aws-cdk/region-info/package.json +++ b/packages/@aws-cdk/region-info/package.json @@ -1,6 +1,6 @@ { "name": "@aws-cdk/region-info", - "version": "1.19.0", + "version": "1.21.0", "description": "AWS region information, such as service principal names", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -53,9 +53,9 @@ "license": "Apache-2.0", "devDependencies": { "@types/fs-extra": "^8.0.1", - "cdk-build-tools": "1.19.0", + "cdk-build-tools": "1.21.0", "fs-extra": "^8.1.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "jest": { "coverageReporters": [ diff --git a/packages/aws-cdk/bin/cdk.ts b/packages/aws-cdk/bin/cdk.ts index 6e4eacb20293e..92b7da1fc50ac 100644 --- a/packages/aws-cdk/bin/cdk.ts +++ b/packages/aws-cdk/bin/cdk.ts @@ -3,6 +3,7 @@ import 'source-map-support/register'; import * as cxapi from '@aws-cdk/cx-api'; import * as colors from 'colors/safe'; +import * as fs from 'fs-extra'; import * as path from 'path'; import * as yargs from 'yargs'; @@ -17,7 +18,7 @@ import { availableInitLanguages, cliInit, printAvailableTemplates } from '../lib import { data, debug, error, print, setVerbose, success } from '../lib/logging'; import { PluginHost } from '../lib/plugin'; import { serializeStructure } from '../lib/serialize'; -import { Configuration, Settings } from '../lib/settings'; +import { Configuration, PROJECT_CONFIG, Settings } from '../lib/settings'; import * as version from '../lib/version'; // tslint:disable:no-shadowed-variable max-line-length @@ -61,7 +62,7 @@ async function parseCommandLineArguments() { .option('build-exclude', { type: 'array', alias: 'E', nargs: 1, desc: 'Do not rebuild asset with the given ID. Can be specified multiple times.', default: [] }) .option('exclusively', { type: 'boolean', alias: 'e', desc: 'Only deploy requested stacks, don\'t include dependencies' }) .option('require-approval', { type: 'string', choices: [RequireApproval.Never, RequireApproval.AnyChange, RequireApproval.Broadening], desc: 'What security-sensitive changes need manual approval' }) - .option('ci', { type: 'boolean', desc: 'Force CI detection. Use --no-ci to disable CI autodetection.', default: process.env.CI !== undefined }) + .option('ci', { type: 'boolean', desc: 'Force CI detection (deprecated)', default: process.env.CI !== undefined }) .option('notification-arns', {type: 'array', desc: 'ARNs of SNS topics that CloudFormation will notify with stack related events', nargs: 1, requiresArg: true}) .option('tags', { type: 'array', alias: 't', desc: 'Tags to add to the stack (KEY=VALUE)', nargs: 1, requiresArg: true }) .option('execute', {type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true}) @@ -84,6 +85,7 @@ async function parseCommandLineArguments() { .commandDir('../lib/commands', { exclude: /^_.*/ }) .version(version.DISPLAY_VERSION) .demandCommand(1, '') // just print help + .recommendCommands() .help() .alias('h', 'help') .epilogue([ @@ -102,6 +104,16 @@ async function initCommandLine() { if (argv.verbose) { setVerbose(); } + + const projectRootDirectory = await lookupProjectRoot(); + + if (projectRootDirectory) { + // We change to the project root directory to maintian the behavior prior to (1.21.0) this feature, where + // cdk commands had to be executed from the project root. + // Note that if we cannot locate the project root, then we proceed anyway because the user might have the "app" configured in some other way. + process.chdir(projectRootDirectory); + } + debug('CDK toolkit version:', version.DISPLAY_VERSION); debug('Command line arguments:', argv); @@ -215,7 +227,6 @@ async function initCommandLine() { roleArn: args.roleArn, notificationArns: args.notificationArns, requireApproval: configuration.settings.get(['requireApproval']), - ci: args.ci, reuseAssets: args['build-exclude'], tags: configuration.settings.get(['tags']), sdk: aws, @@ -381,6 +392,31 @@ async function initCommandLine() { } } +async function lookupProjectRoot(): Promise { + + async function ascend(directory: string): Promise { + + const filePath = path.join(directory, PROJECT_CONFIG); + + if (await fs.pathExists(filePath)) { + return directory; + } + + const parentDir = path.dirname(directory); + + if (parentDir === directory) { + // We reached the file system root, give up. + return undefined; + } + + return ascend(parentDir); + + } + + return ascend(path.resolve(process.cwd())); + +} + initCommandLine() .then(value => { if (value == null) { return; } diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts index a25e1e51e9214..a9fcd8cff4763 100644 --- a/packages/aws-cdk/lib/api/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deploy-stack.ts @@ -34,7 +34,6 @@ export interface DeployStackOptions { notificationArns?: string[]; deployName?: string; quiet?: boolean; - ci?: boolean; reuseAssets?: string[]; tags?: Tag[]; @@ -53,7 +52,7 @@ export async function deployStack(options: DeployStackOptions): Promise { + public async prepareEcrRepository(repositoryName: string): Promise { const ecr = await this.props.sdk.ecr(this.props.environment.account, this.props.environment.region, Mode.ForWriting); - let repositoryName; - if (asset.repositoryName) { - // Repository name provided by user - repositoryName = asset.repositoryName; - } else { - // Repository name based on asset id - const assetId = asset.id; - repositoryName = 'cdk/' + assetId.replace(/[:/]/g, '-').toLowerCase(); - } - let repository; + // check if repo already exists try { - debug(`${repositoryName}: checking for repository.`); + debug(`${repositoryName}: checking if ECR repository already exists`); const describeResponse = await ecr.describeRepositories({ repositoryNames: [repositoryName] }).promise(); - repository = describeResponse.repositories![0]; + const existingRepositoryUri = describeResponse.repositories![0]?.repositoryUri; + if (existingRepositoryUri) { + return { repositoryUri: existingRepositoryUri }; + } } catch (e) { if (e.code !== 'RepositoryNotFoundException') { throw e; } } - if (repository) { - return { - repositoryUri: repository.repositoryUri!, - repositoryName - }; + // create the repo (tag it so it will be easier to garbage collect in the future) + debug(`${repositoryName}: creating ECR repository`); + const assetTag = { Key: 'awscdk:asset', Value: 'true' }; + const response = await ecr.createRepository({ repositoryName, tags: [ assetTag ] }).promise(); + const repositoryUri = response.repository?.repositoryUri; + if (!repositoryUri) { + throw new Error(`CreateRepository did not return a repository URI for ${repositoryUri}`); } - debug(`${repositoryName}: creating`); - const response = await ecr.createRepository({ repositoryName }).promise(); - repository = response.repository!; - - // Better put a lifecycle policy on this so as to not cost too much money - await ecr.putLifecyclePolicy({ - repositoryName, - lifecyclePolicyText: JSON.stringify(DEFAULT_REPO_LIFECYCLE) - }).promise(); - - // Configure image scanning on push (helps in identifying software vulnerabilities, no additional charge) - await ecr.putImageScanningConfiguration({ - repositoryName, - imageScanningConfiguration: { - scanOnPush: true - } - }).promise(); + // configure image scanning on push (helps in identifying software vulnerabilities, no additional charge) + debug(`${repositoryName}: enable image scanning`); + await ecr.putImageScanningConfiguration({ repositoryName, imageScanningConfiguration: { scanOnPush: true } }).promise(); - return { - repositoryUri: repository.repositoryUri!, - repositoryName - }; + return { repositoryUri }; } /** @@ -201,7 +180,6 @@ export class ToolkitInfo { /** @experimental */ export interface EcrRepositoryInfo { repositoryUri: string; - repositoryName: string; } /** @experimental */ @@ -251,18 +229,3 @@ function getOutputValue(stack: aws.CloudFormation.Stack, output: string): string } return result; } - -export const DEFAULT_REPO_LIFECYCLE = { - rules: [ - { - rulePriority: 100, - description: 'Retain only 5 images', - selection: { - tagStatus: 'any', - countType: 'imageCountMoreThan', - countNumber: 5, - }, - action: { type: 'expire' } - } - ] -}; diff --git a/packages/aws-cdk/lib/api/util/sdk.ts b/packages/aws-cdk/lib/api/util/sdk.ts index af1b776d01277..f9efd98c67b4d 100644 --- a/packages/aws-cdk/lib/api/util/sdk.ts +++ b/packages/aws-cdk/lib/api/util/sdk.ts @@ -195,9 +195,9 @@ export class SDK implements ISDK { return environment; } - private async configureSDKHttpOptions(options: SDKOptions) { + private configureSDKHttpOptions(options: SDKOptions) { const config: {[k: string]: any} = {}; - const httpOptions: {[k: string]: any} = {}; + config.httpOptions = {}; let userAgent = options.userAgent; if (userAgent == null) { @@ -207,19 +207,30 @@ export class SDK implements ISDK { } config.customUserAgent = userAgent; - // https://aws.amazon.com/blogs/developer/using-the-aws-sdk-for-javascript-from-behind-a-proxy/ - options.proxyAddress = options.proxyAddress || httpsProxyFromEnvironment(); - options.caBundlePath = options.caBundlePath || caBundlePathFromEnvironment(); + const proxyAddress = options.proxyAddress || httpsProxyFromEnvironment(); + const caBundlePath = options.caBundlePath || caBundlePathFromEnvironment(); - if (options.proxyAddress) { // Ignore empty string on purpose - debug('Using proxy server: %s', options.proxyAddress); - httpOptions.proxy = options.proxyAddress; + if (proxyAddress && caBundlePath) { + throw new Error(`At the moment, cannot specify Proxy (${proxyAddress}) and CA Bundle (${caBundlePath}) at the same time. See https://github.com/aws/aws-cdk/issues/5804`); + // Maybe it's possible after all, but I've been staring at + // https://github.com/TooTallNate/node-proxy-agent/blob/master/index.js#L79 + // a while now trying to figure out what to pass in so that the underlying Agent + // object will get the 'ca' argument. It's not trivial and I don't want to risk it. } - if (options.caBundlePath) { - debug('Using ca bundle path: %s', options.caBundlePath); - httpOptions.agent = new https.Agent({ca: await readIfPossible(options.caBundlePath)}); + + if (proxyAddress) { // Ignore empty string on purpose + // https://aws.amazon.com/blogs/developer/using-the-aws-sdk-for-javascript-from-behind-a-proxy/ + debug('Using proxy server: %s', proxyAddress); + // eslint-disable-next-line @typescript-eslint/no-require-imports + const ProxyAgent: any = require('proxy-agent'); + config.httpOptions.agent = new ProxyAgent(proxyAddress); + } + if (caBundlePath) { + debug('Using CA bundle path: %s', caBundlePath); + config.httpOptions.agent = new https.Agent({ + ca: readIfPossible(caBundlePath) + }); } - config.httpOptions = httpOptions; AWS.config.update(config); } @@ -512,7 +523,7 @@ async function hasEc2Credentials() { ['/sys/devices/virtual/dmi/id/sys_vendor', /ec2/i], ]; for (const [file, re] of files) { - if (matchesRegex(re, await readIfPossible(file))) { + if (matchesRegex(re, readIfPossible(file))) { instance = true; break; } @@ -532,10 +543,15 @@ async function setConfigVariable() { } } -async function readIfPossible(filename: string): Promise { +/** + * Read a file if it exists, or return undefined + * + * Not async because it is used in the constructor + */ +function readIfPossible(filename: string): string | undefined { try { - if (!await fs.pathExists(filename)) { return undefined; } - return fs.readFile(filename, { encoding: 'utf-8' }); + if (!fs.pathExistsSync(filename)) { return undefined; } + return fs.readFileSync(filename, { encoding: 'utf-8' }); } catch (e) { debug(e); return undefined; diff --git a/packages/aws-cdk/lib/assets.ts b/packages/aws-cdk/lib/assets.ts index 2d35c2acb99da..30cc111866460 100644 --- a/packages/aws-cdk/lib/assets.ts +++ b/packages/aws-cdk/lib/assets.ts @@ -11,7 +11,7 @@ import { prepareContainerAsset } from './docker'; import { debug, success } from './logging'; // tslint:disable-next-line:max-line-length -export async function prepareAssets(stack: cxapi.CloudFormationStackArtifact, toolkitInfo?: ToolkitInfo, ci?: boolean, reuse?: string[]): Promise { +export async function prepareAssets(stack: cxapi.CloudFormationStackArtifact, toolkitInfo?: ToolkitInfo, reuse?: string[]): Promise { reuse = reuse || []; const assets = stack.assets; @@ -41,21 +41,21 @@ export async function prepareAssets(stack: cxapi.CloudFormationStackArtifact, to } const assemblyDir = stack.assembly.directory; - params = params.concat(await prepareAsset(assemblyDir, asset, toolkitInfo, reuseAsset, ci)); + params = params.concat(await prepareAsset(assemblyDir, asset, toolkitInfo, reuseAsset)); } return params; } // tslint:disable-next-line:max-line-length -async function prepareAsset(assemblyDir: string, asset: cxapi.AssetMetadataEntry, toolkitInfo: ToolkitInfo, reuse: boolean, ci?: boolean): Promise { +async function prepareAsset(assemblyDir: string, asset: cxapi.AssetMetadataEntry, toolkitInfo: ToolkitInfo, reuse: boolean): Promise { switch (asset.packaging) { case 'zip': return await prepareZipAsset(assemblyDir, asset, toolkitInfo, reuse); case 'file': return await prepareFileAsset(assemblyDir, asset, toolkitInfo, reuse); case 'container-image': - return await prepareContainerAsset(assemblyDir, asset, toolkitInfo, reuse, ci); + return await prepareContainerAsset(assemblyDir, asset, toolkitInfo, reuse); default: // tslint:disable-next-line:max-line-length throw new Error(`Unsupported packaging type: ${(asset as any).packaging}. You might need to upgrade your aws-cdk toolkit to support this asset type.`); diff --git a/packages/aws-cdk/lib/cdk-toolkit.ts b/packages/aws-cdk/lib/cdk-toolkit.ts index 690a7e45ba82a..f9a3717b30071 100644 --- a/packages/aws-cdk/lib/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cdk-toolkit.ts @@ -138,7 +138,6 @@ export class CdkToolkit { stack, deployName: stack.stackName, roleArn: options.roleArn, - ci: options.ci, toolkitStackName: options.toolkitStackName, reuseAssets: options.reuseAssets, notificationArns: options.notificationArns, @@ -288,13 +287,6 @@ export interface DeployOptions { */ requireApproval?: RequireApproval; - /** - * Whether we're in CI mode - * - * @default false - */ - ci?: boolean; - /** * Reuse the assets with the given asset IDs */ diff --git a/packages/aws-cdk/lib/docker.ts b/packages/aws-cdk/lib/docker.ts index 5d229460642b3..d8efbd707f7fd 100644 --- a/packages/aws-cdk/lib/docker.ts +++ b/packages/aws-cdk/lib/docker.ts @@ -31,7 +31,14 @@ export async function prepareContainerAsset(assemblyDir: string, asset: ContainerImageAssetMetadataEntry, toolkitInfo: ToolkitInfo, reuse: boolean, - ci?: boolean): Promise<[CloudFormation.Parameter]> { + ci?: boolean): Promise { + + // following 1.21.0, image asset location (repositoryName and imageTag) is fully determined by the + // app, and therefore there is no need to wire the image name through a cloudformation parameter. + if (!asset.imageNameParameter) { + await prepareContainerAssetNew(assemblyDir, asset, toolkitInfo); + return [ ]; + } if (reuse) { return [ @@ -44,8 +51,10 @@ export async function prepareContainerAsset(assemblyDir: string, debug(' 👑 Preparing Docker image asset:', contextPath); try { - const ecr = await toolkitInfo.prepareEcrRepository(asset); - const latest = `${ecr.repositoryUri}:latest`; + const repositoryName = asset.repositoryName ?? 'cdk/' + asset.id.replace(/[:/]/g, '-').toLowerCase(); + const ecr = await toolkitInfo.prepareEcrRepository(repositoryName); + const imageTag = asset.imageTag ?? 'latest'; + const latest = `${ecr.repositoryUri}:${imageTag}`; let loggedIn = false; @@ -103,7 +112,7 @@ export async function prepareContainerAsset(assemblyDir: string, } return [ - { ParameterKey: asset.imageNameParameter, ParameterValue: repoDigest.replace(ecr.repositoryUri, ecr.repositoryName) }, + { ParameterKey: asset.imageNameParameter, ParameterValue: repoDigest.replace(ecr.repositoryUri, repositoryName) }, ]; } catch (e) { if (e.code === 'ENOENT') { @@ -114,6 +123,71 @@ export async function prepareContainerAsset(assemblyDir: string, } } +/** + * Build and upload a Docker image + */ +export async function prepareContainerAssetNew(assemblyDir: string, + asset: ContainerImageAssetMetadataEntry, + toolkitInfo: ToolkitInfo) { + + if (asset.imageNameParameter || !asset.repositoryName || !asset.imageTag) { + throw new Error(`invalid docker image asset configuration. "repositoryName" and "imageTag" are required and "imageNameParameter" is not allowed`); + } + + const contextPath = path.isAbsolute(asset.path) ? asset.path : path.join(assemblyDir, asset.path); + + debug(' 👑 Preparing Docker image asset:', contextPath); + const ecr = await toolkitInfo.prepareEcrRepository(asset.repositoryName); + + // if both repo name and image tag are explicitly defined, we assume the + // image is immutable and can skip build & push. + debug(`${asset.repositoryName}:${asset.imageTag}: checking if image already exists`); + if (await toolkitInfo.checkEcrImage(asset.repositoryName, asset.imageTag)) { + print(`${asset.repositoryName}:${asset.imageTag}: image already exists, skipping build and push`); + return; + } + + // we use "latest" for image tag for backwards compatibility with pre-1.21.0 apps. + const fullImageName = `${ecr.repositoryUri}:${asset.imageTag}`; + + // render "docker build" command + + const buildCommand = [ 'docker', 'build' ]; + + buildCommand.push('--tag', fullImageName); + + if (asset.target) { + buildCommand.push('--target', asset.target); + } + + if (asset.file) { + buildCommand.push('--file', asset.file); + } + + for (const [ key, value ] of Object.entries(asset.buildArgs || {})) { + buildCommand.push(`--build-arg`, `${key}=${value}`); + } + + buildCommand.push(contextPath); + + try { + await shell(buildCommand); + } catch (e) { + if (e.code === 'ENOENT') { + throw new Error('Unable to execute "docker" in order to build a container asset. Please install "docker" and try again.'); + } + throw e; + } + + // login to ECR + await dockerLogin(toolkitInfo); + + // There's no way to make this quiet, so we can't use a PleaseHold. Print a header message. + print(` ⌛ Pushing Docker image for ${contextPath}; this may take a while.`); + await shell(['docker', 'push', fullImageName]); + debug(` 👑 Docker image for ${contextPath} pushed.`); +} + /** * Get credentials from ECR and run docker login */ @@ -123,4 +197,4 @@ async function dockerLogin(toolkitInfo: ToolkitInfo) { '--username', credentials.username, '--password', credentials.password, credentials.endpoint]); -} +} \ No newline at end of file diff --git a/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.fs b/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.fs index f78b30d675d0f..1582e37f4faaf 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.fs +++ b/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/%name.PascalCased%Stack.template.fs @@ -1,4 +1,4 @@ -namespace HelloCdk +namespace %name.PascalCased% open Amazon.CDK open Amazon.CDK.AWS.SNS diff --git a/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/Program.template.fs b/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/Program.template.fs index 77234df375089..dc618af3fbbf1 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/Program.template.fs +++ b/packages/aws-cdk/lib/init-templates/sample-app/fsharp/src/%name.PascalCased%/Program.template.fs @@ -1,9 +1,11 @@ open Amazon.CDK -open %name.PascalCased%Stack +open %name.PascalCased% [] let main _ = let app = App(null) - %name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps) |> ignore + + %name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps()) |> ignore + app.Synth() |> ignore 0 diff --git a/packages/aws-cdk/lib/init-templates/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java b/packages/aws-cdk/lib/init-templates/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java index d9f09a46d7fef..aaca734f06d68 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java +++ b/packages/aws-cdk/lib/init-templates/sample-app/java/src/test/java/com/myorg/%name.PascalCased%StackTest.template.java @@ -19,6 +19,6 @@ public void testStack() throws IOException { %name.PascalCased%Stack stack = new %name.PascalCased%Stack(app, "test"); JsonNode actual = JSON.valueToTree(app.synth().getStackArtifact(stack.getArtifactId()).getTemplate()); - assertThat(actual.asText(), CoreMatchers.both(CoreMatchers.containsString("AWS::SQS::Queue")).and(CoreMatchers.containsString("AWS::SNS::Topic"))); + assertThat(actual.toString(), CoreMatchers.both(CoreMatchers.containsString("AWS::SQS::Queue")).and(CoreMatchers.containsString("AWS::SNS::Topic"))); } } diff --git a/packages/aws-cdk/lib/init-templates/sample-app/python/%name%/%name%_stack.template.py b/packages/aws-cdk/lib/init-templates/sample-app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py similarity index 100% rename from packages/aws-cdk/lib/init-templates/sample-app/python/%name%/%name%_stack.template.py rename to packages/aws-cdk/lib/init-templates/sample-app/python/%name.PythonModule%/%name.PythonModule%_stack.template.py diff --git a/packages/aws-cdk/lib/init-templates/sample-app/python/%name%/__init__.py b/packages/aws-cdk/lib/init-templates/sample-app/python/%name.PythonModule%/__init__.py similarity index 100% rename from packages/aws-cdk/lib/init-templates/sample-app/python/%name%/__init__.py rename to packages/aws-cdk/lib/init-templates/sample-app/python/%name.PythonModule%/__init__.py diff --git a/packages/aws-cdk/lib/init-templates/sample-app/python/README.template.md b/packages/aws-cdk/lib/init-templates/sample-app/python/README.template.md index 2716cd118afc4..b8084d113f854 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/python/README.template.md +++ b/packages/aws-cdk/lib/init-templates/sample-app/python/README.template.md @@ -1,13 +1,13 @@ # Welcome to your CDK Python project! -You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`%name.PascalCased%Stack`) +You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`%name.PythonModule%_stack`) which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic. The `cdk.json` file tells the CDK Toolkit how to execute your app. This project is set up like a standard Python project. The initialization process also creates -a virtualenv within this project, stored under the .env directory. To create the virtualenv +a virtualenv within this project, stored under the .env directory. To create the virtualenv it assumes that there is a `python3` executable in your path with access to the `venv` package. If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv manually once the init process completes. diff --git a/packages/aws-cdk/lib/init-templates/sample-app/python/app.template.py b/packages/aws-cdk/lib/init-templates/sample-app/python/app.template.py index 40c3c3526af30..580bbee9e069c 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/python/app.template.py +++ b/packages/aws-cdk/lib/init-templates/sample-app/python/app.template.py @@ -2,10 +2,10 @@ from aws_cdk import core -from %name%.%name%_stack import %name.PascalCased%Stack +from %name.PythonModule%.%name.PythonModule%_stack import %name.PascalCased%Stack app = core.App() -%name.PascalCased%Stack(app, "%name%", env={'region': 'us-west-2'}) +%name.PascalCased%Stack(app, "%name.StackName%", env={'region': 'us-west-2'}) app.synth() diff --git a/packages/aws-cdk/lib/init-templates/sample-app/python/setup.template.py b/packages/aws-cdk/lib/init-templates/sample-app/python/setup.template.py index 09829f28d4151..f7d9afb7473bc 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/python/setup.template.py +++ b/packages/aws-cdk/lib/init-templates/sample-app/python/setup.template.py @@ -6,7 +6,7 @@ setuptools.setup( - name="%name%", + name="%name.PythonModule%", version="0.0.1", description="A sample CDK Python app", @@ -15,8 +15,8 @@ author="author", - package_dir={"": "%name%"}, - packages=setuptools.find_packages(where="%name%"), + package_dir={"": "%name.PythonModule%"}, + packages=setuptools.find_packages(where="%name.PythonModule%"), install_requires=[ "aws-cdk.core", diff --git a/packages/aws-cdk/lib/init-templates/sample-app/python/tests/unit/test_%name%_stack.template.py b/packages/aws-cdk/lib/init-templates/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py similarity index 56% rename from packages/aws-cdk/lib/init-templates/sample-app/python/tests/unit/test_%name%_stack.template.py rename to packages/aws-cdk/lib/init-templates/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py index 5c441bd3ae13d..fab17d075ac44 100644 --- a/packages/aws-cdk/lib/init-templates/sample-app/python/tests/unit/test_%name%_stack.template.py +++ b/packages/aws-cdk/lib/init-templates/sample-app/python/tests/unit/test_%name.PythonModule%_stack.template.py @@ -2,13 +2,13 @@ import pytest from aws_cdk import core -from %name%.%name%_stack import %name.PascalCased%Stack +from %name%.%name.PythonModule%_stack import %name.PascalCased%Stack def get_template(): app = core.App() - %name.PascalCased%Stack(app, "%name%") - return json.dumps(app.synth().get_stack("%name%").template) + %name.PascalCased%Stack(app, "%name.StackName%") + return json.dumps(app.synth().get_stack("%name.StackName%").template) def test_sqs_queue_created(): diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index b1dfee603ab82..64f8e8b2f46fb 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -1,7 +1,7 @@ { "name": "aws-cdk", "description": "CDK Toolkit, the command line tool for CDK apps", - "version": "1.19.0", + "version": "1.21.0", "main": "lib/index.js", "types": "lib/index.d.ts", "bin": { @@ -42,8 +42,8 @@ "@types/archiver": "^3.0.0", "@types/fs-extra": "^8.0.1", "@types/glob": "^7.1.1", - "@types/jest": "^24.0.25", - "@types/jszip": "^3.1.6", + "@types/jest": "^24.9.0", + "@types/jszip": "^3.1.7", "@types/minimatch": "^3.0.3", "@types/mockery": "^1.4.29", "@types/node": "^10.17.13", @@ -54,22 +54,22 @@ "@types/table": "^4.0.7", "@types/uuid": "^3.4.6", "@types/yaml": "^1.2.0", - "@types/yargs": "^13.0.4", + "@types/yargs": "^15.0.0", "aws-sdk-mock": "^5.0.0", - "cdk-build-tools": "1.19.0", + "cdk-build-tools": "1.21.0", "jest": "^24.9.0", "jszip": "^3.2.2", "mockery": "^2.1.0", - "pkglint": "1.19.0", - "sinon": "^8.0.2", - "ts-jest": "^24.2.0" + "pkglint": "1.21.0", + "sinon": "^8.1.0", + "ts-jest": "^24.3.0" }, "dependencies": { - "@aws-cdk/cloudformation-diff": "1.19.0", - "@aws-cdk/cx-api": "1.19.0", - "@aws-cdk/region-info": "1.19.0", + "@aws-cdk/cloudformation-diff": "1.21.0", + "@aws-cdk/cx-api": "1.21.0", + "@aws-cdk/region-info": "1.21.0", "archiver": "^3.1.1", - "aws-sdk": "^2.596.0", + "aws-sdk": "^2.601.0", "camelcase": "^5.3.1", "colors": "^1.4.0", "decamelize": "^3.2.0", @@ -78,6 +78,7 @@ "json-diff": "^0.5.4", "minimatch": ">=3.0", "promptly": "^3.0.3", + "proxy-agent": "^3.1.1", "request": "^2.88.0", "semver": "^7.1.1", "source-map-support": "^0.5.16", diff --git a/packages/aws-cdk/test/assets.test.ts b/packages/aws-cdk/test/assets.test.ts index 563811e135524..f1fb2a4974ebb 100644 --- a/packages/aws-cdk/test/assets.test.ts +++ b/packages/aws-cdk/test/assets.test.ts @@ -67,7 +67,7 @@ test('prepare assets with reuse', async () => { const toolkit = new FakeToolkit(); // WHEN - const params = await prepareAssets(stack, toolkit as any, undefined, ['SomeStackSomeResource4567']); + const params = await prepareAssets(stack, toolkit as any, ['SomeStackSomeResource4567']); // THEN expect(params).toEqual([ @@ -101,7 +101,7 @@ test('prepare container asset with reuse', async () => { const toolkit = new FakeToolkit(); // WHEN - const params = await prepareAssets(stack, toolkit as any, undefined, ['SomeStackSomeResource4567']); + const params = await prepareAssets(stack, toolkit as any, ['SomeStackSomeResource4567']); // THEN expect(params).toEqual([ diff --git a/packages/aws-cdk/test/docker-new.test.ts b/packages/aws-cdk/test/docker-new.test.ts new file mode 100644 index 0000000000000..b8469e512c71c --- /dev/null +++ b/packages/aws-cdk/test/docker-new.test.ts @@ -0,0 +1,304 @@ +import * as cxapi from '@aws-cdk/cx-api'; +import * as sinon from 'sinon'; +import { ToolkitInfo } from '../lib'; +import { prepareContainerAsset } from '../lib/docker'; +import * as os from '../lib/os'; +import { MockSDK } from './util/mock-sdk'; + +test('fails if "repositoryName" and "imageTag" are not specified', async () => { + // GIVEN + const toolkit = newMockToolkitInfo(); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: '/foo', + sourceHash: '0123456789abcdef', + }; + + // THEN + await expect(prepareContainerAsset('.', asset, toolkit, false)) + .rejects.toEqual(new Error(`invalid docker image asset configuration\. "repositoryName" and "imageTag" are required and "imageNameParameter" is not allowed`)); +}); + +test('fails if "repositoryName" is not specified', async () => { + // GIVEN + const toolkit = newMockToolkitInfo(); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + repositoryName: 'repository-name', + packaging: 'container-image', + path: '/foo', + sourceHash: '0123456789abcdef', + }; + + // THEN + await expect(prepareContainerAsset('.', asset, toolkit, false)) + .rejects.toEqual(new Error(`invalid docker image asset configuration\. "repositoryName" and "imageTag" are required and "imageNameParameter" is not allowed`)); +}); + +test('creates repository with given name', async () => { + // GIVEN + const sdk = new MockSDK(); + const toolkit = newMockToolkitInfo(sdk); + let createdName; + + sdk.stubEcr({ + describeRepositories: () => ({ repositories: [] }), + createRepository: req => { + createdName = req.repositoryName; + + // Stop the test so that we don't actually docker build + throw new Error('STOPTEST'); + }, + }); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: '/foo', + repositoryName: 'some-name', + imageTag: 'image-tag', + sourceHash: '0123456789abcdef', + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + // THEN + expect(createdName).toBe('some-name'); +}); + +test('configures image scanning', async () => { + // GIVEN + let putImageScanningConfigurationParams; + + const sdk = new MockSDK(); + sdk.stubEcr({ + describeRepositories: () => ({ repositories: [] }), + createRepository: () => ({ repository: { repositoryUri: 'uri' } }), + putImageScanningConfiguration: params => { + putImageScanningConfigurationParams = params; + + // Stop the test so that we don't actually docker build + throw new Error('STOPTEST'); + } + }); + + const toolkit = newMockToolkitInfo(sdk); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: '/foo', + repositoryName: 'some-name', + imageTag: 'some-tag', + sourceHash: '0123456789abcdef', + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + expect(putImageScanningConfigurationParams).toEqual({ + repositoryName: 'some-name', + imageScanningConfiguration: { + scanOnPush: true + } + }); +}); + +test('passes the correct target to docker build', async () => { + // GIVEN + const toolkit = newMockToolkitInfo(); + + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri' }); + const checkEcrImageStub = sinon.stub(toolkit, 'checkEcrImage').resolves(false); + const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: '/foo', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + imageTag: 'some-tag', + buildArgs: { + a: 'b', + c: 'd' + }, + target: 'a-target', + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + // THEN + const command = [ 'docker', 'build', '--tag', `uri:some-tag`, '--target', 'a-target', '--build-arg', 'a=b', '--build-arg', 'c=d', '/foo' ]; + sinon.assert.calledWith(shellStub, command); + + prepareEcrRepositoryStub.restore(); + shellStub.restore(); + checkEcrImageStub.restore(); +}); + +test('passes the correct args to docker build', async () => { + // GIVEN + const toolkit = newMockToolkitInfo(); + + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri' }); + const checkEcrImageStub = sinon.stub(toolkit, 'checkEcrImage').resolves(false); + const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: '/foo', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + imageTag: 'some-tag', + buildArgs: { + a: 'b', + c: 'd' + } + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + // THEN + const command = ['docker', 'build', '--tag', `uri:some-tag`, '--build-arg', 'a=b', '--build-arg', 'c=d', '/foo']; + sinon.assert.calledWith(shellStub, command); + + prepareEcrRepositoryStub.restore(); + checkEcrImageStub.restore(); + shellStub.restore(); +}); + +test('passes the correct docker file name if specified', async () => { + const toolkit = newMockToolkitInfo(); + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri' }); + const checkEcrImageStub = sinon.stub(toolkit, 'checkEcrImage').resolves(false); + const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: '/foo', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + imageTag: 'some-tag', + file: 'CustomDockerfile', + buildArgs: { + a: 'b', + c: 'd' + } + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + // THEN + const command = ['docker', 'build', '--tag', `uri:some-tag`, '--file', 'CustomDockerfile', '--build-arg', 'a=b', '--build-arg', 'c=d', '/foo']; + sinon.assert.calledWith(shellStub, command); + + prepareEcrRepositoryStub.restore(); + checkEcrImageStub.restore(); + shellStub.restore(); +}); + +test('relative path', async () => { + // GIVEN + const toolkit = newMockToolkitInfo(); + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri' }); + const checkEcrImageStub = sinon.stub(toolkit, 'checkEcrImage').resolves(false); + const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: 'relative-to-assembly', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + imageTag: 'some-tag', + buildArgs: { + a: 'b', + c: 'd' + } + }; + + try { + await prepareContainerAsset('/assembly/dir/root', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + // THEN + const command = ['docker', 'build', '--tag', `uri:some-tag`, '--build-arg', 'a=b', '--build-arg', 'c=d', '/assembly/dir/root/relative-to-assembly']; + sinon.assert.calledWith(shellStub, command); + + prepareEcrRepositoryStub.restore(); + checkEcrImageStub.restore(); + shellStub.restore(); +}); + +test('skips build & push if image already exists in the ECR repo', async () => { + // GIVEN + const toolkit = newMockToolkitInfo(); + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository'); + const shellStub = sinon.stub(os, 'shell'); + const checkEcrImageStub = sinon.stub(toolkit, 'checkEcrImage').resolves(true); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + packaging: 'container-image', + path: 'relative-to-assembly', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + imageTag: 'some-tag', + buildArgs: { + a: 'b', + c: 'd' + } + }; + + await prepareContainerAsset('/assembly/dir/root', asset, toolkit, false); + + // THEN + sinon.assert.calledOnce(prepareEcrRepositoryStub); + sinon.assert.calledOnce(checkEcrImageStub); + sinon.assert.notCalled(shellStub); +}); + +function newMockToolkitInfo(sdk: MockSDK = new MockSDK()) { + return new ToolkitInfo({ + sdk, + bucketName: 'BUCKET_NAME', + bucketEndpoint: 'BUCKET_ENDPOINT', + environment: { name: 'env', account: '1234', region: 'abc' } + }); +} \ No newline at end of file diff --git a/packages/aws-cdk/test/docker.test.ts b/packages/aws-cdk/test/docker.test.ts index 0d903b62d80d7..be13712c49aff 100644 --- a/packages/aws-cdk/test/docker.test.ts +++ b/packages/aws-cdk/test/docker.test.ts @@ -1,6 +1,6 @@ import * as cxapi from '@aws-cdk/cx-api'; import * as sinon from 'sinon'; -import { DEFAULT_REPO_LIFECYCLE, ToolkitInfo } from '../lib'; +import { ToolkitInfo } from '../lib'; import { prepareContainerAsset } from '../lib/docker'; import * as os from '../lib/os'; import { MockSDK } from './util/mock-sdk'; @@ -96,9 +96,8 @@ test('derives repository name from asset id', async () => { expect(createdName).toBe('cdk/stack-construct-abc123'); }); -test('configures lifecycle policy and image scanning', async () => { +test('configures image scanning', async () => { // GIVEN - let putLifecyclePolicyParams; let putImageScanningConfigurationParams; const sdk = new MockSDK(); @@ -115,11 +114,6 @@ test('configures lifecycle policy and image scanning', async () => { }; }, - putLifecyclePolicy(params) { - putLifecyclePolicyParams = params; - return {}; - }, - putImageScanningConfiguration(params) { putImageScanningConfigurationParams = params; @@ -151,12 +145,6 @@ test('configures lifecycle policy and image scanning', async () => { if (!/STOPTEST/.test(e.toString())) { throw e; } } - // THEN - expect(putLifecyclePolicyParams).toEqual({ - repositoryName: 'some-name', - lifecyclePolicyText: JSON.stringify(DEFAULT_REPO_LIFECYCLE) - }); - expect(putImageScanningConfigurationParams).toEqual({ repositoryName: 'some-name', imageScanningConfiguration: { @@ -176,7 +164,6 @@ test('passes the correct target to docker build', async () => { const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri', - repositoryName: 'name' }); const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); @@ -197,7 +184,7 @@ test('passes the correct target to docker build', async () => { }; try { - await prepareContainerAsset('.', asset, toolkit, false, false); + await prepareContainerAsset('.', asset, toolkit, false); } catch (e) { if (!/STOPTEST/.test(e.toString())) { throw e; } } @@ -221,7 +208,6 @@ test('passes the correct args to docker build', async () => { const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri', - repositoryName: 'name' }); const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); @@ -265,7 +251,6 @@ test('relative path', async () => { const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ repositoryUri: 'uri', - repositoryName: 'name' }); const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); @@ -297,3 +282,97 @@ test('relative path', async () => { prepareEcrRepositoryStub.restore(); shellStub.restore(); }); + +test('passes the correct file to docker build', async () => { + // GIVEN + const toolkit = new ToolkitInfo({ + sdk: new MockSDK(), + bucketName: 'BUCKET_NAME', + bucketEndpoint: 'BUCKET_ENDPOINT', + environment: { name: 'env', account: '1234', region: 'abc' } + }); + + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ + repositoryUri: 'uri', + }); + + const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + imageNameParameter: 'MyParameter', + packaging: 'container-image', + path: '/foo', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + buildArgs: { + a: 'b', + c: 'd' + }, + target: 'a-target', + file: 'some-file' + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + const command = ['docker', 'build', '--build-arg', 'a=b', '--build-arg', 'c=d', '--tag', 'uri:latest', '/foo', '--target', 'a-target', '--file', 'some-file']; + sinon.assert.calledWith(shellStub, command); + + prepareEcrRepositoryStub.restore(); + shellStub.restore(); +}); + +// since "imageNameParameter" is present, this means we are pre 1.21.0, which +// implies which is before "imageTag" was supported. still, for the sake of +// correctness of the protocol we added support for specifying image tag even if +// it's probably not going to be used. +test('"imageTag" is used instead of "latest"', async () => { + // GIVEN + const toolkit = new ToolkitInfo({ + sdk: new MockSDK(), + bucketName: 'BUCKET_NAME', + bucketEndpoint: 'BUCKET_ENDPOINT', + environment: { name: 'env', account: '1234', region: 'abc' } + }); + + const prepareEcrRepositoryStub = sinon.stub(toolkit, 'prepareEcrRepository').resolves({ + repositoryUri: 'uri', + }); + + const shellStub = sinon.stub(os, 'shell').rejects('STOPTEST'); + + // WHEN + const asset: cxapi.ContainerImageAssetMetadataEntry = { + id: 'assetId', + imageNameParameter: 'MyParameter', + packaging: 'container-image', + path: '/foo', + sourceHash: '1234567890abcdef', + repositoryName: 'some-name', + imageTag: 'image-tag', + buildArgs: { + a: 'b', + c: 'd' + }, + target: 'a-target', + file: 'some-file' + }; + + try { + await prepareContainerAsset('.', asset, toolkit, false); + } catch (e) { + if (!/STOPTEST/.test(e.toString())) { throw e; } + } + + // THEN + const command = ['docker', 'build', '--build-arg', 'a=b', '--build-arg', 'c=d', '--tag', 'uri:image-tag', '/foo', '--target', 'a-target', '--file', 'some-file']; + sinon.assert.calledWith(shellStub, command); + + prepareEcrRepositoryStub.restore(); + shellStub.restore(); +}); diff --git a/packages/aws-cdk/test/integ/cli/app/app.js b/packages/aws-cdk/test/integ/cli/app/app.js index 62b18880c5fb3..7a0dfab184f5d 100644 --- a/packages/aws-cdk/test/integ/cli/app/app.js +++ b/packages/aws-cdk/test/integ/cli/app/app.js @@ -84,7 +84,7 @@ class LambdaStack extends cdk.Stack { const fn = new lambda.Function(this, 'my-function', { code: lambda.Code.asset(path.join(__dirname, 'lambda')), - runtime: lambda.Runtime.NODEJS_8_10, + runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler' }); diff --git a/packages/aws-cdk/test/integ/cli/test-cdk-from-inner-directory.sh b/packages/aws-cdk/test/integ/cli/test-cdk-from-inner-directory.sh new file mode 100755 index 0000000000000..2d9305d19e24e --- /dev/null +++ b/packages/aws-cdk/test/integ/cli/test-cdk-from-inner-directory.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail +scriptdir=$(cd $(dirname $0) && pwd) +source ${scriptdir}/common.bash +# ---------------------------------------------------------- + +setup + +pushd docker +cdk diff ${STACK_NAME_PREFIX}-test-1 + +echo "✅ success" diff --git a/packages/aws-cdk/test/integ/cli/test-cdk-from-outer-directory.sh b/packages/aws-cdk/test/integ/cli/test-cdk-from-outer-directory.sh new file mode 100755 index 0000000000000..cc9bbe934ad22 --- /dev/null +++ b/packages/aws-cdk/test/integ/cli/test-cdk-from-outer-directory.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -euo pipefail +scriptdir=$(cd $(dirname $0) && pwd) +source ${scriptdir}/common.bash +# ---------------------------------------------------------- + +setup + +temp_dir=$(mktemp -d) + +function cleanup() { + rm -rf ${temp_dir} +} + +trap cleanup EXIT INT + +pushd ${temp_dir} +set +e +output="$(cdk diff ${STACK_NAME_PREFIX}-test-1 2>&1)" +set -e + +if [[ "${output}" != *"--app is required"* ]]; then + fail "unexpected output when running 'cdk diff' from outer directory: ${output}" +fi + +echo "✅ success" diff --git a/packages/aws-cdk/test/integ/init/common.bash b/packages/aws-cdk/test/integ/init/common.bash index 1298b2b3f71fa..f41f02b5215e8 100644 --- a/packages/aws-cdk/test/integ/init/common.bash +++ b/packages/aws-cdk/test/integ/init/common.bash @@ -1,5 +1,5 @@ set -eu -init_test_dir=/tmp/cdk-init-test +init_test_dir="${init_test_dir:=/tmp/cdk-init-test}" function setup() { rm -rf $init_test_dir diff --git a/packages/aws-cdk/test/integ/init/test-csharp.sh b/packages/aws-cdk/test/integ/init/test-csharp.sh index 65b479812f77d..ea82e3b63f38c 100755 --- a/packages/aws-cdk/test/integ/init/test-csharp.sh +++ b/packages/aws-cdk/test/integ/init/test-csharp.sh @@ -21,6 +21,6 @@ for template in $templates; do setup - cdk init -l csharp -t $template + cdk init -l csharp $template cdk synth done diff --git a/packages/aws-cdk/test/integ/init/test-fsharp.sh b/packages/aws-cdk/test/integ/init/test-fsharp.sh index 146384fff0d25..f8ad463703672 100755 --- a/packages/aws-cdk/test/integ/init/test-fsharp.sh +++ b/packages/aws-cdk/test/integ/init/test-fsharp.sh @@ -21,6 +21,6 @@ for template in $templates; do setup - cdk init -l fsharp -t $template + cdk init -l fsharp $template cdk synth done diff --git a/packages/aws-cdk/test/integ/init/test-java.sh b/packages/aws-cdk/test/integ/init/test-java.sh index 81cf7deccf4ea..f27441809da3c 100755 --- a/packages/aws-cdk/test/integ/init/test-java.sh +++ b/packages/aws-cdk/test/integ/init/test-java.sh @@ -21,6 +21,6 @@ for template in $templates; do setup - cdk init -l java -t $template + cdk init -l java $template cdk synth done diff --git a/packages/aws-cdk/test/integ/init/test-javascript.sh b/packages/aws-cdk/test/integ/init/test-javascript.sh index d386eaafbad29..c161d35a5edd1 100755 --- a/packages/aws-cdk/test/integ/init/test-javascript.sh +++ b/packages/aws-cdk/test/integ/init/test-javascript.sh @@ -21,6 +21,6 @@ for template in $templates; do setup - cdk init -l javascript -t $template + cdk init -l javascript $template cdk synth done diff --git a/packages/aws-cdk/test/integ/init/test-python-stackname.sh b/packages/aws-cdk/test/integ/init/test-python-stackname.sh new file mode 100755 index 0000000000000..415c9bdb25cf2 --- /dev/null +++ b/packages/aws-cdk/test/integ/init/test-python-stackname.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Naming shim for backwards compatibility with legacy +# tests and canaries. +set -eu +scriptdir=$(cd $(dirname $0) && pwd) +init_test_dir=/tmp/cdkInitTest +source $scriptdir/test-python.sh diff --git a/packages/aws-cdk/test/integ/init/test-python.sh b/packages/aws-cdk/test/integ/init/test-python.sh index 0c6304f5c1c5f..33034466f05d0 100755 --- a/packages/aws-cdk/test/integ/init/test-python.sh +++ b/packages/aws-cdk/test/integ/init/test-python.sh @@ -21,7 +21,7 @@ for template in $templates; do setup - cdk init -l python -t $template + cdk init -l python $template source .env/bin/activate type -p pip diff --git a/packages/aws-cdk/test/integ/init/test-typescript.sh b/packages/aws-cdk/test/integ/init/test-typescript.sh index 0943ae90caa04..67a6cb2920729 100755 --- a/packages/aws-cdk/test/integ/init/test-typescript.sh +++ b/packages/aws-cdk/test/integ/init/test-typescript.sh @@ -21,9 +21,13 @@ for template in $templates; do setup - cdk init -l typescript -t $template + cdk init -l typescript $template npm ls # this will fail if we have unmet peer dependencies npm run build npm run test - cdk synth + + # Can't run `cdk synth` on libraries + if [[ $template != "lib" ]]; then + cdk synth + fi done diff --git a/packages/aws-cdk/test/integ/run-against-dist.bash b/packages/aws-cdk/test/integ/run-against-dist.bash index 3a247ab58ea69..10f70d965f37a 100644 --- a/packages/aws-cdk/test/integ/run-against-dist.bash +++ b/packages/aws-cdk/test/integ/run-against-dist.bash @@ -149,6 +149,14 @@ function prepare_java_packages() { exit 1 fi + # Rename all maven-metadata.xml* files to maven-metadata-local.xml* + # This is necessary for Maven to find them correctly after we've rsync'ed + # them into place: + # https://github.com/sonatype/sonatype-aether/blob/master/aether-impl/src/main/java/org/sonatype/aether/impl/internal/SimpleLocalRepositoryManager.java#L114 + for f in $(find $dist_root/java -name maven-metadata.xml\*); do + mv "$f" "$(echo "$f" | sed s/metadata\.xml/metadata-local.xml/)" + done + export MAVEN_CONFIG=${MAVEN_CONFIG:-$HOME/.m2} rsync -a $dist_root/java/ ${MAVEN_CONFIG}/repository } diff --git a/packages/cdk-dasm/package.json b/packages/cdk-dasm/package.json index e8817edc37594..991c830e0ac56 100644 --- a/packages/cdk-dasm/package.json +++ b/packages/cdk-dasm/package.json @@ -1,6 +1,6 @@ { "name": "cdk-dasm", - "version": "1.19.0", + "version": "1.21.0", "description": "AWS CDK disassembler: convert CloudFormation to code", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,7 +30,7 @@ "yaml": "1.7.2" }, "devDependencies": { - "@types/jest": "^24.0.25", + "@types/jest": "^24.9.0", "@types/yaml": "1.2.0", "jest": "^24.9.0" }, diff --git a/packages/cdk/package.json b/packages/cdk/package.json index f999060427460..551e5d877101d 100644 --- a/packages/cdk/package.json +++ b/packages/cdk/package.json @@ -1,12 +1,12 @@ { "name": "cdk", - "version": "1.19.0", + "version": "1.21.0", "description": "AWS CDK Toolkit", "bin": { "cdk": "bin/cdk" }, "dependencies": { - "aws-cdk": "1.19.0" + "aws-cdk": "1.21.0" }, "repository": { "type": "git", diff --git a/packages/decdk/package.json b/packages/decdk/package.json index 987f91625cc1a..8cc25825fe25d 100644 --- a/packages/decdk/package.json +++ b/packages/decdk/package.json @@ -1,6 +1,6 @@ { "name": "decdk", - "version": "1.19.0", + "version": "1.21.0", "description": "Declarative CDK: a CloudFormation-like syntax for defining CDK stacks", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -27,148 +27,149 @@ }, "license": "Apache-2.0", "dependencies": { - "@aws-cdk/alexa-ask": "1.19.0", - "@aws-cdk/app-delivery": "1.19.0", - "@aws-cdk/assets": "1.19.0", - "@aws-cdk/aws-accessanalyzer": "1.19.0", - "@aws-cdk/aws-amazonmq": "1.19.0", - "@aws-cdk/aws-amplify": "1.19.0", - "@aws-cdk/aws-apigateway": "1.19.0", - "@aws-cdk/aws-applicationautoscaling": "1.19.0", - "@aws-cdk/aws-appmesh": "1.19.0", - "@aws-cdk/aws-appstream": "1.19.0", - "@aws-cdk/aws-appsync": "1.19.0", - "@aws-cdk/aws-athena": "1.19.0", - "@aws-cdk/aws-autoscaling": "1.19.0", - "@aws-cdk/aws-autoscaling-common": "1.19.0", - "@aws-cdk/aws-autoscaling-hooktargets": "1.19.0", - "@aws-cdk/aws-autoscalingplans": "1.19.0", - "@aws-cdk/aws-backup": "1.19.0", - "@aws-cdk/aws-batch": "1.19.0", - "@aws-cdk/aws-budgets": "1.19.0", - "@aws-cdk/aws-certificatemanager": "1.19.0", - "@aws-cdk/aws-cloud9": "1.19.0", - "@aws-cdk/aws-cloudformation": "1.19.0", - "@aws-cdk/aws-cloudfront": "1.19.0", - "@aws-cdk/aws-cloudtrail": "1.19.0", - "@aws-cdk/aws-cloudwatch": "1.19.0", - "@aws-cdk/aws-cloudwatch-actions": "1.19.0", - "@aws-cdk/aws-codebuild": "1.19.0", - "@aws-cdk/aws-codecommit": "1.19.0", - "@aws-cdk/aws-codedeploy": "1.19.0", - "@aws-cdk/aws-codepipeline": "1.19.0", - "@aws-cdk/aws-codepipeline-actions": "1.19.0", - "@aws-cdk/aws-codestar": "1.19.0", - "@aws-cdk/aws-codestarnotifications": "1.19.0", - "@aws-cdk/aws-cognito": "1.19.0", - "@aws-cdk/aws-config": "1.19.0", - "@aws-cdk/aws-datapipeline": "1.19.0", - "@aws-cdk/aws-dax": "1.19.0", - "@aws-cdk/aws-directoryservice": "1.19.0", - "@aws-cdk/aws-dlm": "1.19.0", - "@aws-cdk/aws-dms": "1.19.0", - "@aws-cdk/aws-docdb": "1.19.0", - "@aws-cdk/aws-dynamodb": "1.19.0", - "@aws-cdk/aws-dynamodb-global": "1.19.0", - "@aws-cdk/aws-ec2": "1.19.0", - "@aws-cdk/aws-ecr": "1.19.0", - "@aws-cdk/aws-ecr-assets": "1.19.0", - "@aws-cdk/aws-ecs": "1.19.0", - "@aws-cdk/aws-ecs-patterns": "1.19.0", - "@aws-cdk/aws-efs": "1.19.0", - "@aws-cdk/aws-eks": "1.19.0", - "@aws-cdk/aws-elasticache": "1.19.0", - "@aws-cdk/aws-elasticbeanstalk": "1.19.0", - "@aws-cdk/aws-elasticloadbalancing": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2": "1.19.0", - "@aws-cdk/aws-elasticloadbalancingv2-targets": "1.19.0", - "@aws-cdk/aws-elasticsearch": "1.19.0", - "@aws-cdk/aws-emr": "1.19.0", - "@aws-cdk/aws-events": "1.19.0", - "@aws-cdk/aws-events-targets": "1.19.0", - "@aws-cdk/aws-eventschemas": "1.19.0", - "@aws-cdk/aws-fsx": "1.19.0", - "@aws-cdk/aws-gamelift": "1.19.0", - "@aws-cdk/aws-glue": "1.19.0", - "@aws-cdk/aws-greengrass": "1.19.0", - "@aws-cdk/aws-guardduty": "1.19.0", - "@aws-cdk/aws-iam": "1.19.0", - "@aws-cdk/aws-inspector": "1.19.0", - "@aws-cdk/aws-iot": "1.19.0", - "@aws-cdk/aws-iot1click": "1.19.0", - "@aws-cdk/aws-iotanalytics": "1.19.0", - "@aws-cdk/aws-iotevents": "1.19.0", - "@aws-cdk/aws-iotthingsgraph": "1.19.0", - "@aws-cdk/aws-kinesis": "1.19.0", - "@aws-cdk/aws-kinesisanalytics": "1.19.0", - "@aws-cdk/aws-kinesisfirehose": "1.19.0", - "@aws-cdk/aws-kms": "1.19.0", - "@aws-cdk/aws-lakeformation": "1.19.0", - "@aws-cdk/aws-lambda": "1.19.0", - "@aws-cdk/aws-lambda-destinations": "1.19.0", - "@aws-cdk/aws-lambda-event-sources": "1.19.0", - "@aws-cdk/aws-logs": "1.19.0", - "@aws-cdk/aws-logs-destinations": "1.19.0", - "@aws-cdk/aws-managedblockchain": "1.19.0", - "@aws-cdk/aws-mediaconvert": "1.19.0", - "@aws-cdk/aws-medialive": "1.19.0", - "@aws-cdk/aws-mediastore": "1.19.0", - "@aws-cdk/aws-msk": "1.19.0", - "@aws-cdk/aws-neptune": "1.19.0", - "@aws-cdk/aws-opsworks": "1.19.0", - "@aws-cdk/aws-opsworkscm": "1.19.0", - "@aws-cdk/aws-pinpoint": "1.19.0", - "@aws-cdk/aws-pinpointemail": "1.19.0", - "@aws-cdk/aws-qldb": "1.19.0", - "@aws-cdk/aws-ram": "1.19.0", - "@aws-cdk/aws-rds": "1.19.0", - "@aws-cdk/aws-redshift": "1.19.0", - "@aws-cdk/aws-robomaker": "1.19.0", - "@aws-cdk/aws-route53": "1.19.0", - "@aws-cdk/aws-route53-patterns": "1.19.0", - "@aws-cdk/aws-route53-targets": "1.19.0", - "@aws-cdk/aws-route53resolver": "1.19.0", - "@aws-cdk/aws-s3": "1.19.0", - "@aws-cdk/aws-s3-assets": "1.19.0", - "@aws-cdk/aws-s3-deployment": "1.19.0", - "@aws-cdk/aws-s3-notifications": "1.19.0", - "@aws-cdk/aws-sagemaker": "1.19.0", - "@aws-cdk/aws-sam": "1.19.0", - "@aws-cdk/aws-sdb": "1.19.0", - "@aws-cdk/aws-secretsmanager": "1.19.0", - "@aws-cdk/aws-securityhub": "1.19.0", - "@aws-cdk/aws-servicecatalog": "1.19.0", - "@aws-cdk/aws-servicediscovery": "1.19.0", - "@aws-cdk/aws-ses": "1.19.0", - "@aws-cdk/aws-ses-actions": "1.19.0", - "@aws-cdk/aws-sns": "1.19.0", - "@aws-cdk/aws-sns-subscriptions": "1.19.0", - "@aws-cdk/aws-sqs": "1.19.0", - "@aws-cdk/aws-ssm": "1.19.0", - "@aws-cdk/aws-stepfunctions": "1.19.0", - "@aws-cdk/aws-stepfunctions-tasks": "1.19.0", - "@aws-cdk/aws-transfer": "1.19.0", - "@aws-cdk/aws-waf": "1.19.0", - "@aws-cdk/aws-wafregional": "1.19.0", - "@aws-cdk/aws-wafv2": "1.19.0", - "@aws-cdk/aws-workspaces": "1.19.0", - "@aws-cdk/cfnspec": "1.19.0", - "@aws-cdk/core": "1.19.0", - "@aws-cdk/custom-resources": "1.19.0", - "@aws-cdk/cx-api": "1.19.0", - "@aws-cdk/region-info": "1.19.0", + "@aws-cdk/alexa-ask": "1.21.0", + "@aws-cdk/app-delivery": "1.21.0", + "@aws-cdk/assets": "1.21.0", + "@aws-cdk/aws-accessanalyzer": "1.21.0", + "@aws-cdk/aws-amazonmq": "1.21.0", + "@aws-cdk/aws-amplify": "1.21.0", + "@aws-cdk/aws-apigateway": "1.21.0", + "@aws-cdk/aws-apigatewayv2": "1.21.0", + "@aws-cdk/aws-applicationautoscaling": "1.21.0", + "@aws-cdk/aws-appmesh": "1.21.0", + "@aws-cdk/aws-appstream": "1.21.0", + "@aws-cdk/aws-appsync": "1.21.0", + "@aws-cdk/aws-athena": "1.21.0", + "@aws-cdk/aws-autoscaling": "1.21.0", + "@aws-cdk/aws-autoscaling-common": "1.21.0", + "@aws-cdk/aws-autoscaling-hooktargets": "1.21.0", + "@aws-cdk/aws-autoscalingplans": "1.21.0", + "@aws-cdk/aws-backup": "1.21.0", + "@aws-cdk/aws-batch": "1.21.0", + "@aws-cdk/aws-budgets": "1.21.0", + "@aws-cdk/aws-certificatemanager": "1.21.0", + "@aws-cdk/aws-cloud9": "1.21.0", + "@aws-cdk/aws-cloudformation": "1.21.0", + "@aws-cdk/aws-cloudfront": "1.21.0", + "@aws-cdk/aws-cloudtrail": "1.21.0", + "@aws-cdk/aws-cloudwatch": "1.21.0", + "@aws-cdk/aws-cloudwatch-actions": "1.21.0", + "@aws-cdk/aws-codebuild": "1.21.0", + "@aws-cdk/aws-codecommit": "1.21.0", + "@aws-cdk/aws-codedeploy": "1.21.0", + "@aws-cdk/aws-codepipeline": "1.21.0", + "@aws-cdk/aws-codepipeline-actions": "1.21.0", + "@aws-cdk/aws-codestar": "1.21.0", + "@aws-cdk/aws-codestarnotifications": "1.21.0", + "@aws-cdk/aws-cognito": "1.21.0", + "@aws-cdk/aws-config": "1.21.0", + "@aws-cdk/aws-datapipeline": "1.21.0", + "@aws-cdk/aws-dax": "1.21.0", + "@aws-cdk/aws-directoryservice": "1.21.0", + "@aws-cdk/aws-dlm": "1.21.0", + "@aws-cdk/aws-dms": "1.21.0", + "@aws-cdk/aws-docdb": "1.21.0", + "@aws-cdk/aws-dynamodb": "1.21.0", + "@aws-cdk/aws-dynamodb-global": "1.21.0", + "@aws-cdk/aws-ec2": "1.21.0", + "@aws-cdk/aws-ecr": "1.21.0", + "@aws-cdk/aws-ecr-assets": "1.21.0", + "@aws-cdk/aws-ecs": "1.21.0", + "@aws-cdk/aws-ecs-patterns": "1.21.0", + "@aws-cdk/aws-efs": "1.21.0", + "@aws-cdk/aws-eks": "1.21.0", + "@aws-cdk/aws-eks-legacy": "1.21.0", + "@aws-cdk/aws-elasticache": "1.21.0", + "@aws-cdk/aws-elasticbeanstalk": "1.21.0", + "@aws-cdk/aws-elasticloadbalancing": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2": "1.21.0", + "@aws-cdk/aws-elasticloadbalancingv2-targets": "1.21.0", + "@aws-cdk/aws-elasticsearch": "1.21.0", + "@aws-cdk/aws-emr": "1.21.0", + "@aws-cdk/aws-events": "1.21.0", + "@aws-cdk/aws-events-targets": "1.21.0", + "@aws-cdk/aws-eventschemas": "1.21.0", + "@aws-cdk/aws-fsx": "1.21.0", + "@aws-cdk/aws-gamelift": "1.21.0", + "@aws-cdk/aws-glue": "1.21.0", + "@aws-cdk/aws-greengrass": "1.21.0", + "@aws-cdk/aws-guardduty": "1.21.0", + "@aws-cdk/aws-iam": "1.21.0", + "@aws-cdk/aws-inspector": "1.21.0", + "@aws-cdk/aws-iot": "1.21.0", + "@aws-cdk/aws-iot1click": "1.21.0", + "@aws-cdk/aws-iotanalytics": "1.21.0", + "@aws-cdk/aws-iotevents": "1.21.0", + "@aws-cdk/aws-iotthingsgraph": "1.21.0", + "@aws-cdk/aws-kinesis": "1.21.0", + "@aws-cdk/aws-kinesisanalytics": "1.21.0", + "@aws-cdk/aws-kinesisfirehose": "1.21.0", + "@aws-cdk/aws-kms": "1.21.0", + "@aws-cdk/aws-lakeformation": "1.21.0", + "@aws-cdk/aws-lambda": "1.21.0", + "@aws-cdk/aws-lambda-destinations": "1.21.0", + "@aws-cdk/aws-lambda-event-sources": "1.21.0", + "@aws-cdk/aws-logs": "1.21.0", + "@aws-cdk/aws-logs-destinations": "1.21.0", + "@aws-cdk/aws-managedblockchain": "1.21.0", + "@aws-cdk/aws-mediaconvert": "1.21.0", + "@aws-cdk/aws-medialive": "1.21.0", + "@aws-cdk/aws-mediastore": "1.21.0", + "@aws-cdk/aws-msk": "1.21.0", + "@aws-cdk/aws-neptune": "1.21.0", + "@aws-cdk/aws-opsworks": "1.21.0", + "@aws-cdk/aws-opsworkscm": "1.21.0", + "@aws-cdk/aws-pinpoint": "1.21.0", + "@aws-cdk/aws-pinpointemail": "1.21.0", + "@aws-cdk/aws-qldb": "1.21.0", + "@aws-cdk/aws-ram": "1.21.0", + "@aws-cdk/aws-rds": "1.21.0", + "@aws-cdk/aws-redshift": "1.21.0", + "@aws-cdk/aws-robomaker": "1.21.0", + "@aws-cdk/aws-route53": "1.21.0", + "@aws-cdk/aws-route53-patterns": "1.21.0", + "@aws-cdk/aws-route53-targets": "1.21.0", + "@aws-cdk/aws-route53resolver": "1.21.0", + "@aws-cdk/aws-s3": "1.21.0", + "@aws-cdk/aws-s3-assets": "1.21.0", + "@aws-cdk/aws-s3-deployment": "1.21.0", + "@aws-cdk/aws-s3-notifications": "1.21.0", + "@aws-cdk/aws-sagemaker": "1.21.0", + "@aws-cdk/aws-sam": "1.21.0", + "@aws-cdk/aws-sdb": "1.21.0", + "@aws-cdk/aws-secretsmanager": "1.21.0", + "@aws-cdk/aws-securityhub": "1.21.0", + "@aws-cdk/aws-servicecatalog": "1.21.0", + "@aws-cdk/aws-servicediscovery": "1.21.0", + "@aws-cdk/aws-ses": "1.21.0", + "@aws-cdk/aws-ses-actions": "1.21.0", + "@aws-cdk/aws-sns": "1.21.0", + "@aws-cdk/aws-sns-subscriptions": "1.21.0", + "@aws-cdk/aws-sqs": "1.21.0", + "@aws-cdk/aws-ssm": "1.21.0", + "@aws-cdk/aws-stepfunctions": "1.21.0", + "@aws-cdk/aws-stepfunctions-tasks": "1.21.0", + "@aws-cdk/aws-transfer": "1.21.0", + "@aws-cdk/aws-waf": "1.21.0", + "@aws-cdk/aws-wafregional": "1.21.0", + "@aws-cdk/aws-wafv2": "1.21.0", + "@aws-cdk/aws-workspaces": "1.21.0", + "@aws-cdk/cfnspec": "1.21.0", + "@aws-cdk/core": "1.21.0", + "@aws-cdk/custom-resources": "1.21.0", + "@aws-cdk/cx-api": "1.21.0", + "@aws-cdk/region-info": "1.21.0", "fs-extra": "^8.1.0", "jsii-reflect": "^0.21.1", "jsonschema": "^1.2.5", "yaml": "1.7.2", - "yargs": "^15.1.0", - "@aws-cdk/aws-eks-legacy": "1.19.0" + "yargs": "^15.1.0" }, "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/jest": "^24.0.25", + "@types/jest": "^24.9.0", "@types/yaml": "1.2.0", - "@types/yargs": "^13.0.4", + "@types/yargs": "^15.0.0", "jest": "^24.9.0", "jsii": "^0.21.1" }, diff --git a/packages/decdk/test/fixture/tsconfig.json b/packages/decdk/test/fixture/tsconfig.json index ff97fed386484..07afb1f64860c 100644 --- a/packages/decdk/test/fixture/tsconfig.json +++ b/packages/decdk/test/fixture/tsconfig.json @@ -7,7 +7,7 @@ "inlineSourceMap": true, "inlineSources": true, "lib": [ - "es2016" + "es2018" ], "module": "CommonJS", "noEmitOnError": true, @@ -22,7 +22,7 @@ "strictNullChecks": true, "strictPropertyInitialization": true, "stripInternal": true, - "target": "ES2017" + "target": "ES2018" }, "include": [ "**/*.ts" diff --git a/tools/awslint/package.json b/tools/awslint/package.json index a1b3a1d0597e5..cdd23425b3cd1 100644 --- a/tools/awslint/package.json +++ b/tools/awslint/package.json @@ -1,7 +1,7 @@ { "name": "awslint", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "Enforces the AWS Construct Library guidelines", "main": "index.js", "scripts": { @@ -25,7 +25,7 @@ }, "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/yargs": "^13.0.4", + "@types/yargs": "^15.0.0", "tslint": "^5.20.1", "typescript": "~3.7.4" }, diff --git a/tools/cdk-build-tools/lib/package-info.ts b/tools/cdk-build-tools/lib/package-info.ts index 3358d347ac047..fe104006b26fc 100644 --- a/tools/cdk-build-tools/lib/package-info.ts +++ b/tools/cdk-build-tools/lib/package-info.ts @@ -83,7 +83,7 @@ export interface CompilerOverrides { */ export function packageCompiler(compilers: CompilerOverrides): string[] { if (isJsii()) { - return [compilers.jsii || require.resolve('jsii/bin/jsii'), '--project-references']; + return [compilers.jsii || require.resolve('jsii/bin/jsii'), '--project-references', '--silence-warnings=reserved-word']; } else { return [compilers.tsc || require.resolve('typescript/bin/tsc'), '--build']; } diff --git a/tools/cdk-build-tools/package.json b/tools/cdk-build-tools/package.json index d475bb9ed27d3..9f1884c73c869 100644 --- a/tools/cdk-build-tools/package.json +++ b/tools/cdk-build-tools/package.json @@ -1,7 +1,7 @@ { "name": "cdk-build-tools", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "Tools package with shared build scripts for CDK packages", "main": "lib/index.js", "repository": { @@ -32,26 +32,26 @@ "license": "Apache-2.0", "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/jest": "^24.0.25", - "@types/yargs": "^13.0.4", - "pkglint": "1.19.0" + "@types/jest": "^24.9.0", + "@types/yargs": "^15.0.0", + "pkglint": "1.21.0" }, "dependencies": { - "@typescript-eslint/eslint-plugin": "^2.14.0", - "@typescript-eslint/parser": "^2.14.0", - "awslint": "1.19.0", + "@typescript-eslint/eslint-plugin": "^2.16.0", + "@typescript-eslint/parser": "^2.16.0", + "awslint": "1.21.0", "colors": "^1.4.0", "eslint": "^6.8.0", - "eslint-import-resolver-node": "^0.3.2", + "eslint-import-resolver-node": "^0.3.3", "eslint-import-resolver-typescript": "^2.0.0", - "eslint-plugin-import": "^2.19.1", + "eslint-plugin-import": "^2.20.0", "fs-extra": "^8.1.0", "jest": "^24.9.0", "jsii": "^0.21.1", "jsii-pacmak": "^0.21.1", "nodeunit": "^0.11.3", "nyc": "^15.0.0", - "ts-jest": "^24.2.0", + "ts-jest": "^24.3.0", "tslint": "^5.20.1", "typescript": "~3.7.4", "yargs": "^15.1.0" diff --git a/tools/cdk-integ-tools/package.json b/tools/cdk-integ-tools/package.json index e77d8fd0a1962..ed0191cf01a7d 100644 --- a/tools/cdk-integ-tools/package.json +++ b/tools/cdk-integ-tools/package.json @@ -1,7 +1,7 @@ { "name": "cdk-integ-tools", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "Package with integration test scripts for CDK packages", "main": "index.js", "repository": { @@ -30,14 +30,14 @@ "license": "Apache-2.0", "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/yargs": "^13.0.4", - "cdk-build-tools": "1.19.0", - "pkglint": "1.19.0" + "@types/yargs": "^15.0.0", + "cdk-build-tools": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { - "@aws-cdk/cloudformation-diff": "1.19.0", - "@aws-cdk/cx-api": "1.19.0", - "aws-cdk": "1.19.0", + "@aws-cdk/cloudformation-diff": "1.21.0", + "@aws-cdk/cx-api": "1.21.0", + "aws-cdk": "1.21.0", "fs-extra": "^8.1.0", "yargs": "^15.1.0" }, diff --git a/tools/cfn2ts/package.json b/tools/cfn2ts/package.json index a2ed31ff7f628..30a500ba5b558 100644 --- a/tools/cfn2ts/package.json +++ b/tools/cfn2ts/package.json @@ -1,7 +1,7 @@ { "name": "cfn2ts", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "Generates typescript types from CloudFormation spec, with support for enrichments", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -29,7 +29,7 @@ }, "license": "Apache-2.0", "dependencies": { - "@aws-cdk/cfnspec": "1.19.0", + "@aws-cdk/cfnspec": "1.21.0", "codemaker": "^0.21.1", "fast-json-patch": "^3.0.0-1", "fs-extra": "^8.1.0", @@ -37,11 +37,11 @@ }, "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/jest": "^24.0.25", - "@types/yargs": "^13.0.4", - "cdk-build-tools": "1.19.0", + "@types/jest": "^24.9.0", + "@types/yargs": "^15.0.0", + "cdk-build-tools": "1.21.0", "jest": "^24.9.0", - "pkglint": "1.19.0" + "pkglint": "1.21.0" }, "cdk-build": { "eslint": { diff --git a/tools/pkglint/package.json b/tools/pkglint/package.json index c6aaf6c09707f..246bd7cc44355 100644 --- a/tools/pkglint/package.json +++ b/tools/pkglint/package.json @@ -1,6 +1,6 @@ { "name": "pkglint", - "version": "1.19.0", + "version": "1.21.0", "private": true, "description": "Validate and fix package.json files", "main": "lib/index.js", @@ -36,7 +36,7 @@ "devDependencies": { "@types/fs-extra": "^8.0.1", "@types/semver": "^6.2.0", - "@types/yargs": "^13.0.4" + "@types/yargs": "^15.0.0" }, "dependencies": { "case": "^1.6.2", diff --git a/tools/pkgtools/package.json b/tools/pkgtools/package.json index 9990e645084a3..4e95c39cedc31 100644 --- a/tools/pkgtools/package.json +++ b/tools/pkgtools/package.json @@ -1,7 +1,7 @@ { "name": "pkgtools", "private": true, - "version": "1.19.0", + "version": "1.21.0", "description": "Tools for generating cross-package artifacts", "main": "index.js", "repository": { @@ -30,9 +30,9 @@ "license": "Apache-2.0", "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/yargs": "^13.0.4", - "cdk-build-tools": "1.19.0", - "pkglint": "1.19.0" + "@types/yargs": "^15.0.0", + "cdk-build-tools": "1.21.0", + "pkglint": "1.21.0" }, "dependencies": { "fs-extra": "^8.1.0", diff --git a/yarn.lock b/yarn.lock index d6ddeb2c78c83..b6d26f612df2f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1207,10 +1207,10 @@ "@sinonjs/commons" "^1" "@sinonjs/samsam" "^4.2.0" -"@sinonjs/samsam@^4.2.0", "@sinonjs/samsam@^4.2.1": - version "4.2.1" - resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-4.2.1.tgz#cee77dc95f8d00339633e1683e026f2d73ed1d3a" - integrity sha512-7+5S4C4wpug5pzHS+z/63+XUwsH7dtyYELDafoT1QnfruFh7eFjlDWwZXltUB0GLk6y5eMeAt34Bjx8wJ4KfSA== +"@sinonjs/samsam@^4.2.0", "@sinonjs/samsam@^4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-4.2.2.tgz#0f6cb40e467865306d8a20a97543a94005204e23" + integrity sha512-z9o4LZUzSD9Hl22zV38aXNykgFeVj8acqfFabCY6FY83n/6s/XwNJyYYldz6/9lBJanpno9h+oL6HTISkviweA== dependencies: "@sinonjs/commons" "^1.6.0" lodash.get "^4.4.2" @@ -1322,10 +1322,10 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" -"@types/jest@^24.0.25": - version "24.0.25" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.25.tgz#2aba377824ce040114aa906ad2cac2c85351360f" - integrity sha512-hnP1WpjN4KbGEK4dLayul6lgtys6FPz0UfxMeMQCv0M+sTnzN3ConfiO72jHgLxl119guHgI8gLqDOrRLsyp2g== +"@types/jest@^24.9.0": + version "24.9.0" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.9.0.tgz#78c6991cd1734cf0d390be24875e310bb0a9fb74" + integrity sha512-dXvuABY9nM1xgsXlOtLQXJKdacxZJd7AtvLsKZ/0b57ruMXDKCOXAC/M75GbllQX6o1pcZ5hAG4JzYy7Z/wM2w== dependencies: jest-diff "^24.3.0" @@ -1339,10 +1339,10 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= -"@types/jszip@^3.1.6": - version "3.1.6" - resolved "https://registry.yarnpkg.com/@types/jszip/-/jszip-3.1.6.tgz#0512574a2b35f3194b41769c56e4b35065e67000" - integrity sha512-m8uFcI+O2EupCfbEVQWsBM/4nhbegjOHL7cQgBpM95FeF98kdFJXzy9/8yhx4b3lCRl/gMBhcvyh30Qt3X+XPQ== +"@types/jszip@^3.1.7": + version "3.1.7" + resolved "https://registry.yarnpkg.com/@types/jszip/-/jszip-3.1.7.tgz#c45bd72b448b3fb002125282c57c36190247cb34" + integrity sha512-+XQKNI5zpxutK05hO67huUTw/2imXCuJWjnFdU63tRES/xXSX1yVR9cv/QAdO6Rii2y2tTHbzjQ4i2apLfuK0Q== dependencies: "@types/node" "*" @@ -1454,53 +1454,60 @@ resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-13.1.0.tgz#c563aa192f39350a1d18da36c5a8da382bbd8228" integrity sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg== -"@types/yargs@^13.0.0", "@types/yargs@^13.0.4": +"@types/yargs@^13.0.0": version "13.0.4" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-13.0.4.tgz#53d231cebe1a540e7e13727fc1f0d13ad4a9ba3b" integrity sha512-Ke1WmBbIkVM8bpvsNEcGgQM70XcEh/nbpxQhW7FhrsbCsXSY9BmLB1+LHtD7r9zrsOcFlLiF+a/UeJsdfw3C5A== dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^2.14.0": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.14.0.tgz#c74447400537d4eb7aae1e31879ab43e6c662a8a" - integrity sha512-sneOJ3Hu0m5whJiVIxGBZZZMxMJ7c0LhAJzeMJgHo+n5wFs+/6rSR/gl7crkdR2kNwfOOSdzdc0gMvatG4dX2Q== +"@types/yargs@^15.0.0": + version "15.0.0" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.0.tgz#26aa57277eec9ab9c5fce61bddec20ecc9a4cfb7" + integrity sha512-TITCsNxRSDVmq3kPGuUdKZTPTfHeswsUGIjxSe8SB4EBKTPA0DO0y4yWI95kZ2hfqJAYxmu+gxzjOwdumB5S0g== dependencies: - "@typescript-eslint/experimental-utils" "2.14.0" + "@types/yargs-parser" "*" + +"@typescript-eslint/eslint-plugin@^2.16.0": + version "2.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.16.0.tgz#bf339b7db824c7cc3fd1ebedbc88dd17016471af" + integrity sha512-TKWbeFAKRPrvKiR9GNxErQ8sELKqg1ZvXi6uho07mcKShBnCnqNpDQWP01FEvWKf0bxM2g7uQEI5MNjSNqvUpQ== + dependencies: + "@typescript-eslint/experimental-utils" "2.16.0" eslint-utils "^1.4.3" functional-red-black-tree "^1.0.1" regexpp "^3.0.0" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@2.14.0": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.14.0.tgz#e9179fa3c44e00b3106b85d7b69342901fb43e3b" - integrity sha512-KcyKS7G6IWnIgl3ZpyxyBCxhkBPV+0a5Jjy2g5HxlrbG2ZLQNFeneIBVXdaBCYOVjvGmGGFKom1kgiAY75SDeQ== +"@typescript-eslint/experimental-utils@2.16.0": + version "2.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.16.0.tgz#bba65685728c532e0ddc811a0376e8d38e671f77" + integrity sha512-bXTmAztXpqxliDKZgvWkl+5dHeRN+jqXVZ16peKKFzSXVzT6mz8kgBpHiVzEKO2NZ8OCU7dG61K9sRS/SkUUFQ== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "2.14.0" + "@typescript-eslint/typescript-estree" "2.16.0" eslint-scope "^5.0.0" -"@typescript-eslint/parser@^2.14.0": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.14.0.tgz#30fa0523d86d74172a5e32274558404ba4262cd6" - integrity sha512-haS+8D35fUydIs+zdSf4BxpOartb/DjrZ2IxQ5sR8zyGfd77uT9ZJZYF8+I0WPhzqHmfafUBx8MYpcp8pfaoSA== +"@typescript-eslint/parser@^2.16.0": + version "2.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.16.0.tgz#d0c0135a8fdb915f670802ddd7c1ba457c1b4f9d" + integrity sha512-+w8dMaYETM9v6il1yYYkApMSiwgnqXWJbXrA94LAWN603vXHACsZTirJduyeBOJjA9wT6xuXe5zZ1iCUzoxCfw== dependencies: "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "2.14.0" - "@typescript-eslint/typescript-estree" "2.14.0" + "@typescript-eslint/experimental-utils" "2.16.0" + "@typescript-eslint/typescript-estree" "2.16.0" eslint-visitor-keys "^1.1.0" -"@typescript-eslint/typescript-estree@2.14.0": - version "2.14.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.14.0.tgz#c67698acdc14547f095eeefe908958d93e1a648d" - integrity sha512-pnLpUcMNG7GfFFfNQbEX6f1aPa5fMnH2G9By+A1yovYI4VIOK2DzkaRuUlIkbagpAcrxQHLqovI1YWqEcXyRnA== +"@typescript-eslint/typescript-estree@2.16.0": + version "2.16.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.16.0.tgz#b444943a76c716ed32abd08cbe96172d2ca0ab75" + integrity sha512-hyrCYjFHISos68Bk5KjUAXw0pP/455qq9nxqB1KkT67Pxjcfw+r6Yhcmqnp8etFL45UexCHUMrADHH7dI/m2WQ== dependencies: debug "^4.1.1" eslint-visitor-keys "^1.1.0" glob "^7.1.6" is-glob "^4.0.1" - lodash.unescape "4.0.1" + lodash "^4.17.15" semver "^6.3.0" tsutils "^3.17.1" @@ -1569,7 +1576,7 @@ add-stream@^1.0.0: resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" integrity sha1-anmQQ3ynNtXhKI25K9MmbV9csqo= -agent-base@4, agent-base@^4.3.0: +agent-base@4, agent-base@^4.2.0, agent-base@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== @@ -1668,11 +1675,6 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -app-root-path@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-2.2.1.tgz#d0df4a682ee408273583d43f6f79e9892624bc9a" - integrity sha512-91IFKeKk7FjfmezPKkwtaRvSpnUc4gDwPAjA1YZ9Gn0q0PPeW+vbeUsZuyDwjI7+QTHhcLen2v25fi/AmhvbJA== - append-transform@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-1.0.0.tgz#046a52ae582a228bd72f58acfbe2967c678759ab" @@ -1846,6 +1848,11 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= +ast-types@0.x.x: + version "0.13.2" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.2.tgz#df39b677a911a83f3a049644fb74fdded23cea48" + integrity sha512-uWMHxJxtfj/1oZClOxDEV1sQ1HCDkA4MG8Gr69KKeBjEVH0R84WlejZ0y2DcwyBlpAEMltmVYkVgqfLFb2oyiA== + astral-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" @@ -1887,10 +1894,10 @@ aws-sdk-mock@^5.0.0: sinon "^8.0.1" traverse "^0.6.6" -aws-sdk@^2.596.0, aws-sdk@^2.597.0: - version "2.597.0" - resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.597.0.tgz#028c7778b4fdc742ac040e7071b85a070d18bf2a" - integrity sha512-xdhm1bYnh46b7pEOmIsptQcPAJmq9MT31cUsn3WzOr6IPtiRLz5XIHIusFFsJYpyjiFB99b1n8SabRR7j6H1AA== +aws-sdk@^2.596.0, aws-sdk@^2.601.0: + version "2.601.0" + resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.601.0.tgz#7210e4e1edcffbe76e9b2a7181617966c9cfc731" + integrity sha512-i8ND3Hn0zjuwyau47io8Uyvbeb6dnOYbC6k34u3DvqH3I/kFDgDAme6L58LUzSHAPDWhUDjNXpScmMsGZVDWrw== dependencies: buffer "4.9.1" events "1.1.1" @@ -2114,6 +2121,11 @@ byte-size@^5.0.1: resolved "https://registry.yarnpkg.com/byte-size/-/byte-size-5.0.1.tgz#4b651039a5ecd96767e71a3d7ed380e48bed4191" integrity sha512-/XuKeqWocKsYa/cBY1YbSJSWWqTi4cFgr9S6OyM7PBaPbr9zvNGwWP33vt0uqGhwDdN+y3yhbXVILEUpnwEWGw== +bytes@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" + integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== + cacache@^12.0.0, cacache@^12.0.3: version "12.0.3" resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.3.tgz#be99abba4e1bf5df461cd5a2c1071fc432573390" @@ -2883,6 +2895,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +data-uri-to-buffer@1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz#77163ea9c20d8641b4707e8f18abdf9a78f34835" + integrity sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ== + data-urls@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-1.1.0.tgz#15ee0582baa5e22bb59c77140da8f9c76963bbfe" @@ -2907,6 +2924,13 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== +debug@2, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + debug@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" @@ -2914,12 +2938,12 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: - version "2.6.9" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" - integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== +debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: - ms "2.0.0" + ms "^2.1.1" debug@^3.1.0, debug@^3.2.6: version "3.2.6" @@ -2928,13 +2952,6 @@ debug@^3.1.0, debug@^3.2.6: dependencies: ms "^2.1.1" -debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" - integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== - dependencies: - ms "^2.1.1" - debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" @@ -3048,6 +3065,15 @@ define-property@^2.0.2: is-descriptor "^1.0.2" isobject "^3.0.1" +degenerator@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-1.0.4.tgz#fcf490a37ece266464d9cc431ab98c5819ced095" + integrity sha1-/PSQo37OJmRk2cxDGrmMWBnO0JU= + dependencies: + ast-types "0.x.x" + escodegen "1.x.x" + esprima "3.x.x" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -3058,6 +3084,11 @@ delegates@^1.0.0: resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= + deprecation@^2.0.0: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" @@ -3101,10 +3132,10 @@ diff@^1.3.2: resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" integrity sha1-fyjS657nsVqX79ic5j3P2qPMur8= -diff@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff" - integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q== +diff@^4.0.1, diff@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== difflib@~0.2.1: version "0.2.4" @@ -3161,16 +3192,6 @@ dot-prop@^4.2.0: dependencies: is-obj "^1.0.0" -dotenv-json@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/dotenv-json/-/dotenv-json-1.0.0.tgz#fc7f672aafea04bed33818733b9f94662332815c" - integrity sha512-jAssr+6r4nKhKRudQ0HOzMskOFFi9+ubXWwmrSGJFgTvpjyPXCXsCsYbjif6mXp7uxA7xY3/LGaiTQukZzSbOQ== - -dotenv@^8.0.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" - integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== - dreamopt@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/dreamopt/-/dreamopt-0.6.0.tgz#d813ccdac8d39d8ad526775514a13dda664d6b4b" @@ -3361,6 +3382,18 @@ escape-string-regexp@^2.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== +escodegen@1.x.x: + version "1.12.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.12.1.tgz#08770602a74ac34c7a90ca9229e7d51e379abc76" + integrity sha512-Q8t2YZ+0e0pc7NRVj3B4tSQ9rim1oi4Fh46k2xhJ2qOiEwhQfdjyEQddWdj7ZFaKmU+5104vn1qrcjEPWq+bgQ== + dependencies: + esprima "^3.1.3" + estraverse "^4.2.0" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.6.1" + escodegen@^1.9.1: version "1.12.0" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.12.0.tgz#f763daf840af172bb3a2b6dd7219c0e17f7ff541" @@ -3373,18 +3406,13 @@ escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" -eslint-config-standard@^14.1.0: - version "14.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-14.1.0.tgz#b23da2b76fe5a2eba668374f246454e7058f15d4" - integrity sha512-EF6XkrrGVbvv8hL/kYa/m6vnvmUT+K82pJJc4JJVMM6+Qgqh0pnwprSxdduDLB9p/7bIxD+YV5O0wfb8lmcPbA== - -eslint-import-resolver-node@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" - integrity sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q== +eslint-import-resolver-node@^0.3.2, eslint-import-resolver-node@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz#dbaa52b6b2816b50bc6711af75422de808e98404" + integrity sha512-b8crLDo0M5RSe5YG8Pu2DYBj71tSB6OvXkfzwbJU2w7y8P4/yo0MyF8jU26IEuEuHF2K5/gcAJE3LhQGqBBbVg== dependencies: debug "^2.6.9" - resolve "^1.5.0" + resolve "^1.13.1" eslint-import-resolver-typescript@^2.0.0: version "2.0.0" @@ -3405,18 +3433,10 @@ eslint-module-utils@^2.4.1: debug "^2.6.9" pkg-dir "^2.0.0" -eslint-plugin-es@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-2.0.0.tgz#0f5f5da5f18aa21989feebe8a73eadefb3432976" - integrity sha512-f6fceVtg27BR02EYnBhgWLFQfK6bN4Ll0nQFrBHOlCsAyxeZkn0NHns5O0YZOPrV1B3ramd6cgFwaoFLcSkwEQ== - dependencies: - eslint-utils "^1.4.2" - regexpp "^3.0.0" - -eslint-plugin-import@^2.19.1: - version "2.19.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.19.1.tgz#5654e10b7839d064dd0d46cd1b88ec2133a11448" - integrity sha512-x68131aKoCZlCae7rDXKSAQmbT5DQuManyXo2sK6fJJ0aK5CWAkv6A6HJZGgqC8IhjQxYPgo6/IY4Oz8AFsbBw== +eslint-plugin-import@^2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.20.0.tgz#d749a7263fb6c29980def8e960d380a6aa6aecaa" + integrity sha512-NK42oA0mUc8Ngn4kONOPsPB1XhbUvNHqF+g307dPV28aknPoiNnKLFd9em4nkswwepdF5ouieqv5Th/63U7YJQ== dependencies: array-includes "^3.0.3" array.prototype.flat "^1.2.1" @@ -3431,28 +3451,6 @@ eslint-plugin-import@^2.19.1: read-pkg-up "^2.0.0" resolve "^1.12.0" -eslint-plugin-node@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-10.0.0.tgz#fd1adbc7a300cf7eb6ac55cf4b0b6fc6e577f5a6" - integrity sha512-1CSyM/QCjs6PXaT18+zuAXsjXGIGo5Rw630rSKwokSs2jrYURQc4R5JZpoanNCqwNmepg+0eZ9L7YiRUJb8jiQ== - dependencies: - eslint-plugin-es "^2.0.0" - eslint-utils "^1.4.2" - ignore "^5.1.1" - minimatch "^3.0.4" - resolve "^1.10.1" - semver "^6.1.0" - -eslint-plugin-promise@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a" - integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw== - -eslint-plugin-standard@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-4.0.1.tgz#ff0519f7ffaff114f76d1bd7c3996eef0f6e20b4" - integrity sha512-v/KBnfyaOMPmZc/dmc6ozOdWqekGp7bBGq4jLAecEfPGmfKiWS4sA8sC0LqiV9w5qmXAtXVn4M3p1jSyhY85SQ== - eslint-scope@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" @@ -3461,7 +3459,7 @@ eslint-scope@^5.0.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-utils@^1.4.2, eslint-utils@^1.4.3: +eslint-utils@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== @@ -3530,7 +3528,7 @@ espree@^6.1.2: acorn-jsx "^5.1.0" eslint-visitor-keys "^1.1.0" -esprima@^3.1.3: +esprima@3.x.x, esprima@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" integrity sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM= @@ -3765,6 +3763,11 @@ file-entry-cache@^5.0.1: dependencies: flat-cache "^2.0.1" +file-uri-to-path@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + fill-keys@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/fill-keys/-/fill-keys-1.0.2.tgz#9a8fa36f4e8ad634e3bf6b4f3c8882551452eb20" @@ -3966,6 +3969,14 @@ fsevents@^1.2.7: nan "^2.12.1" node-pre-gyp "^0.12.0" +ftp@~0.3.10: + version "0.3.10" + resolved "https://registry.yarnpkg.com/ftp/-/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d" + integrity sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0= + dependencies: + readable-stream "1.1.x" + xregexp "2.0.0" + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -4033,6 +4044,18 @@ get-stream@^4.0.0, get-stream@^4.1.0: dependencies: pump "^3.0.0" +get-uri@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-2.0.4.tgz#d4937ab819e218d4cb5ae18e4f5962bef169cc6a" + integrity sha512-v7LT/s8kVjs+Tx0ykk1I+H/rbpzkHvuIq87LmeXptcf5sNWm9uQiwjNAt94SJPA1zOlCntmnOlJvVWKmzsxG8Q== + dependencies: + data-uri-to-buffer "1" + debug "2" + extend "~3.0.2" + file-uri-to-path "1" + ftp "~0.3.10" + readable-stream "2" + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -4331,6 +4354,17 @@ http-cache-semantics@^3.8.1: resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== +http-errors@1.7.3: + version "1.7.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" + integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw== + dependencies: + depd "~1.1.2" + inherits "2.0.4" + setprototypeof "1.1.1" + statuses ">= 1.5.0 < 2" + toidentifier "1.0.0" + http-proxy-agent@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405" @@ -4356,6 +4390,14 @@ https-proxy-agent@^2.2.3: agent-base "^4.3.0" debug "^3.1.0" +https-proxy-agent@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz#b8c286433e87602311b01c8ea34413d856a4af81" + integrity sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg== + dependencies: + agent-base "^4.3.0" + debug "^3.1.0" + humanize-ms@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" @@ -4392,11 +4434,6 @@ ignore@^4.0.3, ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.1.1: - version "5.1.4" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf" - integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A== - immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" @@ -4461,7 +4498,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -4530,7 +4567,7 @@ invariant@^2.2.4: dependencies: loose-envify "^1.0.0" -ip@1.1.5: +ip@1.1.5, ip@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= @@ -5591,24 +5628,6 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== -lambda-leak@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lambda-leak/-/lambda-leak-2.0.0.tgz#771985d3628487f6e885afae2b54510dcfb2cd7e" - integrity sha1-dxmF02KEh/boha+uK1RRDc+yzX4= - -lambda-tester@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/lambda-tester/-/lambda-tester-3.6.0.tgz#ceb7d4f4f0da768487a05cff37dcd088508b5247" - integrity sha512-F2ZTGWCLyIR95o/jWK46V/WnOCFAEUG/m/V7/CLhPJ7PCM+pror1rZ6ujP3TkItSGxUfpJi0kqwidw+M/nEqWw== - dependencies: - app-root-path "^2.2.1" - dotenv "^8.0.0" - dotenv-json "^1.0.0" - lambda-leak "^2.0.0" - semver "^6.1.1" - uuid "^3.3.2" - vandium-utils "^1.1.1" - lazystream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" @@ -5810,11 +5829,6 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "^3.0.0" -lodash.unescape@4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" - integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= - lodash.union@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.union/-/lodash.union-4.6.0.tgz#48bb5088409f16f1821666641c44dd1aaae3cd88" @@ -6295,6 +6309,11 @@ nested-error-stacks@^2.0.0: resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz#0fbdcf3e13fe4994781280524f8b96b0cdff9c61" integrity sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug== +netmask@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35" + integrity sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU= + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" @@ -6312,10 +6331,10 @@ nise@^3.0.1: lolex "^5.0.1" path-to-regexp "^1.7.0" -nock@^11.7.0, nock@^11.7.1: - version "11.7.1" - resolved "https://registry.yarnpkg.com/nock/-/nock-11.7.1.tgz#761971f24093e291af6e1f0af5b6eb048b94b1c1" - integrity sha512-fW+dlMyquAEvgtmGoRHftKrNnJ7yZcbINQDTW7OKRoTYa+11GA0u0UokWHuvCyZrG5TXkplnEv2jmj6R3vvImg== +nock@^11.7.2: + version "11.7.2" + resolved "https://registry.yarnpkg.com/nock/-/nock-11.7.2.tgz#4cee4fa838dc3635c074c5b3436bcdec7f7ee213" + integrity sha512-7swr5bL1xBZ5FctyubjxEVySXOSebyqcL7Vy1bx1nS9IUqQWj81cmKjVKJLr8fHhtzI1MV8nyCdENA/cGcY1+Q== dependencies: debug "^4.1.0" json-stringify-safe "^5.0.1" @@ -6856,6 +6875,31 @@ p-waterfall@^1.0.0: dependencies: p-reduce "^1.0.0" +pac-proxy-agent@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-3.0.1.tgz#115b1e58f92576cac2eba718593ca7b0e37de2ad" + integrity sha512-44DUg21G/liUZ48dJpUSjZnFfZro/0K5JTyFYLBcmh9+T6Ooi4/i4efwUiEy0+4oQusCBqWdhv16XohIj1GqnQ== + dependencies: + agent-base "^4.2.0" + debug "^4.1.1" + get-uri "^2.0.0" + http-proxy-agent "^2.1.0" + https-proxy-agent "^3.0.0" + pac-resolver "^3.0.0" + raw-body "^2.2.0" + socks-proxy-agent "^4.0.1" + +pac-resolver@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-3.0.0.tgz#6aea30787db0a891704deb7800a722a7615a6f26" + integrity sha512-tcc38bsjuE3XZ5+4vP96OfhOugrX+JcnpUbhfuc4LuXBLQhoTthOstZeoQJBDnQUDYzYmdImKsbz0xSl1/9qeA== + dependencies: + co "^4.6.0" + degenerator "^1.0.4" + ip "^1.1.5" + netmask "^1.0.6" + thunkify "^2.1.2" + package-hash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-3.0.0.tgz#50183f2d36c9e3e528ea0a8605dff57ce976f88e" @@ -7177,6 +7221,25 @@ protoduck@^5.0.1: dependencies: genfun "^5.0.0" +proxy-agent@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-3.1.1.tgz#7e04e06bf36afa624a1540be247b47c970bd3014" + integrity sha512-WudaR0eTsDx33O3EJE16PjBRZWcX8GqCEeERw1W3hZJgH/F2a46g7jty6UGty6NeJ4CKQy8ds2CJPMiyeqaTvw== + dependencies: + agent-base "^4.2.0" + debug "4" + http-proxy-agent "^2.1.0" + https-proxy-agent "^3.0.0" + lru-cache "^5.1.1" + pac-proxy-agent "^3.0.1" + proxy-from-env "^1.0.0" + socks-proxy-agent "^4.0.1" + +proxy-from-env@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" + integrity sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4= + proxyquire@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/proxyquire/-/proxyquire-2.1.3.tgz#2049a7eefa10a9a953346a18e54aab2b4268df39" @@ -7261,6 +7324,16 @@ quick-lru@^1.0.0: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" integrity sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g= +raw-body@^2.2.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.1.tgz#30ac82f98bb5ae8c152e67149dac8d55153b168c" + integrity sha512-9WmIKF6mkvA0SLmA2Knm9+qj89e+j1zqgyn8aXGd7+nAduPoqgI9lO57SAZNn/Byzo5P7JhXTyg9PzaJbH73bA== + dependencies: + bytes "3.1.0" + http-errors "1.7.3" + iconv-lite "0.4.24" + unpipe "1.0.0" + rc@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" @@ -7383,6 +7456,29 @@ read@1, read@^1.0.4, read@~1.0.1: string_decoder "~1.1.1" util-deprecate "~1.0.1" +readable-stream@1.1.x: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@2: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + "readable-stream@2 || 3", readable-stream@^3.0.1, readable-stream@^3.0.2, readable-stream@^3.1.1, readable-stream@^3.4.0: version "3.4.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.4.0.tgz#a51c26754658e0a3c21dbf59163bd45ba6f447fc" @@ -7568,24 +7664,10 @@ resolve@1.1.7: resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= -resolve@1.x, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.3.2: - version "1.12.2" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.2.tgz#08b12496d9aa8659c75f534a8f05f0d892fff594" - integrity sha512-cAVTI2VLHWYsGOirfeYVVQ7ZDejtQ9fp4YhYckWDEkFfqbVjaT11iM8k6xSAfGFMM+gDpZjMnFssPu8we+mqFw== - dependencies: - path-parse "^1.0.6" - -resolve@^1.10.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.14.1.tgz#9e018c540fcf0c427d678b9931cbf45e984bcaff" - integrity sha512-fn5Wobh4cxbLzuHaE+nphztHy43/b++4M6SsGFC2gB8uYwf0C8LcarfCz1un7UTW8OFQg9iNjZ4xpcFVGebDPg== - dependencies: - path-parse "^1.0.6" - -resolve@^1.12.0, resolve@^1.5.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.13.1.tgz#be0aa4c06acd53083505abb35f4d66932ab35d16" - integrity sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w== +resolve@1.x, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.3.2: + version "1.14.2" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.14.2.tgz#dbf31d0fa98b1f29aa5169783b9c290cb865fea2" + integrity sha512-EjlOBLBO1kxsUxsKjLt7TAECyKW6fOh1VRkykQkKGzcBbjjPIxBqGh0jf7GJ3k/f5mxMqW3htMD3WdTUVtW8HQ== dependencies: path-parse "^1.0.6" @@ -7726,7 +7808,7 @@ semver-intersect@^1.4.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: +semver@^6.0.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -7761,6 +7843,11 @@ set-value@^2.0.0, set-value@^2.0.1: is-plain-object "^2.0.3" split-string "^3.0.1" +setprototypeof@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" + integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== + shallow-clone@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" @@ -7810,15 +7897,15 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= -sinon@^8.0.1, sinon@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-8.0.2.tgz#cc5f6daa9cc351b86b03faaca1e9c3650a04ae11" - integrity sha512-8W1S7BnCyvk7SK+Xi15B1QAVLuS81G/NGmWefPb31+ly6xI3fXaug/g5oUdfc8+7ruC4Ay51AxuLlYm8diq6kA== +sinon@^8.0.1, sinon@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-8.1.0.tgz#30f82371ac6e7d4dccb77fa1525f5ea748c636ff" + integrity sha512-6/05TR+8QhEgTbyMWaConm8iPL609Eno7SqToPq63wC/jS/6NMEI4NxqtzlLkk3r/KcZT9xPXQodH0oJ917Hbg== dependencies: "@sinonjs/commons" "^1.7.0" "@sinonjs/formatio" "^4.0.1" - "@sinonjs/samsam" "^4.2.1" - diff "^4.0.1" + "@sinonjs/samsam" "^4.2.2" + diff "^4.0.2" lolex "^5.1.2" nise "^3.0.1" supports-color "^7.1.0" @@ -7887,7 +7974,7 @@ snapdragon@^0.8.1: source-map-resolve "^0.5.0" use "^3.1.0" -socks-proxy-agent@^4.0.0: +socks-proxy-agent@^4.0.0, socks-proxy-agent@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz#3c8991f3145b2799e70e11bd5fbc8b1963116386" integrity sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg== @@ -8069,6 +8156,11 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" +"statuses@>= 1.5.0 < 2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= + stealthy-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" @@ -8183,6 +8275,11 @@ string_decoder@^1.1.1: dependencies: safe-buffer "~5.2.0" +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= + string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -8511,6 +8608,11 @@ through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= +thunkify@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d" + integrity sha1-+qDp0jDFGsyVyhOjYawFyn4EVT0= + tiny-glob@^0.2.6: version "0.2.6" resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.6.tgz#9e056e169d9788fe8a734dfa1ff02e9b92ed7eda" @@ -8566,6 +8668,11 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" +toidentifier@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" + integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== + tough-cookie@^2.3.3, tough-cookie@^2.3.4: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" @@ -8614,10 +8721,10 @@ trivial-deferred@^1.0.1: resolved "https://registry.yarnpkg.com/trivial-deferred/-/trivial-deferred-1.0.1.tgz#376d4d29d951d6368a6f7a0ae85c2f4d5e0658f3" integrity sha1-N21NKdlR1jaKb3oK6FwvTV4GWPM= -ts-jest@^24.2.0: - version "24.2.0" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.2.0.tgz#7abca28c2b4b0a1fdd715cd667d65d047ea4e768" - integrity sha512-Yc+HLyldlIC9iIK8xEN7tV960Or56N49MDP7hubCZUeI7EbIOTsas6rXCMB4kQjLACJ7eDOF4xWEO5qumpKsag== +ts-jest@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-24.3.0.tgz#b97814e3eab359ea840a1ac112deae68aa440869" + integrity sha512-Hb94C/+QRIgjVZlJyiWwouYUF+siNJHJHknyspaOcZ+OQAIdFG/UrdQVXw/0B8Z3No34xkUXZJpOTy9alOWdVQ== dependencies: bs-logger "0.x" buffer-from "1.x" @@ -8812,6 +8919,11 @@ universalify@^0.1.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +unpipe@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= + unset-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" @@ -8900,11 +9012,6 @@ validate-npm-package-name@^3.0.0: dependencies: builtins "^1.0.3" -vandium-utils@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/vandium-utils/-/vandium-utils-1.2.0.tgz#44735de4b7641a05de59ebe945f174e582db4f59" - integrity sha1-RHNd5LdkGgXeWevpRfF05YLbT1k= - verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" @@ -9159,6 +9266,11 @@ xmlbuilder@~9.0.1: resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0= +xregexp@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" + integrity sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM= + xregexp@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.2.4.tgz#02a4aea056d65a42632c02f0233eab8e4d7e57ed"