diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug-report.yml similarity index 56% rename from .github/ISSUE_TEMPLATE/bug.yml rename to .github/ISSUE_TEMPLATE/bug-report.yml index f77fa5beb193e..aa7f959e2ca80 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,44 +1,64 @@ -name: Bug Report +--- +name: "🐛 Bug Report" description: Report a bug -title: "(module name): short issue description" +title: "(module name): (short issue description)" labels: [bug, needs-triage] +assignees: [] body: - type: textarea - id: problem + id: description attributes: - label: What is the problem? + label: Describe the bug + description: What is the problem? A clear and concise description of the bug. validations: required: true - - type: textarea - id: reproduction + id: expected attributes: - label: Reproduction Steps + label: Expected Behavior description: | - Minimal amount of code that causes the bug (if possible) or a reference. - - The code sample should be an SSCCE. See http://sscce.org/ for details. - In short, provide a code sample that we can copy/paste, run and reproduce. + What did you expect to happen? validations: required: true - - type: textarea - id: expected + id: current attributes: - label: What did you expect to happen? + label: Current Behavior description: | - What were you trying to achieve by performing the steps above? + What actually happened? + + Please include full errors, uncaught exceptions, stack traces, and relevant logs. + If service responses are relevant, please include wire logs. validations: required: true - - type: textarea - id: actual + id: reproduction attributes: - label: What actually happened? + label: Reproduction Steps description: | - What is the unexpected behavior you were seeing? If you got an error, paste it here. + Provide a self-contained, concise snippet of code that can be used to reproduce the issue. + For more complex issues provide a repo with the smallest sample that reproduces the bug. + + Avoid including business logic or unrelated code, it makes diagnosis more difficult. + The code sample should be an SSCCE. See http://sscce.org/ for details. In short, please provide a code sample that we can copy/paste, run and reproduce. validations: required: true + - type: textarea + id: solution + attributes: + label: Possible Solution + description: | + Suggest a fix/reason for the bug + validations: + required: false + - type: textarea + id: context + attributes: + label: Additional Information/Context + description: | + Anything else that might be relevant for troubleshooting this bug. Providing context helps us come up with a solution that is most useful in the real world. + validations: + required: false - type: input id: cdk-version @@ -99,10 +119,3 @@ body: e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, slack, etc validations: required: false - - - type: markdown - attributes: - value: | - --- - - This is :bug: Bug Report diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index ebbc970f83c09..b4c0c5049128b 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,6 @@ +--- blank_issues_enabled: false contact_links: - - name: Stackoverflow - url: https://stackoverflow.com/questions/tagged/aws-cdk - about: Please ask and answer questions here. + - name: 💬 General Question + url: https://github.com/aws/aws-cdk/discussions/categories/q-a + about: Please ask and answer questions as a discussion thread \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/doc.yml b/.github/ISSUE_TEMPLATE/doc.yml deleted file mode 100644 index 974a752cac810..0000000000000 --- a/.github/ISSUE_TEMPLATE/doc.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Documentation Issue -description: Issue in the reference documentation or developer guide -title: "(module name): short issue description" -labels: [feature-request, documentation, needs-triage] -body: - - type: markdown - attributes: - value: | - Developer guide? Raise issue/pr here: https://github.com/awsdocs/aws-cdk-guide - - Want to help? Submit a pull request here: https://github.com/aws/aws-cdk - - - type: input - id: doc-link - attributes: - label: link to reference doc page - validations: - required: false - - - type: textarea - id: issue - attributes: - label: Describe your issue? - validations: - required: true - - - type: markdown - attributes: - value: | - --- - - This is a 📕 documentation issue diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000000000..c068514d136c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,23 @@ +--- +name: "📕 Documentation Issue" +description: Report an issue in the API Reference documentation or Developer Guide +title: "(short issue description)" +labels: [documentation, needs-triage] +assignees: [] +body: + - type: textarea + id: description + attributes: + label: Describe the issue + description: A clear and concise description of the issue. + validations: + required: true + + - type: textarea + id: links + attributes: + label: Links + description: | + Include links to affected documentation page(s). + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index a16053f420a82..23c385d1ef6d1 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,56 +1,59 @@ -name: Feature Request -description: Request a new feature -title: "(module name): short issue description" +--- +name: 🚀 Feature Request +description: Suggest an idea for this project +title: "(short issue description)" labels: [feature-request, needs-triage] +assignees: [] body: - type: textarea id: description attributes: - label: Description - description: Short description of the feature you are proposing. + label: Describe the feature + description: A clear and concise description of the feature you are proposing. validations: required: true - - type: textarea id: use-case attributes: label: Use Case description: | - Why do you need this feature? + Why do you need this feature? For example: "I'm always frustrated when..." validations: - required: true - + required: true - type: textarea id: solution attributes: label: Proposed Solution description: | - Please include prototype/workaround/sketch/reference implementation. + Suggest how to implement the addition or change. Please include prototype/workaround/sketch/reference implementation. validations: - required: true - + required: false - type: textarea id: other attributes: - label: Other information + label: Other Information description: | - e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, slack, etc + Any alternative solutions or features you considered, a more detailed explanation, stack traces, related issues, links for context, etc. validations: required: false - - type: checkboxes - id: acknowledgments + id: ack attributes: - label: Acknowledge + label: Acknowledgements options: - label: I may be able to implement this feature request required: false - label: This feature might incur a breaking change required: false - - - type: markdown + - type: input + id: sdk-version attributes: - value: | - --- - - This is a :rocket: Feature Request + label: CDK version used + validations: + required: true + - type: input + id: environment + attributes: + label: Environment details (OS name and version, etc.) + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/general-issue.yml b/.github/ISSUE_TEMPLATE/general-issue.yml deleted file mode 100644 index 61119a33a761c..0000000000000 --- a/.github/ISSUE_TEMPLATE/general-issue.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: General Issue -description: Create a new issue -title: "(module name): short issue description" -labels: [needs-triage, guidance] -body: - - type: markdown - attributes: - value: | - If there is an issue regarding developer guide, please create an issue [here](https://github.com/awsdocs/aws-cdk-guide/issues). - - - type: input - id: issue - attributes: - label: General Issue - description: | - For support questions, please first reference our [documentation](https://docs.aws.amazon.com/cdk/api/latest), then use [Stackoverflow](https://stackoverflow.com/questions/tagged/aws-cdk). This repository's issues are intended for feature requests and bug reports. - validations: - required: true - - - type: textarea - id: question - attributes: - label: The Question - description: | - Ask your question here. Include any details relevant. Make sure you are not falling prey to the [X/Y problem](http://xyproblem.info)! - validations: - required: true - - - type: input - id: cdk-version - attributes: - label: CDK CLI Version - description: Output of `cdk version` - validations: - required: true - - - type: input - id: framework-version - attributes: - label: Framework Version - validations: - required: false - - - type: input - id: node-version - attributes: - label: Node.js Version - validations: - required: false - - - type: input - id: operating-system - attributes: - label: OS - validations: - required: false - - - type: dropdown - id: language - attributes: - label: Language - multiple: true - options: - - Typescript - - Python - - .NET - - Java - - Go - validations: - required: true - - - type: input - id: language-version - attributes: - label: Language Version - description: E.g. TypeScript (3.8.3) | Java (8) | Python (3.7.3) - validations: - required: false - - - type: textarea - id: other - attributes: - label: Other information - description: | - e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, slack, etc - validations: - required: false diff --git a/.github/workflows/issue-label-assign.yml b/.github/workflows/issue-label-assign.yml index 14fe7ff0cde62..b38072a275697 100644 --- a/.github/workflows/issue-label-assign.yml +++ b/.github/workflows/issue-label-assign.yml @@ -3,9 +3,9 @@ on: issues: types: [opened, edited] pull_request: - types: [opened, edited] + types: [opened] pull_request_target: - types: [opened, edited] + types: [opened] jobs: issue-triage-manager: @@ -39,7 +39,7 @@ jobs: included-labels: "[guidance]" default-area: ${{ env.OSDS_DEVS }} parameters: > - [{"area":"guidance","keywords":["guidance"]}] + [{"area":"guidance","keywords":["guidancekeyword"]}] pr-triage-manager: permissions: issues: write @@ -51,9 +51,11 @@ jobs: github-token: "${{ secrets.GITHUB_TOKEN }}" target: "pull-requests" area-is-keyword: true - excluded-labels: "[contribution/core]" - parameters: ${{ env.AREA_PARAMS }} - affixes: ${{ env.AREA_AFFIXES }} + default-area: > + {"reviewers":{"teamReviewers":["aws-cdk-owners"]}} + parameters: > + [{"area":"pullrequests","keywords":["pullrequestkeyword"]}] + env: OSDS_DEVS: > diff --git a/CHANGELOG.md b/CHANGELOG.md index 1621fa309c36a..5c908f29e0c15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,30 @@ 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.151.0](https://github.com/aws/aws-cdk/compare/v1.150.0...v1.151.0) (2022-03-31) + + +### Features + +* **aws-ec2:** Enable/disable EC2 "Detailed Monitoring" ([#19437](https://github.com/aws/aws-cdk/issues/19437)) ([94f9d27](https://github.com/aws/aws-cdk/commit/94f9d27e626bced5fc68a6ebbd653fea21c6e21e)) +* **cognito:** configure SNS region for UserPool SMS messages ([#19519](https://github.com/aws/aws-cdk/issues/19519)) ([6eb775e](https://github.com/aws/aws-cdk/commit/6eb775e829d62913bff849d43ed7339f9910d8de)), closes [#19434](https://github.com/aws/aws-cdk/issues/19434) +* **core:** add size.isUnresolved ([#19569](https://github.com/aws/aws-cdk/issues/19569)) ([ed26731](https://github.com/aws/aws-cdk/commit/ed26731a0a6263482d76441fc06e9607963ac838)) +* **ecs-patterns:** PlacementStrategy and PlacementConstraint for many patterns ([#19612](https://github.com/aws/aws-cdk/issues/19612)) ([0096e67](https://github.com/aws/aws-cdk/commit/0096e672e02123a2ae4e094ba9bb11af3aef20b2)) +* **elbv2:** use `addAction()` on an imported application listener ([#19293](https://github.com/aws/aws-cdk/issues/19293)) ([18a6b0c](https://github.com/aws/aws-cdk/commit/18a6b0cecb5e8a419d09a1456953cb2f422a6d76)), closes [#10902](https://github.com/aws/aws-cdk/issues/10902) +* **kinesisanalytics-flink:** Add metrics to Flink applications ([#19599](https://github.com/aws/aws-cdk/issues/19599)) ([dab6aca](https://github.com/aws/aws-cdk/commit/dab6aca5005c8d6d180aada699a4cebc2ef5aefa)) +* **lambda:** warn if you use `function.grantInvoke` while also using `currentVersion` ([#19464](https://github.com/aws/aws-cdk/issues/19464)) ([fd1fff9](https://github.com/aws/aws-cdk/commit/fd1fff904a70d18dc9c7863aefc03b3ee44c2863)), closes [#19273](https://github.com/aws/aws-cdk/issues/19273) [#19318](https://github.com/aws/aws-cdk/issues/19318) + + +### Bug Fixes + +* **apigateway:** allow using GENERATE_IF_NEEDED for the physical name in LambdaRestApi ([#19638](https://github.com/aws/aws-cdk/issues/19638)) ([e817381](https://github.com/aws/aws-cdk/commit/e8173812aad5f482b1bfcc6737f63cfef0c4841c)), closes [#9374](https://github.com/aws/aws-cdk/issues/9374) +* **apigateway:** id in schema model maps to $id ([#15113](https://github.com/aws/aws-cdk/issues/15113)) ([ac5a345](https://github.com/aws/aws-cdk/commit/ac5a3458fe3687014166b20aefe30442867d162a)), closes [#14585](https://github.com/aws/aws-cdk/issues/14585) +* **aws-cognito:** Lambda::Permission of lambdaTrigger should have a SourceArn ([#19622](https://github.com/aws/aws-cdk/issues/19622)) ([c62eeb7](https://github.com/aws/aws-cdk/commit/c62eeb7162d85c8cb162f8c0ad4b93fb5bccf981)), closes [#19604](https://github.com/aws/aws-cdk/issues/19604) +* **docdb:** DB Instance ARN uses 'docdb' as the service component instead of 'rds' ([#19555](https://github.com/aws/aws-cdk/issues/19555)) ([6a63924](https://github.com/aws/aws-cdk/commit/6a63924c0b184342befd92903b8867e45b158252)), closes [#19554](https://github.com/aws/aws-cdk/issues/19554) +* **eks:** incorrect version of aws-node-termination-handler ([#19510](https://github.com/aws/aws-cdk/issues/19510)) ([9c712cc](https://github.com/aws/aws-cdk/commit/9c712cc457ccb80d7180fee67a101b76fc01d207)) +* **elbv2:** unable to add multiple certificates to NLB ([#19289](https://github.com/aws/aws-cdk/issues/19289)) ([e8142e9](https://github.com/aws/aws-cdk/commit/e8142e944ac5fae9948e5c010fe475806b83c94b)), closes [#13490](https://github.com/aws/aws-cdk/issues/13490) [#8918](https://github.com/aws/aws-cdk/issues/8918) [#15328](https://github.com/aws/aws-cdk/issues/15328) +* **rds:** `SnapshotCredentials.fromSecret()` takes a `Secret`, not `ISecret` ([#19639](https://github.com/aws/aws-cdk/issues/19639)) ([a74d82e](https://github.com/aws/aws-cdk/commit/a74d82e667ba3cfbb3341392f7c641b0e29d47f0)), closes [#19409](https://github.com/aws/aws-cdk/issues/19409) + ## [1.150.0](https://github.com/aws/aws-cdk/compare/v1.149.0...v1.150.0) (2022-03-26) diff --git a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts index e0252b377ddc9..a8b83e2395f68 100644 --- a/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts +++ b/packages/@aws-cdk/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts @@ -184,12 +184,31 @@ function renderCustomMetric(metric?: cloudwatch.IMetric): CfnScalingPolicy.Custo */ export enum PredefinedMetric { /** - * DYNAMODB_READ_CAPACITY_UTILIZATIO - * @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html + * Average percentage of instances in an AppStream fleet that are being used. + */ + APPSTREAM_AVERAGE_CAPACITY_UTILIZATION = 'AppStreamAverageCapacityUtilization', + /** + * Percentage of provisioned read capacity units utilized by a Keyspaces table. + */ + CASSANDRA_READ_CAPACITY_UTILIZATION = 'CassandraReadCapacityUtilization', + /** + * Percentage of provisioned write capacity units utilized by a Keyspaces table. + */ + CASSANDRA_WRITE_CAPACITY_UTILIZATION = 'CassandraWriteCapacityUtilization', + /** + * Percentage of provisioned inference units utilized by a Comprehend endpoint. + */ + COMPREHEND_INFERENCE_UTILIZATION = 'ComprehendInferenceUtilization', + /** + * Average CPU Utilization of read replica instances in a Neptune DB cluster. + */ + NEPTURE_READER_AVERAGE_CPU_UTILIZATION = 'NeptuneReaderAverageCPUUtilization', + /** + * Percentage of provisioned read capacity units consumed by a DynamoDB table. */ DYNAMODB_READ_CAPACITY_UTILIZATION = 'DynamoDBReadCapacityUtilization', /** - * DYNAMODB_WRITE_CAPACITY_UTILIZATION + * Percentage of provisioned write capacity units consumed by a DynamoDB table. * * Suffix `dummy` is necessary due to jsii bug (https://github.com/aws/jsii/issues/2782). * Duplicate values will be dropped, so this suffix is added as a workaround. diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.expected.json b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.expected.json new file mode 100644 index 0000000000000..f790c8ae78487 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.expected.json @@ -0,0 +1,38 @@ +{ + "Resources": { + "Service1EDCC8134": { + "Type": "AWS::AppRunner::Service", + "Properties": { + "SourceConfiguration": { + "AuthenticationConfiguration": {}, + "ImageRepository": { + "ImageConfiguration": { + "Port": "8000" + }, + "ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest", + "ImageRepositoryType": "ECR_PUBLIC" + } + }, + "InstanceConfiguration": {} + } + } + }, + "Outputs": { + "URL1": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::GetAtt": [ + "Service1EDCC8134", + "ServiceUrl" + ] + } + ] + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.ts b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.ts new file mode 100644 index 0000000000000..82d2c7c4794f1 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr-public.ts @@ -0,0 +1,18 @@ +import * as cdk from '@aws-cdk/core'; +import { Service, Source } from '../lib'; + + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'integ-apprunner-ecr-public'); + +// Scenario 1: Create the service from ECR public +const service1 = new Service(stack, 'Service1', { + source: Source.fromEcrPublic({ + imageConfiguration: { + port: 8000, + }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), +}); +new cdk.CfnOutput(stack, 'URL1', { value: `https://${service1.serviceUrl}` }); diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service.expected.json b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.expected.json similarity index 68% rename from packages/@aws-cdk/aws-apprunner/test/integ.service.expected.json rename to packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.expected.json index 9ca183c3ca56a..107dc235584de 100644 --- a/packages/@aws-cdk/aws-apprunner/test/integ.service.expected.json +++ b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.expected.json @@ -1,22 +1,6 @@ { "Resources": { - "Service1EDCC8134": { - "Type": "AWS::AppRunner::Service", - "Properties": { - "SourceConfiguration": { - "AuthenticationConfiguration": {}, - "ImageRepository": { - "ImageConfiguration": { - "Port": "8000" - }, - "ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest", - "ImageRepositoryType": "ECR_PUBLIC" - } - }, - "InstanceConfiguration": {} - } - }, - "Service2AccessRole759CA73D": { + "Service3AccessRole3ACBAAA0": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -33,7 +17,7 @@ } } }, - "Service2AccessRoleDefaultPolicy08C28479": { + "Service3AccessRoleDefaultPolicy57B9744E": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyDocument": { @@ -66,7 +50,7 @@ { "Ref": "AWS::AccountId" }, - ":repository/nginx" + ":repository/aws-cdk/assets" ] ] } @@ -74,29 +58,29 @@ ], "Version": "2012-10-17" }, - "PolicyName": "Service2AccessRoleDefaultPolicy08C28479", + "PolicyName": "Service3AccessRoleDefaultPolicy57B9744E", "Roles": [ { - "Ref": "Service2AccessRole759CA73D" + "Ref": "Service3AccessRole3ACBAAA0" } ] } }, - "Service2AB4D14D8": { + "Service342D067F2": { "Type": "AWS::AppRunner::Service", "Properties": { "SourceConfiguration": { "AuthenticationConfiguration": { "AccessRoleArn": { "Fn::GetAtt": [ - "Service2AccessRole759CA73D", + "Service3AccessRole3ACBAAA0", "Arn" ] } }, "ImageRepository": { "ImageConfiguration": { - "Port": "80" + "Port": "8000" }, "ImageIdentifier": { "Fn::Join": [ @@ -113,7 +97,7 @@ { "Ref": "AWS::URLSuffix" }, - "/nginx:latest" + "/aws-cdk/assets:77284835684772d19c95f4f5a37e7618d5f9efc40db9321d44ac039db457b967" ] ] }, @@ -123,7 +107,7 @@ "InstanceConfiguration": {} } }, - "Service3AccessRole3ACBAAA0": { + "Service2AccessRole759CA73D": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -140,7 +124,7 @@ } } }, - "Service3AccessRoleDefaultPolicy57B9744E": { + "Service2AccessRoleDefaultPolicy08C28479": { "Type": "AWS::IAM::Policy", "Properties": { "PolicyDocument": { @@ -181,29 +165,29 @@ ], "Version": "2012-10-17" }, - "PolicyName": "Service3AccessRoleDefaultPolicy57B9744E", + "PolicyName": "Service2AccessRoleDefaultPolicy08C28479", "Roles": [ { - "Ref": "Service3AccessRole3ACBAAA0" + "Ref": "Service2AccessRole759CA73D" } ] } }, - "Service342D067F2": { + "Service2AB4D14D8": { "Type": "AWS::AppRunner::Service", "Properties": { "SourceConfiguration": { "AuthenticationConfiguration": { "AccessRoleArn": { "Fn::GetAtt": [ - "Service3AccessRole3ACBAAA0", + "Service2AccessRole759CA73D", "Arn" ] } }, "ImageRepository": { "ImageConfiguration": { - "Port": "8000" + "Port": "80" }, "ImageIdentifier": { "Fn::Join": [ @@ -229,89 +213,9 @@ }, "InstanceConfiguration": {} } - }, - "Service429949929": { - "Type": "AWS::AppRunner::Service", - "Properties": { - "SourceConfiguration": { - "AuthenticationConfiguration": { - "ConnectionArn": "MOCK" - }, - "CodeRepository": { - "CodeConfiguration": { - "ConfigurationSource": "REPOSITORY" - }, - "RepositoryUrl": "https://github.com/aws-containers/hello-app-runner", - "SourceCodeVersion": { - "Type": "BRANCH", - "Value": "main" - } - } - }, - "InstanceConfiguration": {} - } - }, - "Service5AD92B5A5": { - "Type": "AWS::AppRunner::Service", - "Properties": { - "SourceConfiguration": { - "AuthenticationConfiguration": { - "ConnectionArn": "MOCK" - }, - "CodeRepository": { - "CodeConfiguration": { - "CodeConfigurationValues": { - "BuildCommand": "yum install -y pycairo && pip install -r requirements.txt", - "Port": "8000", - "Runtime": "PYTHON_3", - "StartCommand": "python app.py" - }, - "ConfigurationSource": "API" - }, - "RepositoryUrl": "https://github.com/aws-containers/hello-app-runner", - "SourceCodeVersion": { - "Type": "BRANCH", - "Value": "main" - } - } - }, - "InstanceConfiguration": {} - } } }, "Outputs": { - "URL1": { - "Value": { - "Fn::Join": [ - "", - [ - "https://", - { - "Fn::GetAtt": [ - "Service1EDCC8134", - "ServiceUrl" - ] - } - ] - ] - } - }, - "URL2": { - "Value": { - "Fn::Join": [ - "", - [ - "https://", - { - "Fn::GetAtt": [ - "Service2AB4D14D8", - "ServiceUrl" - ] - } - ] - ] - } - }, "URL3": { "Value": { "Fn::Join": [ @@ -328,23 +232,7 @@ ] } }, - "URL4": { - "Value": { - "Fn::Join": [ - "", - [ - "https://", - { - "Fn::GetAtt": [ - "Service429949929", - "ServiceUrl" - ] - } - ] - ] - } - }, - "URL5": { + "URL2": { "Value": { "Fn::Join": [ "", @@ -352,7 +240,7 @@ "https://", { "Fn::GetAtt": [ - "Service5AD92B5A5", + "Service2AB4D14D8", "ServiceUrl" ] } diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.ts b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.ts new file mode 100644 index 0000000000000..347cdced6ef4b --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner/test/integ.service-ecr.ts @@ -0,0 +1,32 @@ +import * as path from 'path'; +import * as assets from '@aws-cdk/aws-ecr-assets'; +import * as cdk from '@aws-cdk/core'; +import { Service, Source } from '../lib'; + + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'integ-apprunner'); + + +// Scenario 3: Create the service from local code assets +const imageAsset = new assets.DockerImageAsset(stack, 'ImageAssets', { + directory: path.join(__dirname, './docker.assets'), +}); +const service3 = new Service(stack, 'Service3', { + source: Source.fromAsset({ + imageConfiguration: { port: 8000 }, + asset: imageAsset, + }), +}); +new cdk.CfnOutput(stack, 'URL3', { value: `https://${service3.serviceUrl}` }); + +// Scenario 2: Create the service from existing ECR repository +const service2 = new Service(stack, 'Service2', { + source: Source.fromEcr({ + imageConfiguration: { port: 80 }, + repository: imageAsset.repository, + tag: imageAsset.assetHash, + }), +}); +new cdk.CfnOutput(stack, 'URL2', { value: `https://${service2.serviceUrl}` }); diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service-github.expected.json b/packages/@aws-cdk/aws-apprunner/test/integ.service-github.expected.json new file mode 100644 index 0000000000000..a30841a30e91c --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner/test/integ.service-github.expected.json @@ -0,0 +1,86 @@ +{ + "Resources": { + "Service429949929": { + "Type": "AWS::AppRunner::Service", + "Properties": { + "SourceConfiguration": { + "AuthenticationConfiguration": { + "ConnectionArn": "MOCK" + }, + "CodeRepository": { + "CodeConfiguration": { + "ConfigurationSource": "REPOSITORY" + }, + "RepositoryUrl": "https://github.com/aws-containers/hello-app-runner", + "SourceCodeVersion": { + "Type": "BRANCH", + "Value": "main" + } + } + }, + "InstanceConfiguration": {} + } + }, + "Service5AD92B5A5": { + "Type": "AWS::AppRunner::Service", + "Properties": { + "SourceConfiguration": { + "AuthenticationConfiguration": { + "ConnectionArn": "MOCK" + }, + "CodeRepository": { + "CodeConfiguration": { + "CodeConfigurationValues": { + "BuildCommand": "yum install -y pycairo && pip install -r requirements.txt", + "Port": "8000", + "Runtime": "PYTHON_3", + "StartCommand": "python app.py" + }, + "ConfigurationSource": "API" + }, + "RepositoryUrl": "https://github.com/aws-containers/hello-app-runner", + "SourceCodeVersion": { + "Type": "BRANCH", + "Value": "main" + } + } + }, + "InstanceConfiguration": {} + } + } + }, + "Outputs": { + "URL4": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::GetAtt": [ + "Service429949929", + "ServiceUrl" + ] + } + ] + ] + } + }, + "URL5": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::GetAtt": [ + "Service5AD92B5A5", + "ServiceUrl" + ] + } + ] + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service-github.ts b/packages/@aws-cdk/aws-apprunner/test/integ.service-github.ts new file mode 100644 index 0000000000000..8813865f04259 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner/test/integ.service-github.ts @@ -0,0 +1,35 @@ +import * as cdk from '@aws-cdk/core'; +import { Service, Source, GitHubConnection, ConfigurationSourceType, Runtime } from '../lib'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'integ-apprunner'); + +// Scenario 4: Create the service from Github. Make sure you specify a valid connection ARN. +const connectionArn = process.env.CONNECTION_ARN || 'MOCK'; +const service4 = new Service(stack, 'Service4', { + source: Source.fromGitHub({ + repositoryUrl: 'https://github.com/aws-containers/hello-app-runner', + branch: 'main', + configurationSource: ConfigurationSourceType.REPOSITORY, + connection: GitHubConnection.fromConnectionArn(connectionArn), + }), +}); +new cdk.CfnOutput(stack, 'URL4', { value: `https://${service4.serviceUrl}` }); + +// Scenario 5: Create the service from Github with configuration values override. +const service5 = new Service(stack, 'Service5', { + source: Source.fromGitHub({ + repositoryUrl: 'https://github.com/aws-containers/hello-app-runner', + branch: 'main', + configurationSource: ConfigurationSourceType.API, + codeConfigurationValues: { + runtime: Runtime.PYTHON_3, + port: '8000', + startCommand: 'python app.py', + buildCommand: 'yum install -y pycairo && pip install -r requirements.txt', + }, + connection: GitHubConnection.fromConnectionArn(connectionArn), + }), +}); +new cdk.CfnOutput(stack, 'URL5', { value: `https://${service5.serviceUrl}` }); diff --git a/packages/@aws-cdk/aws-apprunner/test/integ.service.ts b/packages/@aws-cdk/aws-apprunner/test/integ.service.ts deleted file mode 100644 index 2df2dab9301aa..0000000000000 --- a/packages/@aws-cdk/aws-apprunner/test/integ.service.ts +++ /dev/null @@ -1,71 +0,0 @@ -import * as path from 'path'; -import * as ecr from '@aws-cdk/aws-ecr'; -import * as assets from '@aws-cdk/aws-ecr-assets'; -import * as cdk from '@aws-cdk/core'; -import { Service, Source, GitHubConnection, ConfigurationSourceType, Runtime } from '../lib'; - - -const app = new cdk.App(); - -const stack = new cdk.Stack(app, 'integ-apprunner'); - -// Scenario 1: Create the service from ECR public -const service1 = new Service(stack, 'Service1', { - source: Source.fromEcrPublic({ - imageConfiguration: { - port: 8000, - }, - imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', - }), -}); -new cdk.CfnOutput(stack, 'URL1', { value: `https://${service1.serviceUrl}` }); - -// Scenario 2: Create the service from existing ECR repository, make sure you have `nginx` ECR repo in your account. -const service2 = new Service(stack, 'Service2', { - source: Source.fromEcr({ - imageConfiguration: { port: 80 }, - repository: ecr.Repository.fromRepositoryName(stack, 'NginxRepository', 'nginx'), - }), -}); -new cdk.CfnOutput(stack, 'URL2', { value: `https://${service2.serviceUrl}` }); - -// Scenario 3: Create the service from local code assets -const imageAsset = new assets.DockerImageAsset(stack, 'ImageAssets', { - directory: path.join(__dirname, './docker.assets'), -}); -const service3 = new Service(stack, 'Service3', { - source: Source.fromAsset({ - imageConfiguration: { port: 8000 }, - asset: imageAsset, - }), -}); -new cdk.CfnOutput(stack, 'URL3', { value: `https://${service3.serviceUrl}` }); - -// Scenario 4: Create the service from Github. Make sure you specify a valid connection ARN. -const connectionArn = stack.node.tryGetContext('CONNECTION_ARN') || 'MOCK'; -const service4 = new Service(stack, 'Service4', { - source: Source.fromGitHub({ - repositoryUrl: 'https://github.com/aws-containers/hello-app-runner', - branch: 'main', - configurationSource: ConfigurationSourceType.REPOSITORY, - connection: GitHubConnection.fromConnectionArn(connectionArn), - }), -}); -new cdk.CfnOutput(stack, 'URL4', { value: `https://${service4.serviceUrl}` }); - -// Scenario 5: Create the service from Github with configuration values override. -const service5 = new Service(stack, 'Service5', { - source: Source.fromGitHub({ - repositoryUrl: 'https://github.com/aws-containers/hello-app-runner', - branch: 'main', - configurationSource: ConfigurationSourceType.API, - codeConfigurationValues: { - runtime: Runtime.PYTHON_3, - port: '8000', - startCommand: 'python app.py', - buildCommand: 'yum install -y pycairo && pip install -r requirements.txt', - }, - connection: GitHubConnection.fromConnectionArn(connectionArn), - }), -}); -new cdk.CfnOutput(stack, 'URL5', { value: `https://${service5.serviceUrl}` }); diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.expected.json b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.expected.json index 9307879bca924..5fc5a888c4c11 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.expected.json +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.expected.json @@ -1,9 +1,9 @@ { "Resources": { "Bucket83908E77": { - "DeletionPolicy": "Delete", + "Type": "AWS::S3::Bucket", "UpdateReplacePolicy": "Delete", - "Type": "AWS::S3::Bucket" + "DeletionPolicy": "Delete" }, "MyDistributionCFDistributionDE147309": { "Type": "AWS::CloudFront::Distribution", @@ -18,6 +18,7 @@ "GET", "HEAD" ], + "Compress": true, "ForwardedValues": { "Cookies": { "Forward": "none" @@ -25,8 +26,7 @@ "QueryString": false }, "TargetOriginId": "origin1", - "ViewerProtocolPolicy": "redirect-to-https", - "Compress": true + "ViewerProtocolPolicy": "redirect-to-https" }, "DefaultRootObject": "index.html", "Enabled": true, @@ -47,17 +47,20 @@ } ], "PriceClass": "PriceClass_100", - "ViewerCertificate": { - "CloudFrontDefaultCertificate": true - }, "Restrictions": { "GeoRestriction": { - "Locations": ["US", "UK"], + "Locations": [ + "US", + "GB" + ], "RestrictionType": "whitelist" } + }, + "ViewerCertificate": { + "CloudFrontDefaultCertificate": true } } } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.ts b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.ts index 7f90fff25740e..b89fee939cb4c 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-geo-restrictions.ts @@ -19,7 +19,7 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', { behaviors: [{ isDefaultBehavior: true }], }, ], - geoRestriction: cloudfront.GeoRestriction.allowlist('US', 'UK'), + geoRestriction: cloudfront.GeoRestriction.allowlist('US', 'GB'), }); app.synth(); diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.expected.json b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.expected.json index 8759a3b629e14..d8528288e52d0 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.expected.json +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.expected.json @@ -52,7 +52,7 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "LambdaServiceRoleA8ED4D3B" diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.ts b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.ts index 83eea22f40cef..6427b28195c51 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-lambda-association.ts @@ -14,7 +14,7 @@ const sourceBucket = new s3.Bucket(stack, 'Bucket', { const lambdaFunction = new lambda.Function(stack, 'Lambda', { code: lambda.Code.fromInline('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); const lambdaVersion = new lambda.Version(stack, 'LambdaVersion', { diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.expected.json b/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.expected.json index d87415745eed9..301d18dd22920 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.expected.json +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.expected.json @@ -47,13 +47,13 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "LambdaServiceRoleA8ED4D3B" ] }, - "LambdaCurrentVersionDF706F6A25bf7d67df4eb614ea2e1ea69c8759b6": { + "LambdaCurrentVersionDF706F6A9a632a294ae3a9cd4d550f1c4e26619d": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { @@ -72,7 +72,7 @@ { "EventType": "origin-request", "LambdaFunctionARN": { - "Ref": "LambdaCurrentVersionDF706F6A25bf7d67df4eb614ea2e1ea69c8759b6" + "Ref": "LambdaCurrentVersionDF706F6A9a632a294ae3a9cd4d550f1c4e26619d" } } ], diff --git a/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.ts b/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.ts index b6da02f0fa860..c277e93f4a678 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/integ.distribution-lambda.ts @@ -9,7 +9,7 @@ const stack = new cdk.Stack(app, 'integ-distribution-lambda', { env: { region: ' const lambdaFunction = new lambda.Function(stack, 'Lambda', { code: lambda.Code.fromInline('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); new cloudfront.Distribution(stack, 'Dist', { diff --git a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.expected.json b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.expected.json index e115d5360fee6..f8a12f1430107 100644 --- a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.expected.json +++ b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.expected.json @@ -2,9 +2,177 @@ "Resources": { "Bucket83908E77": { "Type": "AWS::S3::Bucket", + "Properties": { + "Tags": [ + { + "Key": "aws-cdk:auto-delete-objects", + "Value": "true" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "BucketPolicyE9A3008A": { + "Type": "AWS::S3::BucketPolicy", + "Properties": { + "Bucket": { + "Ref": "Bucket83908E77" + }, + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:DeleteObject*", + "s3:GetBucket*", + "s3:List*" + ], + "Effect": "Allow", + "Principal": { + "AWS": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092", + "Arn" + ] + } + }, + "Resource": [ + { + "Fn::GetAtt": [ + "Bucket83908E77", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "Bucket83908E77", + "Arn" + ] + }, + "/*" + ] + ] + } + ] + } + ], + "Version": "2012-10-17" + } + } + }, + "BucketAutoDeleteObjectsCustomResourceBAFD23C2": { + "Type": "Custom::S3AutoDeleteObjects", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F", + "Arn" + ] + }, + "BucketName": { + "Ref": "Bucket83908E77" + } + }, + "DependsOn": [ + "BucketPolicyE9A3008A" + ], "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ] + } + }, + "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232" + }, + "S3Key": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE" + } + ] + } + ] + } + ] + ] + } + }, + "Timeout": 900, + "MemorySize": 128, + "Handler": "__entrypoint__.handler", + "Role": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092", + "Arn" + ] + }, + "Runtime": "nodejs12.x", + "Description": { + "Fn::Join": [ + "", + [ + "Lambda function for auto-deleting objects in ", + { + "Ref": "Bucket83908E77" + }, + " S3 bucket." + ] + ] + } + }, + "DependsOn": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092" + ] + }, "LambdaFunctionServiceRoleC555A460": { "Type": "AWS::IAM::Role", "Properties": { @@ -49,7 +217,7 @@ ] }, "Handler": "hello.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "LambdaFunctionServiceRoleC555A460" @@ -57,8 +225,16 @@ }, "S3486F821D": { "Type": "AWS::S3::Bucket", - "UpdateReplacePolicy": "Retain", - "DeletionPolicy": "Retain" + "Properties": { + "Tags": [ + { + "Key": "aws-cdk:auto-delete-objects", + "Value": "true" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" }, "S3Policy2E4AA1D6": { "Type": "AWS::S3::BucketPolicy", @@ -68,6 +244,44 @@ }, "PolicyDocument": { "Statement": [ + { + "Action": [ + "s3:DeleteObject*", + "s3:GetBucket*", + "s3:List*" + ], + "Effect": "Allow", + "Principal": { + "AWS": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092", + "Arn" + ] + } + }, + "Resource": [ + { + "Fn::GetAtt": [ + "S3486F821D", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "S3486F821D", + "Arn" + ] + }, + "/*" + ] + ] + } + ] + }, { "Action": "s3:GetBucketAcl", "Effect": "Allow", @@ -116,6 +330,25 @@ } } }, + "S3AutoDeleteObjectsCustomResource5A4102C9": { + "Type": "Custom::S3AutoDeleteObjects", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F", + "Arn" + ] + }, + "BucketName": { + "Ref": "S3486F821D" + } + }, + "DependsOn": [ + "S3Policy2E4AA1D6" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, "Trail022F0CF2": { "Type": "AWS::CloudTrail::Trail", "Properties": { @@ -171,5 +404,19 @@ "S3Policy2E4AA1D6" ] } + }, + "Parameters": { + "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232": { + "Type": "String", + "Description": "S3 bucket for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\"" + }, + "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE": { + "Type": "String", + "Description": "S3 key for asset version \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\"" + }, + "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824ArtifactHash76F8FCF2": { + "Type": "String", + "Description": "Artifact hash for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\"" + } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.ts b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.ts index aeb9139462bb5..1e399351646d1 100644 --- a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.ts +++ b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail-supplied-bucket.lit.ts @@ -8,9 +8,12 @@ import * as cloudtrail from '../lib'; const app = new cdk.App(); const stack = new cdk.Stack(app, 'integ-cloudtrail'); -const bucket = new s3.Bucket(stack, 'Bucket', { removalPolicy: cdk.RemovalPolicy.DESTROY }); +const bucket = new s3.Bucket(stack, 'Bucket', { + removalPolicy: cdk.RemovalPolicy.DESTROY, + autoDeleteObjects: true, +}); const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', { - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, handler: 'hello.handler', code: lambda.Code.fromInline('exports.handler = {}'), }); @@ -18,7 +21,11 @@ const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', { // using exctecy the same code as inside the cloudtrail class to produce the supplied bucket and policy const cloudTrailPrincipal = new iam.ServicePrincipal('cloudtrail.amazonaws.com'); -const Trailbucket = new s3.Bucket(stack, 'S3', { encryption: s3.BucketEncryption.UNENCRYPTED }); +const Trailbucket = new s3.Bucket(stack, 'S3', { + encryption: s3.BucketEncryption.UNENCRYPTED, + removalPolicy: cdk.RemovalPolicy.DESTROY, + autoDeleteObjects: true, +}); Trailbucket.addToResourcePolicy(new iam.PolicyStatement({ resources: [Trailbucket.bucketArn], diff --git a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.expected.json b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.expected.json index 90c9dd9724771..10acbfff90f7f 100644 --- a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.expected.json +++ b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.expected.json @@ -2,9 +2,177 @@ "Resources": { "Bucket83908E77": { "Type": "AWS::S3::Bucket", + "Properties": { + "Tags": [ + { + "Key": "aws-cdk:auto-delete-objects", + "Value": "true" + } + ] + }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, + "BucketPolicyE9A3008A": { + "Type": "AWS::S3::BucketPolicy", + "Properties": { + "Bucket": { + "Ref": "Bucket83908E77" + }, + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:DeleteObject*", + "s3:GetBucket*", + "s3:List*" + ], + "Effect": "Allow", + "Principal": { + "AWS": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092", + "Arn" + ] + } + }, + "Resource": [ + { + "Fn::GetAtt": [ + "Bucket83908E77", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "Bucket83908E77", + "Arn" + ] + }, + "/*" + ] + ] + } + ] + } + ], + "Version": "2012-10-17" + } + } + }, + "BucketAutoDeleteObjectsCustomResourceBAFD23C2": { + "Type": "Custom::S3AutoDeleteObjects", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F", + "Arn" + ] + }, + "BucketName": { + "Ref": "Bucket83908E77" + } + }, + "DependsOn": [ + "BucketPolicyE9A3008A" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ] + } + }, + "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232" + }, + "S3Key": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE" + } + ] + } + ] + } + ] + ] + } + }, + "Timeout": 900, + "MemorySize": 128, + "Handler": "__entrypoint__.handler", + "Role": { + "Fn::GetAtt": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092", + "Arn" + ] + }, + "Runtime": "nodejs12.x", + "Description": { + "Fn::Join": [ + "", + [ + "Lambda function for auto-deleting objects in ", + { + "Ref": "Bucket83908E77" + }, + " S3 bucket." + ] + ] + } + }, + "DependsOn": [ + "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092" + ] + }, "TopicBFC7AF6E": { "Type": "AWS::SNS::Topic" }, @@ -71,14 +239,14 @@ "Code": { "ZipFile": "exports.handler = {}" }, - "Handler": "hello.handler", "Role": { "Fn::GetAtt": [ "LambdaFunctionServiceRoleC555A460", "Arn" ] }, - "Runtime": "nodejs10.x" + "Handler": "hello.handler", + "Runtime": "nodejs14.x" }, "DependsOn": [ "LambdaFunctionServiceRoleC555A460" @@ -240,5 +408,19 @@ "TrailS3PolicyE42170FE" ] } + }, + "Parameters": { + "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232": { + "Type": "String", + "Description": "S3 bucket for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\"" + }, + "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE": { + "Type": "String", + "Description": "S3 key for asset version \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\"" + }, + "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824ArtifactHash76F8FCF2": { + "Type": "String", + "Description": "Artifact hash for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\"" + } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.ts b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.ts index 8aeb2aab84eae..8280f7f797a44 100644 --- a/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.ts +++ b/packages/@aws-cdk/aws-cloudtrail/test/integ.cloudtrail.lit.ts @@ -7,10 +7,13 @@ import * as cloudtrail from '../lib'; const app = new cdk.App(); const stack = new cdk.Stack(app, 'integ-cloudtrail'); -const bucket = new s3.Bucket(stack, 'Bucket', { removalPolicy: cdk.RemovalPolicy.DESTROY }); +const bucket = new s3.Bucket(stack, 'Bucket', { + removalPolicy: cdk.RemovalPolicy.DESTROY, + autoDeleteObjects: true, +}); const topic = new sns.Topic(stack, 'Topic'); const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', { - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, handler: 'hello.handler', code: lambda.Code.fromInline('exports.handler = {}'), }); diff --git a/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.expected.json b/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.expected.json index e9b096abe09f9..1686127fc7771 100644 --- a/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.expected.json +++ b/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.expected.json @@ -79,13 +79,13 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "HandlerServiceRoleFCDC14AE" ] }, - "HandlerCurrentVersion93FB80BFb2de9794fd0f0df5e5c01c16ba4b05cf": { + "HandlerCurrentVersion93FB80BFb2a9ce598bf2730613c07e406cddb6b6": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { @@ -101,7 +101,7 @@ }, "FunctionVersion": { "Fn::GetAtt": [ - "HandlerCurrentVersion93FB80BFb2de9794fd0f0df5e5c01c16ba4b05cf", + "HandlerCurrentVersion93FB80BFb2a9ce598bf2730613c07e406cddb6b6", "Version" ] }, @@ -250,7 +250,7 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "PreHookServiceRoleDefaultPolicy65358F76", @@ -383,7 +383,7 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "PostHookServiceRoleDefaultPolicy82AEE758", diff --git a/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.ts b/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.ts index ced2c76f4d447..4464fd9fc9a21 100644 --- a/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.ts +++ b/packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.ts @@ -11,7 +11,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-lambda'); const handler = new lambda.Function(stack, 'Handler', { code: lambda.Code.fromAsset(path.join(__dirname, 'handler')), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); const version = handler.currentVersion; const blueGreenAlias = new lambda.Alias(stack, 'Alias', { @@ -22,12 +22,12 @@ const blueGreenAlias = new lambda.Alias(stack, 'Alias', { const preHook = new lambda.Function(stack, 'PreHook', { code: lambda.Code.fromAsset(path.join(__dirname, 'preHook')), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); const postHook = new lambda.Function(stack, 'PostHook', { code: lambda.Code.fromAsset(path.join(__dirname, 'postHook')), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); new codedeploy.LambdaDeploymentGroup(stack, 'BlueGreenDeployment', { diff --git a/packages/@aws-cdk/aws-eks/README.md b/packages/@aws-cdk/aws-eks/README.md index 001a2cbb3022a..ad531945ba3c1 100644 --- a/packages/@aws-cdk/aws-eks/README.md +++ b/packages/@aws-cdk/aws-eks/README.md @@ -539,7 +539,7 @@ To deploy the controller on your EKS cluster, configure the `albController` prop new eks.Cluster(this, 'HelloEKS', { version: eks.KubernetesVersion.V1_21, albController: { - version: eks.AlbControllerVersion.V2_3_1, + version: eks.AlbControllerVersion.V2_4_1, }, }); ``` @@ -1417,7 +1417,7 @@ Kubernetes [endpoint access](#endpoint-access), you must also specify: ## Logging -EKS supports cluster logging for 5 different types of events: +EKS supports cluster logging for 5 different types of events: * API requests to the cluster. * Cluster access via the Kubernetes API. diff --git a/packages/@aws-cdk/aws-eks/lib/addons/alb-iam_policy-v2.4.1.json b/packages/@aws-cdk/aws-eks/lib/addons/alb-iam_policy-v2.4.1.json new file mode 100644 index 0000000000000..a8d47c8ba68c2 --- /dev/null +++ b/packages/@aws-cdk/aws-eks/lib/addons/alb-iam_policy-v2.4.1.json @@ -0,0 +1,219 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "iam:CreateServiceLinkedRole" + ], + "Resource": "*", + "Condition": { + "StringEquals": { + "iam:AWSServiceName": "elasticloadbalancing.amazonaws.com" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "ec2:DescribeAccountAttributes", + "ec2:DescribeAddresses", + "ec2:DescribeAvailabilityZones", + "ec2:DescribeInternetGateways", + "ec2:DescribeVpcs", + "ec2:DescribeVpcPeeringConnections", + "ec2:DescribeSubnets", + "ec2:DescribeSecurityGroups", + "ec2:DescribeInstances", + "ec2:DescribeNetworkInterfaces", + "ec2:DescribeTags", + "ec2:GetCoipPoolUsage", + "ec2:DescribeCoipPools", + "elasticloadbalancing:DescribeLoadBalancers", + "elasticloadbalancing:DescribeLoadBalancerAttributes", + "elasticloadbalancing:DescribeListeners", + "elasticloadbalancing:DescribeListenerCertificates", + "elasticloadbalancing:DescribeSSLPolicies", + "elasticloadbalancing:DescribeRules", + "elasticloadbalancing:DescribeTargetGroups", + "elasticloadbalancing:DescribeTargetGroupAttributes", + "elasticloadbalancing:DescribeTargetHealth", + "elasticloadbalancing:DescribeTags" + ], + "Resource": "*" + }, + { + "Effect": "Allow", + "Action": [ + "cognito-idp:DescribeUserPoolClient", + "acm:ListCertificates", + "acm:DescribeCertificate", + "iam:ListServerCertificates", + "iam:GetServerCertificate", + "waf-regional:GetWebACL", + "waf-regional:GetWebACLForResource", + "waf-regional:AssociateWebACL", + "waf-regional:DisassociateWebACL", + "wafv2:GetWebACL", + "wafv2:GetWebACLForResource", + "wafv2:AssociateWebACL", + "wafv2:DisassociateWebACL", + "shield:GetSubscriptionState", + "shield:DescribeProtection", + "shield:CreateProtection", + "shield:DeleteProtection" + ], + "Resource": "*" + }, + { + "Effect": "Allow", + "Action": [ + "ec2:AuthorizeSecurityGroupIngress", + "ec2:RevokeSecurityGroupIngress" + ], + "Resource": "*" + }, + { + "Effect": "Allow", + "Action": [ + "ec2:CreateSecurityGroup" + ], + "Resource": "*" + }, + { + "Effect": "Allow", + "Action": [ + "ec2:CreateTags" + ], + "Resource": "arn:aws:ec2:*:*:security-group/*", + "Condition": { + "StringEquals": { + "ec2:CreateAction": "CreateSecurityGroup" + }, + "Null": { + "aws:RequestTag/elbv2.k8s.aws/cluster": "false" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "ec2:CreateTags", + "ec2:DeleteTags" + ], + "Resource": "arn:aws:ec2:*:*:security-group/*", + "Condition": { + "Null": { + "aws:RequestTag/elbv2.k8s.aws/cluster": "true", + "aws:ResourceTag/elbv2.k8s.aws/cluster": "false" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "ec2:AuthorizeSecurityGroupIngress", + "ec2:RevokeSecurityGroupIngress", + "ec2:DeleteSecurityGroup" + ], + "Resource": "*", + "Condition": { + "Null": { + "aws:ResourceTag/elbv2.k8s.aws/cluster": "false" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:CreateLoadBalancer", + "elasticloadbalancing:CreateTargetGroup" + ], + "Resource": "*", + "Condition": { + "Null": { + "aws:RequestTag/elbv2.k8s.aws/cluster": "false" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:CreateListener", + "elasticloadbalancing:DeleteListener", + "elasticloadbalancing:CreateRule", + "elasticloadbalancing:DeleteRule" + ], + "Resource": "*" + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:AddTags", + "elasticloadbalancing:RemoveTags" + ], + "Resource": [ + "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*", + "arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*", + "arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*" + ], + "Condition": { + "Null": { + "aws:RequestTag/elbv2.k8s.aws/cluster": "true", + "aws:ResourceTag/elbv2.k8s.aws/cluster": "false" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:AddTags", + "elasticloadbalancing:RemoveTags" + ], + "Resource": [ + "arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*", + "arn:aws:elasticloadbalancing:*:*:listener/app/*/*/*", + "arn:aws:elasticloadbalancing:*:*:listener-rule/net/*/*/*", + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/*/*/*" + ] + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:ModifyLoadBalancerAttributes", + "elasticloadbalancing:SetIpAddressType", + "elasticloadbalancing:SetSecurityGroups", + "elasticloadbalancing:SetSubnets", + "elasticloadbalancing:DeleteLoadBalancer", + "elasticloadbalancing:ModifyTargetGroup", + "elasticloadbalancing:ModifyTargetGroupAttributes", + "elasticloadbalancing:DeleteTargetGroup" + ], + "Resource": "*", + "Condition": { + "Null": { + "aws:ResourceTag/elbv2.k8s.aws/cluster": "false" + } + } + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:RegisterTargets", + "elasticloadbalancing:DeregisterTargets" + ], + "Resource": "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*" + }, + { + "Effect": "Allow", + "Action": [ + "elasticloadbalancing:SetWebAcl", + "elasticloadbalancing:ModifyListener", + "elasticloadbalancing:AddListenerCertificates", + "elasticloadbalancing:RemoveListenerCertificates", + "elasticloadbalancing:ModifyRule" + ], + "Resource": "*" + } + ] +} diff --git a/packages/@aws-cdk/aws-eks/lib/alb-controller.ts b/packages/@aws-cdk/aws-eks/lib/alb-controller.ts index 7841f581990c2..d2df1dc1bf688 100644 --- a/packages/@aws-cdk/aws-eks/lib/alb-controller.ts +++ b/packages/@aws-cdk/aws-eks/lib/alb-controller.ts @@ -82,6 +82,11 @@ export class AlbControllerVersion { */ public static readonly V2_3_1 = new AlbControllerVersion('v2.3.1', false); + /** + * v2.4.1 + */ + public static readonly V2_4_1 = new AlbControllerVersion('v2.4.1', false); + /** * Specify a custom version. * Use this if the version you need is not available in one of the predefined versions. @@ -101,7 +106,7 @@ export class AlbControllerVersion { /** * Whether or not its a custom version. */ - public readonly custom: boolean) {} + public readonly custom: boolean) { } } /** diff --git a/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts b/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts index 66d2d3f0ff1fd..db5403acc4483 100644 --- a/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts +++ b/packages/@aws-cdk/aws-eks/test/alb-controller.test.ts @@ -36,7 +36,7 @@ test('can configure a custom repository', () => { AlbController.create(stack, { cluster, - version: AlbControllerVersion.V2_3_1, + version: AlbControllerVersion.V2_4_1, repository: 'custom', }); @@ -53,7 +53,7 @@ test('can configure a custom repository', () => { { Ref: 'ClusterDefaultVpcFA9F2722', }, - '","image":{"repository":"custom","tag":"v2.3.1"}}', + '","image":{"repository":"custom","tag":"v2.4.1"}}', ], ], }, diff --git a/packages/@aws-cdk/aws-eks/test/cluster.test.ts b/packages/@aws-cdk/aws-eks/test/cluster.test.ts index 5e579c4f2a247..e2887ad82b5e4 100644 --- a/packages/@aws-cdk/aws-eks/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-eks/test/cluster.test.ts @@ -27,7 +27,7 @@ describe('cluster', () => { const cluster = new eks.Cluster(stack, 'Cluster', { version: CLUSTER_VERSION, albController: { - version: eks.AlbControllerVersion.V2_3_1, + version: eks.AlbControllerVersion.V2_4_1, }, }); diff --git a/packages/@aws-cdk/aws-eks/test/integ.alb-controller.expected.json b/packages/@aws-cdk/aws-eks/test/integ.alb-controller.expected.json index b8bc3541bb0cd..0cad0a02b111b 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.alb-controller.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.alb-controller.expected.json @@ -1615,7 +1615,7 @@ { "Ref": "Vpc8378EB38" }, - "\",\"image\":{\"repository\":\"602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-load-balancer-controller\",\"tag\":\"v2.3.1\"}}" + "\",\"image\":{\"repository\":\"602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-load-balancer-controller\",\"tag\":\"v2.4.1\"}}" ] ] }, diff --git a/packages/@aws-cdk/aws-eks/test/integ.alb-controller.ts b/packages/@aws-cdk/aws-eks/test/integ.alb-controller.ts index 2fdd7ef81899b..c0f52416279b1 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.alb-controller.ts +++ b/packages/@aws-cdk/aws-eks/test/integ.alb-controller.ts @@ -19,7 +19,7 @@ class EksClusterAlbControllerStack extends TestStack { vpc, version: eks.KubernetesVersion.V1_21, albController: { - version: eks.AlbControllerVersion.V2_3_1, + version: eks.AlbControllerVersion.V2_4_1, }, }); diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-inference.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-inference.expected.json index ea0f68dd56ea8..7576e0c311ff5 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-inference.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-inference.expected.json @@ -1980,7 +1980,7 @@ { "Ref": "Vpc8378EB38" }, - "\",\"image\":{\"repository\":\"602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-load-balancer-controller\",\"tag\":\"v2.3.1\"}}" + "\",\"image\":{\"repository\":\"602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-load-balancer-controller\",\"tag\":\"v2.4.1\"}}" ] ] }, diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-inference.ts b/packages/@aws-cdk/aws-eks/test/integ.eks-inference.ts index 13057cdaadbfa..0ea30b491a9f8 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-inference.ts +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-inference.ts @@ -16,7 +16,7 @@ class EksClusterInferenceStack extends TestStack { vpc, version: eks.KubernetesVersion.V1_21, albController: { - version: eks.AlbControllerVersion.V2_3_1, + version: eks.AlbControllerVersion.V2_4_1, }, }); diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts index 52bfd666a0ed4..86b8593f3e8ac 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts @@ -508,6 +508,21 @@ export interface IApplicationListener extends IResource, ec2.IConnectable { * Don't call this directly. It is called by ApplicationTargetGroup. */ registerConnectable(connectable: ec2.IConnectable, portRange: ec2.Port): void; + + /** + * Perform the given action on incoming requests + * + * This allows full control of the default action of the load balancer, + * including Action chaining, fixed responses and redirect responses. See + * the `ListenerAction` class for all options. + * + * It's possible to add routing conditions to the Action added in this way. + * + * It is not possible to add a default action to an imported IApplicationListener. + * In order to add actions to an imported IApplicationListener a `priority` + * must be provided. + */ + addAction(id: string, props: AddApplicationActionProps): void; } /** @@ -627,6 +642,36 @@ abstract class ExternalApplicationListener extends Resource implements IApplicat // eslint-disable-next-line max-len throw new Error('Can only call addTargets() when using a constructed ApplicationListener; construct a new TargetGroup and use addTargetGroup.'); } + + /** + * Perform the given action on incoming requests + * + * This allows full control of the default action of the load balancer, + * including Action chaining, fixed responses and redirect responses. See + * the `ListenerAction` class for all options. + * + * It's possible to add routing conditions to the Action added in this way. + * + * It is not possible to add a default action to an imported IApplicationListener. + * In order to add actions to an imported IApplicationListener a `priority` + * must be provided. + */ + public addAction(id: string, props: AddApplicationActionProps): void { + checkAddRuleProps(props); + + if (props.priority !== undefined) { + // New rule + // + // TargetGroup.registerListener is called inside ApplicationListenerRule. + new ApplicationListenerRule(this, id + 'Rule', { + listener: this, + priority: props.priority, + ...props, + }); + } else { + throw new Error('priority must be set for actions added to an imported listener'); + } + } } /** diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener-certificate.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener-certificate.ts new file mode 100644 index 0000000000000..da8175962e49e --- /dev/null +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener-certificate.ts @@ -0,0 +1,43 @@ +import { Construct } from 'constructs'; +import { CfnListenerCertificate } from '../elasticloadbalancingv2.generated'; +import { IListenerCertificate } from '../shared/listener-certificate'; +import { INetworkListener } from './network-listener'; + +// keep this import separate from other imports to reduce chance for merge conflicts with v2-main +// eslint-disable-next-line no-duplicate-imports, import/order +import { Construct as CoreConstruct } from '@aws-cdk/core'; + +/** + * Properties for adding a set of certificates to a listener + */ +export interface NetworkListenerCertificateProps { + /** + * The listener to attach the rule to + */ + readonly listener: INetworkListener; + + /** + * Certificates to attach + * + * Duplicates are not allowed. + */ + readonly certificates: IListenerCertificate[]; +} + +/** + * Add certificates to a listener + */ +export class NetworkListenerCertificate extends CoreConstruct { + constructor(scope: Construct, id: string, props: NetworkListenerCertificateProps) { + super(scope, id); + + const certificates = [ + ...(props.certificates || []).map(c => ({ certificateArn: c.certificateArn })), + ]; + + new CfnListenerCertificate(this, 'Resource', { + listenerArn: props.listener.listenerArn, + certificates, + }); + } +} diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener.ts index d48dbafc8202a..df043d06282b7 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/nlb/network-listener.ts @@ -1,5 +1,5 @@ import * as cxschema from '@aws-cdk/cloud-assembly-schema'; -import { Duration, IResource, Resource } from '@aws-cdk/core'; +import { Duration, IResource, Resource, Lazy } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { BaseListener, BaseListenerLookupOptions } from '../shared/base-listener'; import { HealthCheck } from '../shared/base-target-group'; @@ -7,6 +7,7 @@ import { AlpnPolicy, Protocol, SslPolicy } from '../shared/enums'; import { IListenerCertificate } from '../shared/listener-certificate'; import { validateNetworkProtocol } from '../shared/util'; import { NetworkListenerAction } from './network-listener-action'; +import { NetworkListenerCertificate } from './network-listener-certificate'; import { INetworkLoadBalancer } from './network-load-balancer'; import { INetworkLoadBalancerTarget, INetworkTargetGroup, NetworkTargetGroup } from './network-target-group'; @@ -160,6 +161,11 @@ export class NetworkListener extends BaseListener implements INetworkListener { */ public readonly loadBalancer: INetworkLoadBalancer; + /** + * ARNs of certificates added to this listener + */ + private readonly certificateArns: string[]; + /** * the protocol of the listener */ @@ -188,13 +194,17 @@ export class NetworkListener extends BaseListener implements INetworkListener { protocol: proto, port: props.port, sslPolicy: props.sslPolicy, - certificates: props.certificates, + certificates: Lazy.any({ produce: () => this.certificateArns.map(certificateArn => ({ certificateArn })) }, { omitEmptyArray: true }), alpnPolicy: props.alpnPolicy ? [props.alpnPolicy] : undefined, }); + this.certificateArns = []; this.loadBalancer = props.loadBalancer; this.protocol = proto; + if (certs.length > 0) { + this.addCertificates('DefaultCertificates', certs); + } if (props.defaultAction && props.defaultTargetGroups) { throw new Error('Specify at most one of \'defaultAction\' and \'defaultTargetGroups\''); } @@ -208,6 +218,29 @@ export class NetworkListener extends BaseListener implements INetworkListener { } } + /** + * Add one or more certificates to this listener. + * + * After the first certificate, this creates NetworkListenerCertificates + * resources since cloudformation requires the certificates array on the + * listener resource to have a length of 1. + */ + public addCertificates(id: string, certificates: IListenerCertificate[]): void { + const additionalCerts = [...certificates]; + if (this.certificateArns.length === 0 && additionalCerts.length > 0) { + const first = additionalCerts.splice(0, 1)[0]; + this.certificateArns.push(first.certificateArn); + } + // Only one certificate can be specified per resource, even though + // `certificates` is of type Array + for (let i = 0; i < additionalCerts.length; i++) { + new NetworkListenerCertificate(this, `${id}${i + 1}`, { + listener: this, + certificates: [additionalCerts[i]], + }); + } + } + /** * Load balance incoming requests to the given target groups. * diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts index 5caf1f756dd80..4167e012d6c4b 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts @@ -707,6 +707,85 @@ describe('tests', () => { }); }); + test('Can add actions to an imported listener', () => { + // GIVEN + const stack = new cdk.Stack(); + const stack2 = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + const lb = new elbv2.ApplicationLoadBalancer(stack, 'LoadBalancer', { + vpc, + }); + const listener = lb.addListener('Listener', { + port: 80, + }); + + // WHEN + listener.addAction('Default', { + action: elbv2.ListenerAction.fixedResponse(404, { + contentType: 'text/plain', + messageBody: 'Not Found', + }), + }); + + const importedListener = elbv2.ApplicationListener.fromApplicationListenerAttributes(stack2, 'listener', { + listenerArn: 'listener-arn', + defaultPort: 443, + securityGroup: ec2.SecurityGroup.fromSecurityGroupId(stack2, 'SG', 'security-group-id', { + allowAllOutbound: false, + }), + }); + importedListener.addAction('Hello', { + action: elbv2.ListenerAction.fixedResponse(503), + conditions: [elbv2.ListenerCondition.pathPatterns(['/hello'])], + priority: 10, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', { + DefaultActions: [ + { + FixedResponseConfig: { + ContentType: 'text/plain', + MessageBody: 'Not Found', + StatusCode: '404', + }, + Type: 'fixed-response', + }, + ], + }); + + Template.fromStack(stack2).hasResourceProperties('AWS::ElasticLoadBalancingV2::ListenerRule', { + ListenerArn: 'listener-arn', + Priority: 10, + Actions: [ + { + FixedResponseConfig: { + StatusCode: '503', + }, + Type: 'fixed-response', + }, + ], + }); + }); + + test('actions added to an imported listener must have a priority', () => { + // GIVEN + const stack = new cdk.Stack(); + + const importedListener = elbv2.ApplicationListener.fromApplicationListenerAttributes(stack, 'listener', { + listenerArn: 'listener-arn', + defaultPort: 443, + securityGroup: ec2.SecurityGroup.fromSecurityGroupId(stack, 'SG', 'security-group-id', { + allowAllOutbound: false, + }), + }); + expect(() => { + importedListener.addAction('Hello', { + action: elbv2.ListenerAction.fixedResponse(503), + }); + }).toThrow(/priority must be set for actions added to an imported listener/); + }); + testDeprecated('Can add redirect responses', () => { // GIVEN const stack = new cdk.Stack(); diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts index b92df26e76bb7..d5343c559d623 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/listener.test.ts @@ -416,6 +416,62 @@ describe('tests', () => { })).toThrow(/Protocol must be TLS when certificates have been specified/); }); + test('Can pass multiple certificates to network listener constructor', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'Stack'); + const lb = new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc }); + + // WHEN + lb.addListener('Listener', { + port: 443, + certificates: [ + importedCertificate(stack, 'cert1'), + importedCertificate(stack, 'cert2'), + ], + defaultTargetGroups: [new elbv2.NetworkTargetGroup(stack, 'Group', { vpc, port: 80 })], + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', { + Protocol: 'TLS', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::ListenerCertificate', { + Certificates: [{ CertificateArn: 'cert2' }], + }); + }); + + test('Can add multiple certificates to network listener after construction', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'Stack'); + const lb = new elbv2.NetworkLoadBalancer(stack, 'LB', { vpc }); + + // WHEN + const listener = lb.addListener('Listener', { + port: 443, + certificates: [ + importedCertificate(stack, 'cert1'), + ], + defaultTargetGroups: [new elbv2.NetworkTargetGroup(stack, 'Group', { vpc, port: 80 })], + }); + + listener.addCertificates('extra', [ + importedCertificate(stack, 'cert2'), + ]); + + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::Listener', { + Protocol: 'TLS', + }); + + Template.fromStack(stack).hasResourceProperties('AWS::ElasticLoadBalancingV2::ListenerCertificate', { + Certificates: [{ CertificateArn: 'cert2' }], + }); + }); + test('not allowed to specify defaultTargetGroups and defaultAction together', () => { // GIVEN const stack = new cdk.Stack(); @@ -462,3 +518,8 @@ class ResourceWithLBDependency extends cdk.CfnResource { this.node.addDependency(targetGroup.loadBalancerAttached); } } + +function importedCertificate(stack: cdk.Stack, + certificateArn = 'arn:aws:certificatemanager:123456789012:testregion:certificate/fd0b8392-3c0e-4704-81b6-8edf8612c852') { + return acm.Certificate.fromCertificateArn(stack, certificateArn, certificateArn); +} diff --git a/packages/@aws-cdk/aws-lambda/README.md b/packages/@aws-cdk/aws-lambda/README.md index 9c9182b174550..e5cc514c9d365 100644 --- a/packages/@aws-cdk/aws-lambda/README.md +++ b/packages/@aws-cdk/aws-lambda/README.md @@ -710,6 +710,24 @@ const fn = new lambda.Function(this, 'MyLambda', { }); ``` +## Ephemeral Storage + +You can configure ephemeral storage on a function to control the amount of storage it gets for reading +or writing data, allowing you to use AWS Lambda for ETL jobs, ML inference, or other data-intensive workloads. +The ephemeral storage will be accessible in the functions' `/tmp` directory. + +```ts +import { Size } from '@aws-cdk/core'; + +const fn = new lambda.Function(this, 'MyFunction', { + runtime: lambda.Runtime.NODEJS_14_X, + handler: 'index.handler', + code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')), + ephemeralStorageSize: Size.mebibytes(1024), +}); +``` + +Read more about using this feature in [this AWS blog post](https://aws.amazon.com/blogs/aws/aws-lambda-now-supports-up-to-10-gb-ephemeral-storage/). ## Singleton Function diff --git a/packages/@aws-cdk/aws-lambda/lib/function.ts b/packages/@aws-cdk/aws-lambda/lib/function.ts index 6bc89845edf3b..904fe515e5a7c 100644 --- a/packages/@aws-cdk/aws-lambda/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda/lib/function.ts @@ -6,7 +6,7 @@ import * as kms from '@aws-cdk/aws-kms'; import * as logs from '@aws-cdk/aws-logs'; import * as sns from '@aws-cdk/aws-sns'; import * as sqs from '@aws-cdk/aws-sqs'; -import { Annotations, ArnFormat, CfnResource, Duration, Fn, Lazy, Names, Stack, Token } from '@aws-cdk/core'; +import { Annotations, ArnFormat, CfnResource, Duration, Fn, Lazy, Names, Size, Stack, Token } from '@aws-cdk/core'; import { Construct } from 'constructs'; import { Architecture } from './architecture'; import { Code, CodeConfig } from './code'; @@ -95,6 +95,13 @@ export interface FunctionOptions extends EventInvokeConfigOptions { */ readonly memorySize?: number; + /** + * The size of the function’s /tmp directory in MB. + * + * @default 512 MiB + */ + readonly ephemeralStorageSize?: Size; + /** * Initial policy statements to add to the created Lambda Role. * @@ -747,6 +754,11 @@ export class Function extends FunctionBase { } this._architecture = props.architecture ?? (props.architectures && props.architectures[0]); + if (props.ephemeralStorageSize && !props.ephemeralStorageSize.isUnresolved() + && (props.ephemeralStorageSize.toMebibytes() < 512 || props.ephemeralStorageSize.toMebibytes() > 10240)) { + throw new Error(`Ephemeral storage size must be between 512 and 10240 MB, received ${props.ephemeralStorageSize}.`); + } + const resource: CfnFunction = new CfnFunction(this, 'Resource', { functionName: this.physicalName, description: props.description, @@ -767,6 +779,9 @@ export class Function extends FunctionBase { // Token, actually *modifies* the 'environment' map. environment: Lazy.uncachedAny({ produce: () => this.renderEnvironment() }), memorySize: props.memorySize, + ephemeralStorage: props.ephemeralStorageSize ? { + size: props.ephemeralStorageSize.toMebibytes(), + } : undefined, vpcConfig: this.configureVpc(props), deadLetterConfig: this.buildDeadLetterConfig(dlqTopicOrQueue), tracingConfig: this.buildTracingConfig(props), diff --git a/packages/@aws-cdk/aws-lambda/test/code.test.ts b/packages/@aws-cdk/aws-lambda/test/code.test.ts index 76e771596d735..9bd03c3082ae8 100644 --- a/packages/@aws-cdk/aws-lambda/test/code.test.ts +++ b/packages/@aws-cdk/aws-lambda/test/code.test.ts @@ -301,7 +301,7 @@ describe('code', () => { { Ref: 'AWS::Region' }, '.', { Ref: 'AWS::URLSuffix' }, - '/aws-cdk/assets:f0fe8a410cb4b860a25f6f3e09237abf69cd38ab59f9ef2441597c75f598c634', + '/aws-cdk/assets:768d7b6c1d41b85135f498fe0cca69fea410be3c3322c69cf08690aaad29a610', ]], }, }, @@ -384,7 +384,7 @@ describe('code', () => { // then Template.fromStack(stack).hasResource('AWS::Lambda::Function', { Metadata: { - [cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.650a009a909c30e767a843a84ff7812616447251d245e0ab65d9bfb37f413e32', + [cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.dd84d39b518e69c0e62a55312372cdd9ab3ef901c74a4861d92e951215257b3c', [cxapi.ASSET_RESOURCE_METADATA_DOCKERFILE_PATH_KEY]: dockerfilePath, [cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_ARGS_KEY]: dockerBuildArgs, [cxapi.ASSET_RESOURCE_METADATA_DOCKER_BUILD_TARGET_KEY]: dockerBuildTarget, @@ -408,7 +408,7 @@ describe('code', () => { // then Template.fromStack(stack).hasResource('AWS::Lambda::Function', { Metadata: { - [cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.a3cc4528c34874616814d9b3436ff0e5d01514c1d563ed8899657ca00982f308', + [cxapi.ASSET_RESOURCE_METADATA_PATH_KEY]: 'asset.b7767e24de8d852617d9600e7a60395334454ca017d648f93b2d990aec7f50fd', [cxapi.ASSET_RESOURCE_METADATA_DOCKERFILE_PATH_KEY]: 'Dockerfile', [cxapi.ASSET_RESOURCE_METADATA_PROPERTY_KEY]: 'Code.ImageUri', }, diff --git a/packages/@aws-cdk/aws-lambda/test/docker-lambda-handler/Dockerfile b/packages/@aws-cdk/aws-lambda/test/docker-lambda-handler/Dockerfile index 18064bbe78ba1..f03af5f73f1a5 100644 --- a/packages/@aws-cdk/aws-lambda/test/docker-lambda-handler/Dockerfile +++ b/packages/@aws-cdk/aws-lambda/test/docker-lambda-handler/Dockerfile @@ -1,8 +1,8 @@ -FROM 628053151772.dkr.ecr.sa-east-1.amazonaws.com/awslambda/nodejs12.x-runtime-internal:beta +FROM public.ecr.aws/lambda/nodejs:12 ARG FUNCTION_DIR="/var/task" # Create function directory RUN mkdir -p ${FUNCTION_DIR} # Copy handler function and package.json COPY app.js ${FUNCTION_DIR} # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) -CMD [ "app.handler" ] \ No newline at end of file +CMD [ "app.handler" ] diff --git a/packages/@aws-cdk/aws-lambda/test/function.test.ts b/packages/@aws-cdk/aws-lambda/test/function.test.ts index fd9a175d93fb2..f22216222baa2 100644 --- a/packages/@aws-cdk/aws-lambda/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda/test/function.test.ts @@ -15,6 +15,7 @@ import * as cdk from '@aws-cdk/core'; import * as constructs from 'constructs'; import * as _ from 'lodash'; import * as lambda from '../lib'; +import { Lazy, Size } from '@aws-cdk/core'; describe('function', () => { test('default function', () => { @@ -2584,6 +2585,7 @@ describe('function', () => { architectures: [lambda.Architecture.X86_64, lambda.Architecture.ARM_64], })).toThrow(/one architecture must be specified/); }); + test('Architecture is properly readable from the function', () => { const stack = new cdk.Stack(); const fn = new lambda.Function(stack, 'MyFunction', { @@ -2635,6 +2637,50 @@ describe('function', () => { }); }); +test('throws if ephemeral storage size is out of bound', () => { + const stack = new cdk.Stack(); + expect(() => new lambda.Function(stack, 'MyLambda', { + code: new lambda.InlineCode('foo'), + handler: 'bar', + runtime: lambda.Runtime.NODEJS_14_X, + ephemeralStorageSize: Size.mebibytes(511), + })).toThrow(/Ephemeral storage size must be between 512 and 10240 MB/); +}); + +test('set ephemeral storage to desired size', () => { + const stack = new cdk.Stack(); + new lambda.Function(stack, 'MyLambda', { + code: new lambda.InlineCode('foo'), + handler: 'bar', + runtime: lambda.Runtime.NODEJS_14_X, + ephemeralStorageSize: Size.mebibytes(1024), + }); + + Template.fromStack(stack).hasResource('AWS::Lambda::Function', { + Properties: + { + Code: { ZipFile: 'foo' }, + Handler: 'bar', + Runtime: 'nodejs14.x', + EphemeralStorage: { + Size: 1024, + }, + }, + }); +}); + +test('ephemeral storage allows unresolved tokens', () => { + const stack = new cdk.Stack(); + expect(() => { + new lambda.Function(stack, 'MyLambda', { + code: new lambda.InlineCode('foo'), + handler: 'bar', + runtime: lambda.Runtime.NODEJS_14_X, + ephemeralStorageSize: Size.mebibytes(Lazy.number({ produce: () => 1024 })), + }); + }).not.toThrow(); +}); + function newTestLambda(scope: constructs.Construct) { return new lambda.Function(scope, 'MyLambda', { code: new lambda.InlineCode('foo'), diff --git a/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.expected.json index 1ee05ac72cef8..bb6ee0277bb99 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.expected.json @@ -37,20 +37,20 @@ "Code": { "ZipFile": "exports.handler = async () => { console.log('hello world'); };" }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "MyLambdaServiceRole4539ECB6", "Arn" ] }, - "Runtime": "nodejs10.x" + "Handler": "index.handler", + "Runtime": "nodejs14.x" }, "DependsOn": [ "MyLambdaServiceRole4539ECB6" ] }, - "MyLambdaCurrentVersionE7A382CC03fc10af301b823dc69dee9357b5caa0": { + "MyLambdaCurrentVersionE7A382CCc9b5d5d60612e848a9b7c670d8802822": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { @@ -66,7 +66,7 @@ }, "FunctionVersion": { "Fn::GetAtt": [ - "MyLambdaCurrentVersionE7A382CC03fc10af301b823dc69dee9357b5caa0", + "MyLambdaCurrentVersionE7A382CCc9b5d5d60612e848a9b7c670d8802822", "Version" ] }, @@ -160,4 +160,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.ts b/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.ts index e8d3411b072f3..ec6387c230c1a 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.autoscaling.lit.ts @@ -14,7 +14,7 @@ class TestStack extends cdk.Stack { const fn = new lambda.Function(this, 'MyLambda', { code: new lambda.InlineCode('exports.handler = async () => { console.log(\'hello world\'); };'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); const version = fn.currentVersion; diff --git a/packages/@aws-cdk/aws-lambda/test/integ.lambda.docker.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.lambda.docker.expected.json index 6affea556c9d9..d7f68ed5f5a1f 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.lambda.docker.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.lambda.docker.expected.json @@ -50,7 +50,7 @@ { "Ref": "AWS::URLSuffix" }, - "/aws-cdk/assets:f0fe8a410cb4b860a25f6f3e09237abf69cd38ab59f9ef2441597c75f598c634" + "/aws-cdk/assets:768d7b6c1d41b85135f498fe0cca69fea410be3c3322c69cf08690aaad29a610" ] ] } diff --git a/packages/@aws-cdk/aws-lambda/test/integ.lambda.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.lambda.expected.json index 88e7b53442a15..a6928d7344a66 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.lambda.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.lambda.expected.json @@ -58,21 +58,21 @@ "Code": { "ZipFile": "foo" }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "MyLambdaServiceRole4539ECB6", "Arn" ] }, - "Runtime": "nodejs10.x" + "Handler": "index.handler", + "Runtime": "nodejs14.x" }, "DependsOn": [ "MyLambdaServiceRoleDefaultPolicy5BBC6F68", "MyLambdaServiceRole4539ECB6" ] }, - "MyLambdaCurrentVersionE7A382CC306b64ef431b3e873cc6258340b63a78": { + "MyLambdaCurrentVersionE7A382CCaab0ffd2d3271bb29338c3fe7c7f3151": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { @@ -88,7 +88,7 @@ }, "FunctionVersion": { "Fn::GetAtt": [ - "MyLambdaCurrentVersionE7A382CC306b64ef431b3e873cc6258340b63a78", + "MyLambdaCurrentVersionE7A382CCaab0ffd2d3271bb29338c3fe7c7f3151", "Version" ] }, diff --git a/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.expected.json index 15a57b7a0e598..668799ec1d170 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.expected.json @@ -58,21 +58,21 @@ "Code": { "ZipFile": "exports.handler = async function(event, context) { console.log(\"Hello from CDK! with Alias Provisioned Concurrent Exec!\");}" }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "MyLambdaAliasPCEServiceRoleF7C9F212", "Arn" ] }, - "Runtime": "nodejs10.x" + "Handler": "index.handler", + "Runtime": "nodejs14.x" }, "DependsOn": [ "MyLambdaAliasPCEServiceRoleDefaultPolicyE7418D56", "MyLambdaAliasPCEServiceRoleF7C9F212" ] }, - "MyLambdaAliasPCECurrentVersion072335D3974767ca5ab9a8786a5779ede8cb8cc5": { + "MyLambdaAliasPCECurrentVersion072335D3f742c0f8cc0b7f48bb32fb34b63bc22c": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { @@ -88,7 +88,7 @@ }, "FunctionVersion": { "Fn::GetAtt": [ - "MyLambdaAliasPCECurrentVersion072335D3974767ca5ab9a8786a5779ede8cb8cc5", + "MyLambdaAliasPCECurrentVersion072335D3f742c0f8cc0b7f48bb32fb34b63bc22c", "Version" ] }, @@ -166,21 +166,21 @@ "Code": { "ZipFile": "exports.handler = async function(event, context) { console.log(\"Hello from CDK! with Version Provisioned Concurrent Exec!\");}" }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "MyLambdaVersionPCEServiceRole2ACFB73E", "Arn" ] }, - "Runtime": "nodejs10.x" + "Handler": "index.handler", + "Runtime": "nodejs14.x" }, "DependsOn": [ "MyLambdaVersionPCEServiceRoleDefaultPolicy229A1552", "MyLambdaVersionPCEServiceRole2ACFB73E" ] }, - "MyLambdaVersionPCECurrentVersion27FC3932a1bc5d5d20600bf4225d17df43a36ea5": { + "MyLambdaVersionPCECurrentVersion27FC3932fbc6188ae863cb6dc15d61f96ad00420": { "Type": "AWS::Lambda::Version", "Properties": { "FunctionName": { @@ -199,7 +199,7 @@ }, "FunctionVersion": { "Fn::GetAtt": [ - "MyLambdaVersionPCECurrentVersion27FC3932a1bc5d5d20600bf4225d17df43a36ea5", + "MyLambdaVersionPCECurrentVersion27FC3932fbc6188ae863cb6dc15d61f96ad00420", "Version" ] }, diff --git a/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.ts b/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.ts index 4a100b4d6e462..dde4a27d84ceb 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.lambda.prov.concurrent.ts @@ -15,7 +15,7 @@ const pce = 5; const fn = new lambda.Function(stack, 'MyLambdaAliasPCE', { code: new lambda.InlineCode(lambdaCode.replace('#type#', 'Alias')), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); fn.addToRolePolicy(new iam.PolicyStatement({ @@ -39,7 +39,7 @@ alias.addPermission('AliasPermission', { const fnVersionPCE = new lambda.Function(stack, 'MyLambdaVersionPCE', { code: new lambda.InlineCode(lambdaCode.replace('#type#', 'Version')), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, currentVersionOptions: { provisionedConcurrentExecutions: pce, }, diff --git a/packages/@aws-cdk/aws-lambda/test/integ.lambda.ts b/packages/@aws-cdk/aws-lambda/test/integ.lambda.ts index c6ca7302a1f91..1dc7ec07b6cfd 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.lambda.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.lambda.ts @@ -9,7 +9,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-lambda-1'); const fn = new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, }); fn.addToRolePolicy(new iam.PolicyStatement({ diff --git a/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.expected.json index 93687882379f7..0c6e5b2d4447a 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.expected.json @@ -42,7 +42,7 @@ } }, "CompatibleRuntimes": [ - "nodejs10.x" + "nodejs14.x" ], "Description": "A layer to test the L2 construct", "LicenseInfo": "Apache-2.0" @@ -97,19 +97,19 @@ "Code": { "ZipFile": "foo" }, - "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "MyLayeredLambdaServiceRole1A7DC118", "Arn" ] }, - "Runtime": "nodejs10.x", + "Handler": "index.handler", "Layers": [ { "Ref": "MyLayer38944FA5" } - ] + ], + "Runtime": "nodejs14.x" }, "DependsOn": [ "MyLayeredLambdaServiceRole1A7DC118" @@ -130,4 +130,4 @@ "Description": "Artifact hash for asset \"8811a2632ac5564a08fd269e159298f7e497f259578b0dc5e927a1f48ab24d34\"" } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.ts b/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.ts index d26722365c72e..49ba7c75a8675 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.layer-version.lit.ts @@ -12,7 +12,7 @@ const awsAccountId = stack.account; /// !show const layer = new lambda.LayerVersion(stack, 'MyLayer', { code: lambda.Code.fromAsset(path.join(__dirname, 'layer-code')), - compatibleRuntimes: [lambda.Runtime.NODEJS_10_X], + compatibleRuntimes: [lambda.Runtime.NODEJS_14_X], license: 'Apache-2.0', description: 'A layer to test the L2 construct', }); @@ -26,7 +26,7 @@ layer.addPermission('remote-account-grant', { accountId: awsAccountId }); new lambda.Function(stack, 'MyLayeredLambda', { code: new lambda.InlineCode('foo'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, layers: [layer], }); /// !hide diff --git a/packages/@aws-cdk/aws-lambda/test/integ.log-retention.expected.json b/packages/@aws-cdk/aws-lambda/test/integ.log-retention.expected.json index 1765faee07465..8aafc5fe25b04 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.log-retention.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.log-retention.expected.json @@ -44,7 +44,7 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "OneWeekServiceRole05A6F9F8" @@ -227,7 +227,7 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "OneMonthServiceRoleFBD1064F" @@ -300,7 +300,7 @@ ] }, "Handler": "index.handler", - "Runtime": "nodejs10.x" + "Runtime": "nodejs14.x" }, "DependsOn": [ "OneYearServiceRole24D47762" diff --git a/packages/@aws-cdk/aws-lambda/test/integ.log-retention.ts b/packages/@aws-cdk/aws-lambda/test/integ.log-retention.ts index 7b4901f651252..965a04c5597d6 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.log-retention.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.log-retention.ts @@ -10,21 +10,21 @@ const stack = new cdk.Stack(app, 'aws-cdk-lambda-log-retention'); new lambda.Function(stack, 'OneWeek', { code: new lambda.InlineCode('exports.handler = (event) => console.log(JSON.stringify(event));'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, logRetention: logs.RetentionDays.ONE_WEEK, }); new lambda.Function(stack, 'OneMonth', { code: new lambda.InlineCode('exports.handler = (event) => console.log(JSON.stringify(event));'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, logRetention: logs.RetentionDays.ONE_MONTH, }); new lambda.Function(stack, 'OneYear', { code: new lambda.InlineCode('exports.handler = (event) => console.log(JSON.stringify(event));'), handler: 'index.handler', - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_14_X, logRetention: logs.RetentionDays.ONE_YEAR, }); 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 index 2a6f6c964822b..ccc1856ef6196 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json +++ b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.expected.json @@ -1,55 +1,5 @@ { "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\" }" - }, - "Role": { - "Fn::GetAtt": [ - "NODEJS10XServiceRole2FD24B65", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs10.x" - }, - "DependsOn": [ - "NODEJS10XServiceRole2FD24B65" - ] - }, "NODEJS12XServiceRole59E71436": { "Type": "AWS::IAM::Role", "Properties": { @@ -100,56 +50,6 @@ "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\"" - }, - "Role": { - "Fn::GetAtt": [ - "PYTHON27ServiceRoleF484A17D", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "python2.7" - }, - "DependsOn": [ - "PYTHON27ServiceRoleF484A17D" - ] - }, "PYTHON36ServiceRole814B3AD9": { "Type": "AWS::IAM::Role", "Properties": { @@ -402,21 +302,11 @@ } }, "Outputs": { - "NODEJS10XfunctionName": { - "Value": { - "Ref": "NODEJS10XF3831960" - } - }, "NODEJS12XfunctionName": { "Value": { "Ref": "NODEJS12X8B8075A4" } }, - "PYTHON27functionName": { - "Value": { - "Ref": "PYTHON27F8E941FA" - } - }, "PYTHON36functionName": { "Value": { "Ref": "PYTHON364935EF15" diff --git a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts index ff6160da9ac27..0aff4e4ff02a8 100644 --- a/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts +++ b/packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts @@ -15,13 +15,6 @@ 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', @@ -29,13 +22,6 @@ const node12xfn = new Function(stack, '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', diff --git a/packages/@aws-cdk/aws-ssm/README.md b/packages/@aws-cdk/aws-ssm/README.md index 23fea31765525..880cc6b7b3322 100644 --- a/packages/@aws-cdk/aws-ssm/README.md +++ b/packages/@aws-cdk/aws-ssm/README.md @@ -30,7 +30,7 @@ import * as ssm from '@aws-cdk/aws-ssm'; ## Using existing SSM Parameters in your CDK app You can reference existing SSM Parameter Store values that you want to use in -your CDK app by using `ssm.ParameterStoreString`: +your CDK app by using `ssm.StringParameter.fromStringParameterAttributes`: [using SSM parameter](test/integ.parameter-store-string.lit.ts) diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/index.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/index.ts index 5fd6eb6ceda07..50c2dc35a5eab 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/index.ts +++ b/packages/@aws-cdk/cloud-assembly-schema/lib/index.ts @@ -1,4 +1,3 @@ export * from './cloud-assembly'; export * from './assets'; export * from './manifest'; -export * from './integ-tests'; diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/common.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/common.ts deleted file mode 100644 index 01ab969b63098..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/common.ts +++ /dev/null @@ -1,202 +0,0 @@ -/** - * In what scenarios should the CLI ask for approval - */ -export enum RequireApproval { - /** - * Never ask for approval - */ - NEVER = 'never', - - /** - * Prompt for approval for any type of change to the stack - */ - ANYCHANGE = 'any-change', - - /** - * Only prompt for approval if there are security related changes - */ - BROADENING = 'broadening' -} - -/** - * Default CDK CLI options that apply to all commands - */ -export interface DefaultCdkOptions { - /** - * List of stacks to deploy - * - * Requried if `all` is not set - * - * @default - [] - */ - readonly stacks?: string[]; - - /** - * Deploy all stacks - * - * Requried if `stacks` is not set - * - * @default - false - */ - readonly all?: boolean; - - /** - * command-line for executing your app or a cloud assembly directory - * e.g. "node bin/my-app.js" - * or - * "cdk.out" - * - * @default - read from cdk.json - */ - readonly app?: string; - - - /** - * Role to pass to CloudFormation for deployment - * - * @default - use the bootstrap cfn-exec role - */ - readonly roleArn?: string; - - /** - * Additional context - * - * @default - no additional context - */ - readonly context?: { [name: string]: string }; - - /** - * Print trace for stack warnings - * - * @default false - */ - readonly trace?: boolean; - - /** - * Do not construct stacks with warnings - * - * @default false - */ - readonly strict?: boolean; - - /** - * Perform context lookups. - * - * Synthesis fails if this is disabled and context lookups need - * to be performed - * - * @default true - */ - readonly lookups?: boolean; - - /** - * Ignores synthesis errors, which will likely produce an invalid output - * - * @default false - */ - readonly ignoreErrors?: boolean; - - /** - * Use JSON output instead of YAML when templates are printed - * to STDOUT - * - * @default false - */ - readonly json?: boolean; - - /** - * show debug logs - * - * @default false - */ - readonly verbose?: boolean; - - /** - * enable emission of additional debugging information, such as creation stack - * traces of tokens - * - * @default false - */ - readonly debug?: boolean; - - /** - * Use the indicated AWS profile as the default environment - * - * @default - no profile is used - */ - readonly profile?: string; - - /** - * Use the indicated proxy. Will read from - * HTTPS_PROXY environment if specified - * - * @default - no proxy - */ - readonly proxy?: string; - - /** - * Path to CA certificate to use when validating HTTPS - * requests. - * - * @default - read from AWS_CA_BUNDLE environment variable - */ - readonly caBundlePath?: string; - - /** - * Force trying to fetch EC2 instance credentials - * - * @default - guess EC2 instance status - */ - readonly ec2Creds?: boolean; - - /** - * Include "AWS::CDK::Metadata" resource in synthesized templates - * - * @default true - */ - readonly versionReporting?: boolean; - - /** - * Include "aws:cdk:path" CloudFormation metadata for each resource - * - * @default true - */ - readonly pathMetadata?: boolean; - - /** - * Include "aws:asset:*" CloudFormation metadata for resources that use assets - * - * @default true - */ - readonly assetMetadata?: boolean; - - /** - * Copy assets to the output directory - * - * Needed for local debugging the source files with SAM CLI - * - * @default false - */ - readonly staging?: boolean; - - /** - * Emits the synthesized cloud assembly into a directory - * - * @default cdk.out - */ - readonly output?: string; - - /** - * Show relevant notices - * - * @default true - */ - readonly notices?: boolean; - - /** - * Show colors and other style from console output - * - * @default true - */ - readonly color?: boolean; -} diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/deploy.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/deploy.ts deleted file mode 100644 index 09a20c610f12d..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/deploy.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { DefaultCdkOptions, RequireApproval } from './common'; - -/** - * Options to use with cdk deploy - */ -export interface DeployOptions extends DefaultCdkOptions { - /** - * Only perform action on the given stack - * - * @default false - */ - readonly exclusively?: boolean; - - /** - * Name of the toolkit stack to use/deploy - * - * @default CDKToolkit - */ - readonly toolkitStackName?: string; - - /** - * Reuse the assets with the given asset IDs - * - * @default - do not reuse assets - */ - readonly reuseAssets?: string[]; - - /** - * Optional name to use for the CloudFormation change set. - * If not provided, a name will be generated automatically. - * - * @default - auto generate a name - */ - readonly changeSetName?: string; - - /** - * Always deploy, even if templates are identical. - * @default false - */ - readonly force?: boolean; - - /** - * Rollback failed deployments - * - * @default true - */ - readonly rollback?: boolean; - - /** - * ARNs of SNS topics that CloudFormation will notify with stack related events - * - * @default - no notifications - */ - readonly notificationArns?: string[]; - - /** - * What kind of security changes require approval - * - * @default RequireApproval.Never - */ - readonly requireApproval?: RequireApproval; - - /** - * Whether to execute the ChangeSet - * Not providing `execute` parameter will result in execution of ChangeSet - * @default true - */ - readonly execute?: boolean; - - /** - * Additional parameters for CloudFormation at deploy time - * @default {} - */ - readonly parameters?: { [name: string]: string }; - - /** - * Use previous values for unspecified parameters - * - * If not set, all parameters must be specified for every deployment. - * - * @default true - */ - readonly usePreviousParameters?: boolean; - - /** - * Path to file where stack outputs will be written after a successful deploy as JSON - * @default - Outputs are not written to any file - */ - readonly outputsFile?: string; - - /** - * Whether we are on a CI system - * - * @default false - */ - readonly ci?: boolean; -} diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/destroy.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/destroy.ts deleted file mode 100644 index 9dfe8f267c6db..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/destroy.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { DefaultCdkOptions } from './common'; - -/** - * Options to use with cdk destroy - */ -export interface DestroyOptions extends DefaultCdkOptions { - /** - * Do not ask for permission before destroying stacks - * - * @default false - */ - readonly force?: boolean; - - /** - * Only destroy the given stack - * - * @default false - */ - readonly exclusively?: boolean; -} diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/index.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/index.ts deleted file mode 100644 index 528980446938b..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/commands/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './common'; -export * from './deploy'; -export * from './destroy'; diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/index.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/index.ts deleted file mode 100644 index 5a08e62a47958..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './schema'; -export * from './commands'; -export * from './test-case'; diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/schema.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/schema.ts deleted file mode 100644 index 4eccc8a6422b4..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { TestCase } from './test-case'; -/** - * Definitions for the integration testing manifest - */ -export interface IntegManifest { - /** - * Version of the manifest - */ - readonly version: string; - - /** - * Enable lookups for this test. If lookups are enabled - * then `stackUpdateWorkflow` must be set to false. - * Lookups should only be enabled when you are explicitely testing - * lookups. - * - * @default false - */ - readonly enableLookups?: boolean; - - /** - * test cases - */ - readonly testCases: { [testName: string]: TestCase }; -} - diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/test-case.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/test-case.ts deleted file mode 100644 index 6d3ecc05c626e..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/integ-tests/test-case.ts +++ /dev/null @@ -1,186 +0,0 @@ -import { DeployOptions, DestroyOptions } from './commands'; - -/** - * Represents an integration test test case - */ -export interface TestCase { - /** - * Stacks that should be tested as part of this test case - * The stackNames will be passed as args to the cdk commands - * so dependent stacks will be automatically deployed unless - * `exclusively` is passed - */ - readonly stacks: string[]; - - /** - * Run update workflow on this test case - * This should only be set to false to test scenarios - * that are not possible to test as part of the update workflow - * - * @default true - */ - readonly stackUpdateWorkflow?: boolean; - - /** - * Additional options to use for each CDK command - * - * @default - runner default options - */ - readonly cdkCommandOptions?: CdkCommands; - - /** - * Additional commands to run at predefined points in the test workflow - * - * e.g. { postDeploy: ['yarn', 'test'] } - * - * @default - no hooks - */ - readonly hooks?: Hooks; - - /** - * Whether or not to include asset hashes in the diff - * Asset hashes can introduces a lot of unneccessary noise into tests, - * but there are some cases where asset hashes _should_ be included. For example - * any tests involving custom resources or bundling - * - * @default false - */ - readonly diffAssets?: boolean; - - /** - * List of CloudFormation resource types in this stack that can - * be destroyed as part of an update without failing the test. - * - * This list should only include resources that for this specific - * integration test we are sure will not cause errors or an outage if - * destroyed. For example, maybe we know that a new resource will be created - * first before the old resource is destroyed which prevents any outage. - * - * e.g. ['AWS::IAM::Role'] - * - * @default - do not allow destruction of any resources on update - */ - readonly allowDestroy?: string[]; - - /** - * Limit deployment to these regions - * - * @default - can run in any region - */ - readonly regions?: string[]; -} - -/** - * Commands to run at predefined points during the - * integration test workflow - */ -export interface Hooks { - /** - * Commands to run prior to deploying the cdk stacks - * in the integration test - * - * @default - no commands - */ - readonly preDeploy?: string[]; - - /** - * Commands to run prior after deploying the cdk stacks - * in the integration test - * - * @default - no commands - */ - readonly postDeploy?: string[]; - - /** - * Commands to run prior to destroying the cdk stacks - * in the integration test - * - * @default - no commands - */ - readonly preDestroy?: string[]; - - /** - * Commands to run after destroying the cdk stacks - * in the integration test - * - * @default - no commands - */ - readonly postDestroy?: string[]; -} - -/** - * Represents a cdk command - * i.e. `synth`, `deploy`, & `destroy` - */ -export interface CdkCommand { - /** - * Whether or not to run this command as part of the workflow - * This can be used if you only want to test some of the workflow - * for example enable `synth` and disable `deploy` & `destroy` in order - * to limit the test to synthesis - * - * @default true - */ - readonly enabled?: boolean; - - /** - * If the runner should expect this command to fail - * - * @default false - */ - readonly expectError?: boolean; - - /** - * This can be used in combination with `expectedError` - * to validate that a specific message is returned. - * - * @default - do not validate message - */ - readonly expectedMessage?: string; -} - -/** - * Represents a cdk deploy command - */ -export interface DeployCommand extends CdkCommand { - /** - * Additional arguments to pass to the command - * This can be used to test specific CLI functionality - * - * @default - only default args are used - */ - readonly args?: DeployOptions; -} - -/** - * Represents a cdk destroy command - */ -export interface DestroyCommand extends CdkCommand { - /** - * Additional arguments to pass to the command - * This can be used to test specific CLI functionality - * - * @default - only default args are used - */ - readonly args?: DestroyOptions; -} - -/** - * Options for specific cdk commands that are run - * as part of the integration test workflow - */ -export interface CdkCommands { - /** - * Options to for the cdk deploy command - * - * @default - default deploy options - */ - readonly deploy?: DeployCommand; - - /** - * Options to for the cdk destroy command - * - * @default - default destroy options - */ - readonly destroy?: DestroyCommand; -} diff --git a/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts b/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts index 62f7894a54dd3..d2ceb45685678 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts +++ b/packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts @@ -3,7 +3,6 @@ import * as jsonschema from 'jsonschema'; import * as semver from 'semver'; import * as assets from './assets'; import * as assembly from './cloud-assembly'; -import * as integ from './integ-tests'; /* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-require-imports */ @@ -22,8 +21,6 @@ const ASSEMBLY_SCHEMA = require('../schema/cloud-assembly.schema.json'); */ const SCHEMA_VERSION = require('../schema/cloud-assembly.version.json').version; -const INTEG_SCHEMA = require('../schema/integ.schema.json'); - /** * Options for the loadManifest operation */ @@ -92,25 +89,6 @@ export class Manifest { return this.loadManifest(filePath, ASSETS_SCHEMA); } - /** - * Validates and saves the integ manifest to file. - * - * @param manifest - manifest. - * @param filePath - output file path. - */ - public static saveIntegManifest(manifest: integ.IntegManifest, filePath: string) { - Manifest.saveManifest(manifest, filePath, INTEG_SCHEMA); - } - - /** - * Load and validates the integ manifest from file. - * - * @param filePath - path to the manifest file. - */ - public static loadIntegManifest(filePath: string): integ.IntegManifest { - return this.loadManifest(filePath, INTEG_SCHEMA); - } - /** * Fetch the current schema version number. */ @@ -273,4 +251,4 @@ function noUndefined(xs: A): A { function stripEnumErrors(errors: jsonschema.ValidationError[]) { return errors.filter(e => typeof e.schema ==='string' || !('enum' in e.schema)); -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/cloud-assembly-schema/schema/cloud-assembly.version.json b/packages/@aws-cdk/cloud-assembly-schema/schema/cloud-assembly.version.json index 90bef2e09ad39..ae7a33e962d0b 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/schema/cloud-assembly.version.json +++ b/packages/@aws-cdk/cloud-assembly-schema/schema/cloud-assembly.version.json @@ -1 +1 @@ -{"version":"17.0.0"} \ No newline at end of file +{"version":"16.0.0"} diff --git a/packages/@aws-cdk/cloud-assembly-schema/schema/integ.schema.json b/packages/@aws-cdk/cloud-assembly-schema/schema/integ.schema.json deleted file mode 100644 index 676c1bdab91dd..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/schema/integ.schema.json +++ /dev/null @@ -1,474 +0,0 @@ -{ - "$ref": "#/definitions/IntegManifest", - "definitions": { - "IntegManifest": { - "description": "Definitions for the integration testing manifest", - "type": "object", - "properties": { - "version": { - "description": "Version of the manifest", - "type": "string" - }, - "enableLookups": { - "description": "Enable lookups for this test. If lookups are enabled\nthen `stackUpdateWorkflow` must be set to false.\nLookups should only be enabled when you are explicitely testing\nlookups.", - "default": false, - "type": "boolean" - }, - "testCases": { - "description": "test cases", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/TestCase" - } - } - }, - "required": [ - "testCases", - "version" - ] - }, - "TestCase": { - "description": "Represents an integration test test case", - "type": "object", - "properties": { - "stacks": { - "description": "Stacks that should be tested as part of this test case\nThe stackNames will be passed as args to the cdk commands\nso dependent stacks will be automatically deployed unless\n`exclusively` is passed", - "type": "array", - "items": { - "type": "string" - } - }, - "stackUpdateWorkflow": { - "description": "Run update workflow on this test case\nThis should only be set to false to test scenarios\nthat are not possible to test as part of the update workflow (Default true)", - "type": "boolean" - }, - "cdkCommandOptions": { - "description": "Additional options to use for each CDK command (Default - runner default options)", - "$ref": "#/definitions/CdkCommands" - }, - "hooks": { - "description": "Additional commands to run at predefined points in the test workflow\n\ne.g. { postDeploy: ['yarn', 'test'] } (Default - no hooks)", - "$ref": "#/definitions/Hooks" - }, - "diffAssets": { - "description": "Whether or not to include asset hashes in the diff\nAsset hashes can introduces a lot of unneccessary noise into tests,\nbut there are some cases where asset hashes _should_ be included. For example\nany tests involving custom resources or bundling", - "default": false, - "type": "boolean" - }, - "allowDestroy": { - "description": "List of CloudFormation resource types in this stack that can\nbe destroyed as part of an update without failing the test.\n\nThis list should only include resources that for this specific\nintegration test we are sure will not cause errors or an outage if\ndestroyed. For example, maybe we know that a new resource will be created\nfirst before the old resource is destroyed which prevents any outage.\n\ne.g. ['AWS::IAM::Role'] (Default - do not allow destruction of any resources on update)", - "type": "array", - "items": { - "type": "string" - } - }, - "regions": { - "description": "Limit deployment to these regions (Default - can run in any region)", - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "stacks" - ] - }, - "CdkCommands": { - "description": "Options for specific cdk commands that are run\nas part of the integration test workflow", - "type": "object", - "properties": { - "deploy": { - "description": "Options to for the cdk deploy command (Default - default deploy options)", - "$ref": "#/definitions/DeployCommand" - }, - "destroy": { - "description": "Options to for the cdk destroy command (Default - default destroy options)", - "$ref": "#/definitions/DestroyCommand" - } - } - }, - "DeployCommand": { - "description": "Represents a cdk deploy command", - "type": "object", - "properties": { - "args": { - "description": "Additional arguments to pass to the command\nThis can be used to test specific CLI functionality (Default - only default args are used)", - "$ref": "#/definitions/DeployOptions" - }, - "enabled": { - "description": "Whether or not to run this command as part of the workflow\nThis can be used if you only want to test some of the workflow\nfor example enable `synth` and disable `deploy` & `destroy` in order\nto limit the test to synthesis (Default true)", - "type": "boolean" - }, - "expectError": { - "description": "If the runner should expect this command to fail", - "default": false, - "type": "boolean" - }, - "expectedMessage": { - "description": "This can be used in combination with `expectedError`\nto validate that a specific message is returned. (Default - do not validate message)", - "type": "string" - } - } - }, - "DeployOptions": { - "description": "Options to use with cdk deploy", - "type": "object", - "properties": { - "exclusively": { - "description": "Only perform action on the given stack", - "default": false, - "type": "boolean" - }, - "toolkitStackName": { - "description": "Name of the toolkit stack to use/deploy (Default CDKToolkit)", - "type": "string" - }, - "reuseAssets": { - "description": "Reuse the assets with the given asset IDs (Default - do not reuse assets)", - "type": "array", - "items": { - "type": "string" - } - }, - "changeSetName": { - "description": "Optional name to use for the CloudFormation change set.\nIf not provided, a name will be generated automatically. (Default - auto generate a name)", - "type": "string" - }, - "force": { - "description": "Always deploy, even if templates are identical.", - "default": false, - "type": "boolean" - }, - "rollback": { - "description": "Rollback failed deployments (Default true)", - "type": "boolean" - }, - "notificationArns": { - "description": "ARNs of SNS topics that CloudFormation will notify with stack related events (Default - no notifications)", - "type": "array", - "items": { - "type": "string" - } - }, - "requireApproval": { - "description": "What kind of security changes require approval (Default RequireApproval.Never)", - "enum": [ - "any-change", - "broadening", - "never" - ], - "type": "string" - }, - "execute": { - "description": "Whether to execute the ChangeSet\nNot providing `execute` parameter will result in execution of ChangeSet (Default true)", - "type": "boolean" - }, - "parameters": { - "description": "Additional parameters for CloudFormation at deploy time (Default [object Object])", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "usePreviousParameters": { - "description": "Use previous values for unspecified parameters\n\nIf not set, all parameters must be specified for every deployment. (Default true)", - "type": "boolean" - }, - "outputsFile": { - "description": "Path to file where stack outputs will be written after a successful deploy as JSON (Default - Outputs are not written to any file)", - "type": "string" - }, - "ci": { - "description": "Whether we are on a CI system", - "default": false, - "type": "boolean" - }, - "stacks": { - "description": "List of stacks to deploy\n\nRequried if `all` is not set (Default - [])", - "type": "array", - "items": { - "type": "string" - } - }, - "all": { - "description": "Deploy all stacks\n\nRequried if `stacks` is not set (Default - false)", - "type": "boolean" - }, - "app": { - "description": "command-line for executing your app or a cloud assembly directory\ne.g. \"node bin/my-app.js\"\nor\n\"cdk.out\" (Default - read from cdk.json)", - "type": "string" - }, - "roleArn": { - "description": "Role to pass to CloudFormation for deployment (Default - use the bootstrap cfn-exec role)", - "type": "string" - }, - "context": { - "description": "Additional context (Default - no additional context)", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "trace": { - "description": "Print trace for stack warnings", - "default": false, - "type": "boolean" - }, - "strict": { - "description": "Do not construct stacks with warnings", - "default": false, - "type": "boolean" - }, - "lookups": { - "description": "Perform context lookups.\n\nSynthesis fails if this is disabled and context lookups need\nto be performed (Default true)", - "type": "boolean" - }, - "ignoreErrors": { - "description": "Ignores synthesis errors, which will likely produce an invalid output", - "default": false, - "type": "boolean" - }, - "json": { - "description": "Use JSON output instead of YAML when templates are printed\nto STDOUT", - "default": false, - "type": "boolean" - }, - "verbose": { - "description": "show debug logs", - "default": false, - "type": "boolean" - }, - "debug": { - "description": "enable emission of additional debugging information, such as creation stack\ntraces of tokens", - "default": false, - "type": "boolean" - }, - "profile": { - "description": "Use the indicated AWS profile as the default environment (Default - no profile is used)", - "type": "string" - }, - "proxy": { - "description": "Use the indicated proxy. Will read from\nHTTPS_PROXY environment if specified (Default - no proxy)", - "type": "string" - }, - "caBundlePath": { - "description": "Path to CA certificate to use when validating HTTPS\nrequests. (Default - read from AWS_CA_BUNDLE environment variable)", - "type": "string" - }, - "ec2Creds": { - "description": "Force trying to fetch EC2 instance credentials (Default - guess EC2 instance status)", - "type": "boolean" - }, - "versionReporting": { - "description": "Include \"AWS::CDK::Metadata\" resource in synthesized templates (Default true)", - "type": "boolean" - }, - "pathMetadata": { - "description": "Include \"aws:cdk:path\" CloudFormation metadata for each resource (Default true)", - "type": "boolean" - }, - "assetMetadata": { - "description": "Include \"aws:asset:*\" CloudFormation metadata for resources that use assets (Default true)", - "type": "boolean" - }, - "staging": { - "description": "Copy assets to the output directory\n\nNeeded for local debugging the source files with SAM CLI", - "default": false, - "type": "boolean" - }, - "output": { - "description": "Emits the synthesized cloud assembly into a directory (Default cdk.out)", - "type": "string" - }, - "notices": { - "description": "Show relevant notices (Default true)", - "type": "boolean" - }, - "color": { - "description": "Show colors and other style from console output (Default true)", - "type": "boolean" - } - } - }, - "DestroyCommand": { - "description": "Represents a cdk destroy command", - "type": "object", - "properties": { - "args": { - "description": "Additional arguments to pass to the command\nThis can be used to test specific CLI functionality (Default - only default args are used)", - "$ref": "#/definitions/DestroyOptions" - }, - "enabled": { - "description": "Whether or not to run this command as part of the workflow\nThis can be used if you only want to test some of the workflow\nfor example enable `synth` and disable `deploy` & `destroy` in order\nto limit the test to synthesis (Default true)", - "type": "boolean" - }, - "expectError": { - "description": "If the runner should expect this command to fail", - "default": false, - "type": "boolean" - }, - "expectedMessage": { - "description": "This can be used in combination with `expectedError`\nto validate that a specific message is returned. (Default - do not validate message)", - "type": "string" - } - } - }, - "DestroyOptions": { - "description": "Options to use with cdk destroy", - "type": "object", - "properties": { - "force": { - "description": "Do not ask for permission before destroying stacks", - "default": false, - "type": "boolean" - }, - "exclusively": { - "description": "Only destroy the given stack", - "default": false, - "type": "boolean" - }, - "stacks": { - "description": "List of stacks to deploy\n\nRequried if `all` is not set (Default - [])", - "type": "array", - "items": { - "type": "string" - } - }, - "all": { - "description": "Deploy all stacks\n\nRequried if `stacks` is not set (Default - false)", - "type": "boolean" - }, - "app": { - "description": "command-line for executing your app or a cloud assembly directory\ne.g. \"node bin/my-app.js\"\nor\n\"cdk.out\" (Default - read from cdk.json)", - "type": "string" - }, - "roleArn": { - "description": "Role to pass to CloudFormation for deployment (Default - use the bootstrap cfn-exec role)", - "type": "string" - }, - "context": { - "description": "Additional context (Default - no additional context)", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "trace": { - "description": "Print trace for stack warnings", - "default": false, - "type": "boolean" - }, - "strict": { - "description": "Do not construct stacks with warnings", - "default": false, - "type": "boolean" - }, - "lookups": { - "description": "Perform context lookups.\n\nSynthesis fails if this is disabled and context lookups need\nto be performed (Default true)", - "type": "boolean" - }, - "ignoreErrors": { - "description": "Ignores synthesis errors, which will likely produce an invalid output", - "default": false, - "type": "boolean" - }, - "json": { - "description": "Use JSON output instead of YAML when templates are printed\nto STDOUT", - "default": false, - "type": "boolean" - }, - "verbose": { - "description": "show debug logs", - "default": false, - "type": "boolean" - }, - "debug": { - "description": "enable emission of additional debugging information, such as creation stack\ntraces of tokens", - "default": false, - "type": "boolean" - }, - "profile": { - "description": "Use the indicated AWS profile as the default environment (Default - no profile is used)", - "type": "string" - }, - "proxy": { - "description": "Use the indicated proxy. Will read from\nHTTPS_PROXY environment if specified (Default - no proxy)", - "type": "string" - }, - "caBundlePath": { - "description": "Path to CA certificate to use when validating HTTPS\nrequests. (Default - read from AWS_CA_BUNDLE environment variable)", - "type": "string" - }, - "ec2Creds": { - "description": "Force trying to fetch EC2 instance credentials (Default - guess EC2 instance status)", - "type": "boolean" - }, - "versionReporting": { - "description": "Include \"AWS::CDK::Metadata\" resource in synthesized templates (Default true)", - "type": "boolean" - }, - "pathMetadata": { - "description": "Include \"aws:cdk:path\" CloudFormation metadata for each resource (Default true)", - "type": "boolean" - }, - "assetMetadata": { - "description": "Include \"aws:asset:*\" CloudFormation metadata for resources that use assets (Default true)", - "type": "boolean" - }, - "staging": { - "description": "Copy assets to the output directory\n\nNeeded for local debugging the source files with SAM CLI", - "default": false, - "type": "boolean" - }, - "output": { - "description": "Emits the synthesized cloud assembly into a directory (Default cdk.out)", - "type": "string" - }, - "notices": { - "description": "Show relevant notices (Default true)", - "type": "boolean" - }, - "color": { - "description": "Show colors and other style from console output (Default true)", - "type": "boolean" - } - } - }, - "Hooks": { - "description": "Commands to run at predefined points during the\nintegration test workflow", - "type": "object", - "properties": { - "preDeploy": { - "description": "Commands to run prior to deploying the cdk stacks\nin the integration test (Default - no commands)", - "type": "array", - "items": { - "type": "string" - } - }, - "postDeploy": { - "description": "Commands to run prior after deploying the cdk stacks\nin the integration test (Default - no commands)", - "type": "array", - "items": { - "type": "string" - } - }, - "preDestroy": { - "description": "Commands to run prior to destroying the cdk stacks\nin the integration test (Default - no commands)", - "type": "array", - "items": { - "type": "string" - } - }, - "postDestroy": { - "description": "Commands to run after destroying the cdk stacks\nin the integration test (Default - no commands)", - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "$schema": "http://json-schema.org/draft-07/schema#" -} \ No newline at end of file diff --git a/packages/@aws-cdk/cloud-assembly-schema/scripts/update-schema.ts b/packages/@aws-cdk/cloud-assembly-schema/scripts/update-schema.ts index 13a410cd4a36f..e92083d34b0a6 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/scripts/update-schema.ts +++ b/packages/@aws-cdk/cloud-assembly-schema/scripts/update-schema.ts @@ -17,7 +17,6 @@ const SCHEMA_DIR = path.resolve(__dirname, '../schema'); const SCHEMA_DEFINITIONS: { [schemaName: string]: { rootTypeName: string } } = { 'assets': { rootTypeName: 'AssetManifest' }, 'cloud-assembly': { rootTypeName: 'AssemblyManifest' }, - 'integ': { rootTypeName: 'IntegManifest' }, }; export const SCHEMAS = Object.keys(SCHEMA_DEFINITIONS); diff --git a/packages/@aws-cdk/cloud-assembly-schema/test/integ-tests.test.ts b/packages/@aws-cdk/cloud-assembly-schema/test/integ-tests.test.ts deleted file mode 100644 index 3baefc89d750f..0000000000000 --- a/packages/@aws-cdk/cloud-assembly-schema/test/integ-tests.test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import * as fs from 'fs'; -import * as os from 'os'; -import * as path from 'path'; -import { Manifest } from '../lib'; - -describe('Integration test', () => { - test('valid input', () => { - expect(() => { - validate({ - version: Manifest.version(), - testCases: { - testCase1: { - stacks: ['stack1', 'stack2'], - stackUpdateWorkflow: true, - cdkCommandOptions: { - deploy: { - enabled: true, - expectError: false, - expectedMessage: 'some message', - args: { - exclusively: true, - toolkitStackName: 'Stack', - reuseAssets: ['asset1', 'asset2'], - changeSetName: 'changeset', - force: true, - rollback: false, - notificationArns: ['arn1', 'arn2'], - execute: true, - parameters: { - 'MYPARAM': 'Value', - 'Stack1:OtherParam': 'OtherValue', - }, - usePreviousParameters: true, - outputsFile: 'outputs.json', - ci: true, - requireApproval: 'never', - app: 'node bin/my-app.js', - roleArn: 'roleArn', - context: { - KEY: 'value', - }, - trace: true, - strict: true, - lookups: true, - ignoreErrors: true, - json: true, - verbose: true, - debug: true, - profile: 'profile', - proxy: 'https://proxy', - caBundlePath: 'path/to/bundle', - ec2Creds: true, - versionReporting: false, - pathMetadata: false, - assetMetadata: true, - staging: false, - output: true, - notices: true, - color: false, - }, - }, - synth: { - enabled: true, - expectError: false, - expectedMessage: 'some message', - args: { - quiet: true, - exclusively: true, - validation: true, - }, - }, - destroy: { - enabled: true, - expectError: false, - expectedMessage: 'some message', - args: { - force: true, - exclusively: true, - }, - }, - }, - hooks: { - preDeploy: ['yarn test'], - postDeploy: ['some other command'], - preDestroy: ['command1', 'command2'], - postDestroy: ['command3', 'command4'], - }, - diffAssets: true, - allowDestroy: ['AWS::IAM::Role'], - region: ['us-east-1', 'us-east-2'], - }, - }, - }); - }); - }); - - test('invalid input', () => { - expect(() => { - validate({ - version: Manifest.version(), - testCases: { - stacks: true, - }, - }); - }).toThrow(/instance\.testCases\.stacks is not of a type\(s\) object/); - }); - - test('without command options', () => { - expect(() => { - validate({ - version: Manifest.version(), - testCases: { - testCase1: { - stacks: ['stack1', 'stack2'], - stackUpdateWorkflow: true, - hooks: { - preDeploy: ['yarn test'], - }, - diffAssets: true, - }, - }, - }); - }); - }); -}); - -function validate(manifest: any) { - const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'integ.test.')); - const filePath = path.join(dir, 'manifest.json'); - fs.writeFileSync(filePath, JSON.stringify(manifest, undefined, 2)); - try { - Manifest.loadIntegManifest(filePath); - } finally { - fs.unlinkSync(filePath); - fs.rmdirSync(dir); - } -} diff --git a/packages/@aws-cdk/core/lib/duration.ts b/packages/@aws-cdk/core/lib/duration.ts index ebb5e60a19a67..29cafc4f8b189 100644 --- a/packages/@aws-cdk/core/lib/duration.ts +++ b/packages/@aws-cdk/core/lib/duration.ts @@ -316,7 +316,7 @@ function convert(amount: number, fromUnit: TimeUnit, toUnit: TimeUnit, { integra if (fromUnit.inMillis === toUnit.inMillis) { return amount; } if (Token.isUnresolved(amount)) { - throw new Error(`Unable to perform time unit conversion on un-resolved token ${amount}.`); + throw new Error(`Duration must be specified as 'Duration.${toUnit}()' here since its value comes from a token and cannot be converted (got Duration.${fromUnit})`); } const value = (amount * fromUnit.inMillis) / toUnit.inMillis; if (!Number.isInteger(value) && integral) { diff --git a/packages/@aws-cdk/core/lib/size.ts b/packages/@aws-cdk/core/lib/size.ts index e8b9c66e35b72..fa938c5939271 100644 --- a/packages/@aws-cdk/core/lib/size.ts +++ b/packages/@aws-cdk/core/lib/size.ts @@ -144,6 +144,13 @@ export class Size { public toPebibytes(opts: SizeConversionOptions = {}): number { return convert(this.amount, this.unit, StorageUnit.Pebibytes, opts); } + + /** + * Checks if size is a token or a resolvable object + */ + public isUnresolved() { + return Token.isUnresolved(this.amount); + } } /** @@ -190,7 +197,7 @@ function convert(amount: number, fromUnit: StorageUnit, toUnit: StorageUnit, opt const rounding = options.rounding ?? SizeRoundingBehavior.FAIL; if (fromUnit.inKibiBytes === toUnit.inKibiBytes) { return amount; } if (Token.isUnresolved(amount)) { - throw new Error(`Unable to perform time unit conversion on un-resolved token ${amount}.`); + throw new Error(`Size must be specified as 'Size.${toUnit}()' here since its value comes from a token and cannot be converted (got Size.${fromUnit})`); } const multiplier = fromUnit.inKibiBytes / toUnit.inKibiBytes; diff --git a/packages/@aws-cdk/core/test/duration.test.ts b/packages/@aws-cdk/core/test/duration.test.ts index 99d54d15f0905..466369be3f4f8 100644 --- a/packages/@aws-cdk/core/test/duration.test.ts +++ b/packages/@aws-cdk/core/test/duration.test.ts @@ -16,10 +16,8 @@ describe('duration', () => { expect(stack.resolve(lazyDuration.toSeconds())).toEqual(1337); expect( () => stack.resolve(lazyDuration.toMinutes())).toThrow( - /Unable to perform time unit conversion on un-resolved token/, + /Duration must be specified as 'Duration.minutes\(\)' here/, ); - - }); test('Duration in seconds', () => { @@ -31,8 +29,6 @@ describe('duration', () => { floatEqual(duration.toDays({ integral: false }), 300 / 86_400); expect(Duration.seconds(60 * 60 * 24).toDays()).toEqual(1); - - }); test('Duration in minutes', () => { @@ -44,8 +40,6 @@ describe('duration', () => { floatEqual(duration.toDays({ integral: false }), 300 / 86_400); expect(Duration.minutes(60 * 24).toDays()).toEqual(1); - - }); test('Duration in hours', () => { @@ -57,16 +51,12 @@ describe('duration', () => { floatEqual(duration.toDays({ integral: false }), 5 / 24); expect(Duration.hours(24).toDays()).toEqual(1); - - }); test('seconds to milliseconds', () => { const duration = Duration.seconds(5); expect(duration.toMilliseconds()).toEqual(5_000); - - }); test('Duration in days', () => { @@ -75,8 +65,6 @@ describe('duration', () => { expect(duration.toSeconds()).toEqual(86_400); expect(duration.toMinutes()).toEqual(1_440); expect(duration.toDays()).toEqual(1); - - }); testDeprecated('toISOString', () => { @@ -93,8 +81,6 @@ describe('duration', () => { expect(Duration.days(5).toISOString()).toEqual('P5D'); expect(Duration.seconds(1 + 60 * (1 + 60 * (1 + 24))).toISOString()).toEqual('P1DT1H1M1S'); - - }); test('toIsoString', () => { @@ -112,8 +98,6 @@ describe('duration', () => { expect(Duration.seconds(65).toIsoString()).toEqual('PT1M5S'); expect(Duration.seconds(1 + 60 * (1 + 60 * (1 + 24))).toIsoString()).toEqual('P1DT1H1M1S'); - - }); test('parse', () => { @@ -128,8 +112,6 @@ describe('duration', () => { expect(Duration.parse('P5D').toSeconds()).toEqual(432_000); expect(Duration.parse('P1DT1H1M1S').toSeconds()).toEqual(1 + 60 * (1 + 60 * (1 + 24))); - - }); test('reject illegal parses', () => { @@ -141,8 +123,6 @@ describe('duration', () => { expect(() => { Duration.parse('P5S'); }).toThrow(err); - - }); test('to human string', () => { @@ -165,8 +145,6 @@ describe('duration', () => { expect(Duration.millis(3666).toHumanString()).toEqual('3 seconds 666 millis'); expect(Duration.millis(3.6).toHumanString()).toEqual('3.6 millis'); - - }); test('add two durations', () => { @@ -188,7 +166,6 @@ describe('duration', () => { expect(Duration.millis(1).unitLabel()).toEqual('millis'); expect(Duration.hours(1000).unitLabel()).toEqual('hours'); expect(Duration.days(2).unitLabel()).toEqual('days'); - }); test('format number token to number', () => { @@ -197,14 +174,12 @@ describe('duration', () => { expect(stack.resolve(lazyDuration.formatTokenToNumber())).toEqual('10 minutes'); expect(Duration.hours(10).formatTokenToNumber()).toEqual('10 hours'); expect(Duration.days(5).formatTokenToNumber()).toEqual('5 days'); - }); test('duration is unresolved', () => { const lazyDuration = Duration.minutes(Lazy.number({ produce: () => 10 })); expect(lazyDuration.isUnresolved()).toEqual(true); expect(Duration.hours(10).isUnresolved()).toEqual(false); - }); }); diff --git a/packages/@aws-cdk/core/test/size.test.ts b/packages/@aws-cdk/core/test/size.test.ts index 9801fc8f53acf..a7c9c93a1a5bb 100644 --- a/packages/@aws-cdk/core/test/size.test.ts +++ b/packages/@aws-cdk/core/test/size.test.ts @@ -1,10 +1,8 @@ -import { Size, SizeRoundingBehavior, Stack, Token } from '../lib'; +import { Size, SizeRoundingBehavior, Stack, Token, Lazy } from '../lib'; describe('size', () => { test('negative amount', () => { expect(() => Size.kibibytes(-1)).toThrow(/negative/); - - }); test('unresolved amount', () => { @@ -13,10 +11,8 @@ describe('size', () => { expect(stack.resolve(lazySize.toKibibytes())).toEqual(1337); expect( () => stack.resolve(lazySize.toMebibytes())).toThrow( - /Unable to perform time unit conversion on un-resolved token/, + /Size must be specified as 'Size.mebibytes\(\)' here/, ); - - }); test('Size in kibibytes', () => { @@ -30,8 +26,6 @@ describe('size', () => { floatEqual(size.toPebibytes({ rounding: SizeRoundingBehavior.NONE }), 4_294_967_296 / (1024 * 1024 * 1024 * 1024)); expect(Size.kibibytes(4 * 1024 * 1024).toGibibytes()).toEqual(4); - - }); test('Size in mebibytes', () => { @@ -45,8 +39,6 @@ describe('size', () => { floatEqual(size.toPebibytes({ rounding: SizeRoundingBehavior.NONE }), 4_194_304 / (1024 * 1024 * 1024)); expect(Size.mebibytes(4 * 1024).toGibibytes()).toEqual(4); - - }); test('Size in gibibyte', () => { @@ -61,8 +53,6 @@ describe('size', () => { floatEqual(size.toPebibytes({ rounding: SizeRoundingBehavior.NONE }), 5 / (1024 * 1024)); expect(Size.gibibytes(4096).toTebibytes()).toEqual(4); - - }); test('Size in tebibyte', () => { @@ -76,8 +66,6 @@ describe('size', () => { floatEqual(size.toPebibytes({ rounding: SizeRoundingBehavior.NONE }), 5 / 1024); expect(Size.tebibytes(4096).toPebibytes()).toEqual(4); - - }); test('Size in pebibytes', () => { @@ -88,8 +76,6 @@ describe('size', () => { expect(size.toGibibytes()).toEqual(5_242_880); expect(size.toTebibytes()).toEqual(5_120); expect(size.toPebibytes()).toEqual(5); - - }); test('rounding behavior', () => { @@ -105,8 +91,12 @@ describe('size', () => { expect(size.toGibibytes({ rounding: SizeRoundingBehavior.NONE })).toEqual(5.078125); expect(size.toTebibytes({ rounding: SizeRoundingBehavior.NONE })).toEqual(5200 / (1024 * 1024)); expect(size.toKibibytes({ rounding: SizeRoundingBehavior.NONE })).toEqual(5_324_800); + }); - + test('size is unresolved', () => { + const lazySize = Size.pebibytes(Lazy.number({ produce: () => 10 })); + expect(lazySize.isUnresolved()).toEqual(true); + expect(Size.mebibytes(10).isUnresolved()).toEqual(false); }); }); diff --git a/packages/@aws-cdk/integ-runner/.eslintrc.js b/packages/@aws-cdk/integ-runner/.eslintrc.js deleted file mode 100644 index 2658ee8727166..0000000000000 --- a/packages/@aws-cdk/integ-runner/.eslintrc.js +++ /dev/null @@ -1,3 +0,0 @@ -const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc'); -baseConfig.parserOptions.project = __dirname + '/tsconfig.json'; -module.exports = baseConfig; diff --git a/packages/@aws-cdk/integ-runner/.gitignore b/packages/@aws-cdk/integ-runner/.gitignore deleted file mode 100644 index d24092a6feda2..0000000000000 --- a/packages/@aws-cdk/integ-runner/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -*.js -*.js.map -*.d.ts -!lib/init-templates/**/javascript/**/* -node_modules -dist - -# Generated by generate.sh -build-info.json - -.LAST_BUILD -.nyc_output -coverage -nyc.config.js -.LAST_PACKAGE -*.snk - -!test/integ/run-wrappers/dist -!test/integ/cli/**/* -assets.json -npm-shrinkwrap.json -!.eslintrc.js -!jest.config.js - -junit.xml - -# Ignore this symlink, we recreate it at test time -test/test-archive-follow/data/linked diff --git a/packages/@aws-cdk/integ-runner/.npmignore b/packages/@aws-cdk/integ-runner/.npmignore deleted file mode 100644 index 45b8808bdd7ac..0000000000000 --- a/packages/@aws-cdk/integ-runner/.npmignore +++ /dev/null @@ -1,30 +0,0 @@ -# Don't include original .ts files when doing `npm pack` -*.ts -!*.template.ts -!*.d.ts -coverage -.nyc_output -*.tgz - -dist -.LAST_PACKAGE -.LAST_BUILD -*.snk - -!lib/init-templates/*/*/tsconfig.json -!test/integ/cli/**/*.js -!test/integ/run-wrappers/dist - -*.tsbuildinfo - -tsconfig.json - -# init templates include default tsconfig.json files which we need -!lib/init-templates/**/tsconfig.json -.eslintrc.js -jest.config.js - -# exclude cdk artifacts -**/cdk.out -junit.xml -test/ \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/LICENSE b/packages/@aws-cdk/integ-runner/LICENSE deleted file mode 100644 index 82ad00bb02d0b..0000000000000 --- a/packages/@aws-cdk/integ-runner/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - 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-2022 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/integ-runner/NOTICE b/packages/@aws-cdk/integ-runner/NOTICE deleted file mode 100644 index 1b7adbb891265..0000000000000 --- a/packages/@aws-cdk/integ-runner/NOTICE +++ /dev/null @@ -1,2 +0,0 @@ -AWS Cloud Development Kit (AWS CDK) -Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/@aws-cdk/integ-runner/README.md b/packages/@aws-cdk/integ-runner/README.md deleted file mode 100644 index e67a64282a42b..0000000000000 --- a/packages/@aws-cdk/integ-runner/README.md +++ /dev/null @@ -1,161 +0,0 @@ -# integ-runner - - - ---- - -![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge) - -> The APIs of higher level constructs in this module are experimental and under active development. -> They are subject to non-backward compatible changes or removal in any future version. These are -> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be -> announced in the release notes. This means that while you may use them, you may need to update -> your source code when upgrading to a newer version of this package. - ---- - - - - -## Overview - - -## Usage - -- Run all integration tests in `test` directory - -```bash -integ-runner [ARGS] [TEST...] -``` - -This will look for all files that match the naming convention of `/integ.*.ts$/`. Each of these files will be expected -to be a self contained CDK app. The runner will execute the following for each file (app): - -1. Check if a snapshot file exists (i.e. `/integ.*.expected.snapshot$/`) -2. If the snapshot does not exist - 2a. Synth the integ app which will produce the `integ.json` file -3. Read the `integ.json` file which contains instructions on what the runner should do. -4. Execute instructions - -### Options - -- `--update-on-failed` (default=false) - Rerun integration tests if snapshot fails -- `--clean` (default=`true`) - Destroy stacks after deploy (use `--no-clean` for debugging) -- `--verbose` (default=`false`) - verbose logging -- `--parallel` (default=`false`) - Run tests in parallel across default regions -- `--parallel-regions` - List of regions to run tests in. If this is provided then all tests will - be run in parallel across these regions -- `--directory` (default=`test`) - Search for integration tests recursively from this starting directory -- `--force` (default=`false`) - Rerun integration test even if the test passes -- `--file` - Read the list of tests from this file - -Example: - -```bash -integ-runner --update --parallel --parallel-regions us-east-1 --parallel-regions us-east-2 --parallel-regions us-west-2 --directory ./ -``` - -This will search for integration tests recursively from the current directory and then execute them in parallel across `us-east-1`, `us-east-2`, & `us-west-2`. - -### integ.json schema - -See [@aws-cdk/cloud-assembly-schema/lib/integ-tests/schema.ts](../cloud-assembly-schema/lib/integ-tests/schema.ts) - -### defining an integration test - -In most cases an integration test will be an instance of a stack - -```ts -import { Function, FunctionOptions } from '../lib'; - -interface MyIntegTestProps extends StackOptions { - functionProps?: FunctionOptions; -} -class MyIntegTest extends Stack { - constructor(scope: Construct, id: string, props: MyIntegTestProps) { - super(scope, id, props); - - new Function(this, 'Handler', { - runtime: Runtime.NODEJS_12_X, - handler: 'index.handler', - code: Code.fromAsset(path.join(__dirname, 'lambda-handler')), - ...props.functionProps, - }); - } -} -``` - -You would then use the `IntegTest` construct to create your test cases - -```ts -new IntegTeset(app, 'ArmTest', { - stacks: [ - new MyIntegTest(app, 'Stack1', { - functionProps: { - architecture: lambda.Architecture.ARM_64, - }, - }), - ], - diffAssets: true, - update: true, - cdkCommandOptions: { - deploy: { - args: { - requireApproval: RequireApproval.NEVER, - json: true, - }, - }, - destroy: { - args: { - force: true, - }, - }, - }, -}); - -new IntegTeset(app, 'AmdTest', { - stacks: [ - new MyIntegTest(app, 'Stack2', { - functionProps: { - architecture: lambda.Architecture.X86_64, - }, - }), - ], -}); -``` - -This will synthesize an `integ.json` file with the following contents - -```json -{ - "ArmTest": { - "stacks": ["Stack1"], - "diffAssets": true, - "update": true, - "cdkCommands": { - "deploy": { - "args": { - "requireApproval": "never", - "json": true - } - }, - "destroy": { - "args": { - "force": true - } - } - } - }, - "AmdTest": { - "stacks": ["Stack2"] - } -} -``` diff --git a/packages/@aws-cdk/integ-runner/bin/integ-runner b/packages/@aws-cdk/integ-runner/bin/integ-runner deleted file mode 100755 index 20ace56b80449..0000000000000 --- a/packages/@aws-cdk/integ-runner/bin/integ-runner +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require('./integ-runner.js'); diff --git a/packages/@aws-cdk/integ-runner/bin/integ-runner.ts b/packages/@aws-cdk/integ-runner/bin/integ-runner.ts deleted file mode 100644 index ca343920f91cb..0000000000000 --- a/packages/@aws-cdk/integ-runner/bin/integ-runner.ts +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env node -// Exercise all integ stacks and if they deploy, update the expected synth files -import * as os from 'os'; -import * as path from 'path'; -import * as chalk from 'chalk'; -import * as workerpool from 'workerpool'; -import * as yargs from 'yargs'; -import { IntegrationTests, IntegTestConfig } from '../lib/runner/integ-tests'; -import * as logger from '../lib/runner/private/logger'; -import { IntegBatchResponse, printResults } from '../lib/workers/common'; -import { SnapshotBatchRequest } from '../lib/workers/extract_worker'; -import { runIntegrationTestsInParallel, IntegTestRunOptions } from '../lib/workers/integ-test-worker'; - - -/** - * Split a list of snapshot tests into batches that can be run using a workerpool. - */ -function batchTests(tests: IntegTestConfig[]): SnapshotBatchRequest[] { - let batchSize = 3; - const ret: SnapshotBatchRequest[] = []; - for (let i = 0; i < tests.length; i += batchSize) { - ret.push({ - tests: tests.slice(i, i + batchSize), - }); - } - return ret; -} - -export function printSummary(total: number, failed: number): void { - if (failed > 0) { - logger.print('%s: %s %s, %s total', chalk.bold('Tests'), chalk.red(failed), chalk.red('failed'), total); - } else { - logger.print('%s: %s %s, %s total', chalk.bold('Tests'), chalk.green(total), chalk.green('passed'), total); - } -} - -/** - * Run Integration tests. - */ -async function runIntegrationTests(options: IntegTestRunOptions): Promise { - logger.highlight('\nRunning integration tests for failed tests...\n'); - logger.print('Running in parallel across: %s', options.regions.join(', ')); - const totalTests = options.tests.length; - const failedTests: IntegTestConfig[] = []; - - const responses = await runIntegrationTestsInParallel(options); - for (const response of responses) { - failedTests.push(...response.failedTests); - } - logger.highlight('\nTest Results: \n'); - printSummary(totalTests, failedTests.length); -} - -/** - * Run Snapshot tests - * First batch up the tests. By default there will be 3 tests per batch. - * Use a workerpool to run the batches in parallel. - */ -async function runSnapshotTests(pool: workerpool.WorkerPool, tests: IntegTestConfig[]): Promise { - const testsToRun: IntegTestConfig[] = []; - const requests = batchTests(tests); - logger.highlight('\nVerifying integration test snapshots...\n'); - const responses: IntegBatchResponse[] = await Promise.all( - requests.map((request) => pool.exec('snapshotTestBatch', [request], { - on: printResults, - })), - ); - for (const response of responses) { - testsToRun.push(...response.failedTests); - } - - logger.highlight('\nSnapshot Results: \n'); - printSummary(tests.length, testsToRun.length); - return testsToRun; -} - -async function main() { - const argv = yargs - .usage('Usage: integ-runner [TEST...]') - .option('list', { type: 'boolean', default: false, desc: 'List tests instead of running them' }) - .option('clean', { type: 'boolean', default: true, desc: 'Skips stack clean up after test is completed (use --no-clean to negate)' }) - .option('verbose', { type: 'boolean', default: false, alias: 'v', desc: 'Verbose logs' }) - .option('dry-run', { type: 'boolean', default: false, desc: 'do not actually deploy the stack. just update the snapshot (not recommended!)' }) - .option('update-on-failed', { type: 'boolean', default: false, desc: 'rerun integration tests and update snapshots for failed tests.' }) - .option('force', { type: 'boolean', default: false, desc: 'Rerun all integration tests even if tests are passing' }) - .option('parallel', { type: 'boolean', default: false, desc: 'run integration tests in parallel' }) - .option('parallel-regions', { type: 'array', desc: 'if --parallel is used then these regions are used to run tests in parallel', nargs: 1, default: [] }) - .options('directory', { type: 'string', default: 'test', desc: 'starting directory to discover integration tests' }) - .argv; - - // Cap to a reasonable top-level limit to prevent thrash on machines with many, many cores. - const maxWorkers = parseInt(process.env.CDK_INTEG_MAX_WORKER_COUNT ?? '16'); - const N = Math.min(maxWorkers, Math.max(1, Math.ceil(os.cpus().length / 2))); - const pool = workerpool.pool(path.join(__dirname, '../lib/workers/extract_worker.js'), { - maxWorkers: N, - }); - - // list of integration tests that will be executed - const testsToRun: IntegTestConfig[] = []; - const testsFromArgs: IntegTestConfig[] = []; - const parallelRegions = arrayFromYargs(argv['parallel-regions']); - const testRegions: string[] = parallelRegions ?? ['us-east-1', 'us-east-2', 'us-west-2']; - const runUpdateOnFailed = argv['update-on-failed'] ?? false; - - - try { - if (argv.list) { - const tests = await new IntegrationTests(argv.directory).fromCliArgs(); - process.stdout.write(tests.map(t => t.fileName).join('\n') + '\n'); - return; - } - - if (argv._.length === 0) { - testsFromArgs.push(...(await new IntegrationTests(argv.directory).fromCliArgs())); - } else { - testsFromArgs.push(...(await new IntegrationTests(argv.directory).fromCliArgs(argv._.map(x => x.toString())))); - } - - // If `--force` is not used then first validate the snapshots and gather - // the failed snapshot tests. If `--force` is used then we will skip snapshot - // tests and run integration tests for all tests - if (!argv.force) { - const failedSnapshots = await runSnapshotTests(pool, testsFromArgs); - testsToRun.push(...failedSnapshots); - } else { - testsToRun.push(...testsFromArgs); - } - - - // run integration tests if `--update-on-failed` OR `--force` is used - if (runUpdateOnFailed || argv.force) { - await runIntegrationTests({ - pool, - tests: testsToRun, - regions: testRegions, - clean: argv.clean, - dryRun: argv['dry-run'], - verbose: argv.verbose, - }); - - if (argv.clean === false) { - logger.warning('Not cleaning up stacks since "--no-clean" was used'); - } - } - - } finally { - void pool.terminate(); - } -} - -/** - * Translate a Yargs input array to something that makes more sense in a programming language - * model (telling the difference between absence and an empty array) - * - * - An empty array is the default case, meaning the user didn't pass any arguments. We return - * undefined. - * - If the user passed a single empty string, they did something like `--array=`, which we'll - * take to mean they passed an empty array. - */ -function arrayFromYargs(xs: string[]): string[] | undefined { - if (xs.length === 0) { return undefined; } - return xs.filter(x => x !== ''); -} - -main().catch(e => { - // eslint-disable-next-line no-console - console.error(e); - process.exit(1); -}); diff --git a/packages/@aws-cdk/integ-runner/jest.config.js b/packages/@aws-cdk/integ-runner/jest.config.js deleted file mode 100644 index d052cbb29f05d..0000000000000 --- a/packages/@aws-cdk/integ-runner/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); -module.exports = { - ...baseConfig, - coverageThreshold: { - global: { - ...baseConfig.coverageThreshold.global, - branches: 60, - }, - }, -}; diff --git a/packages/@aws-cdk/integ-runner/lib/runner/integ-tests.ts b/packages/@aws-cdk/integ-runner/lib/runner/integ-tests.ts deleted file mode 100644 index 0fd648c31c5d1..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/integ-tests.ts +++ /dev/null @@ -1,76 +0,0 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; - -/** - * Represents a single integration test - */ -export interface IntegTestConfig { - readonly directory: string; - readonly fileName: string; -} - -/** - * Discover integration tests - */ -export class IntegrationTests { - constructor(private readonly directory: string) { - } - - /** - * Takes an optional list of tests to look for, otherwise - * it will look for all tests from the directory - */ - public async fromCliArgs(tests?: string[]): Promise { - let allTests = await this.discover(); - const all = allTests.map(x => x.fileName); - let foundAll = true; - - if (tests && tests.length > 0) { - // Pare down found tests to filter - allTests = allTests.filter(t => { - const parts = path.parse(t.fileName); - return (tests.includes(t.fileName) || tests.includes(parts.base)); - }); - - const selectedNames = allTests.map(t => path.parse(t.fileName).base); - for (const unmatched of tests.filter(t => !selectedNames.includes(t))) { - process.stderr.write(`No such integ test: ${unmatched}\n`); - foundAll = false; - } - } - - if (!foundAll) { - process.stderr.write(`Available tests: ${all.join(' ')}\n`); - return []; - } - - return allTests; - } - - private async discover(): Promise { - const files = await this.readTree(); - const integs = files.filter(fileName => path.basename(fileName).startsWith('integ.') && path.basename(fileName).endsWith('.js')); - return this.request(integs); - } - - private request(files: string[]): IntegTestConfig[] { - return files.map(fileName => { return { directory: this.directory, fileName }; }); - } - - private async readTree(): Promise { - const ret = new Array(); - - async function recurse(dir: string) { - const files = await fs.readdir(dir); - for (const file of files) { - const fullPath = path.join(dir, file); - const statf = await fs.stat(fullPath); - if (statf.isFile()) { ret.push(fullPath); } - if (statf.isDirectory()) { await recurse(path.join(fullPath)); } - } - } - - await recurse(this.directory); - return ret; - } -} diff --git a/packages/@aws-cdk/integ-runner/lib/runner/private/canonicalize-assets.ts b/packages/@aws-cdk/integ-runner/lib/runner/private/canonicalize-assets.ts deleted file mode 100644 index 9cee3d4742b3c..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/private/canonicalize-assets.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Reduce template to a normal form where asset references have been normalized - * - * This makes it possible to compare templates if all that's different between - * them is the hashes of the asset values. - * - * Currently only handles parameterized assets, but can (and should) - * be adapted to handle convention-mode assets as well when we start using - * more of those. - */ -export function canonicalizeTemplate(template: any): any { - // For the weird case where we have an array of templates... - if (Array.isArray(template)) { - return template.map(canonicalizeTemplate); - } - - // Find assets via parameters - const stringSubstitutions = new Array<[RegExp, string]>(); - const paramRe = /^AssetParameters([a-zA-Z0-9]{64})(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})$/; - - const assetsSeen = new Set(); - for (const paramName of Object.keys(template?.Parameters || {})) { - const m = paramRe.exec(paramName); - if (!m) { continue; } - if (assetsSeen.has(m[1])) { continue; } - - assetsSeen.add(m[1]); - const ix = assetsSeen.size; - - // Full parameter reference - stringSubstitutions.push([ - new RegExp(`AssetParameters${m[1]}(S3Bucket|S3VersionKey|ArtifactHash)([a-zA-Z0-9]{8})`), - `Asset${ix}$1`, - ]); - // Substring asset hash reference - stringSubstitutions.push([ - new RegExp(`${m[1]}`), - `Asset${ix}Hash`, - ]); - } - - // Substitute them out - return substitute(template); - - function substitute(what: any): any { - if (Array.isArray(what)) { - return what.map(substitute); - } - - if (typeof what === 'object' && what !== null) { - const ret: any = {}; - for (const [k, v] of Object.entries(what)) { - ret[stringSub(k)] = substitute(v); - } - return ret; - } - - if (typeof what === 'string') { - return stringSub(what); - } - - return what; - } - - function stringSub(x: string) { - for (const [re, replacement] of stringSubstitutions) { - x = x.replace(re, replacement); - } - return x; - } -} diff --git a/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts b/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts deleted file mode 100644 index 99626ea53bdb2..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/private/cloud-assembly.ts +++ /dev/null @@ -1,66 +0,0 @@ -import * as path from 'path'; -import { AssemblyManifest, Manifest, ArtifactType, AwsCloudFormationStackProperties } from '@aws-cdk/cloud-assembly-schema'; -import * as fs from 'fs-extra'; - -/** - * Reads a Cloud Assembly manifest - */ -export class AssemblyManifestReader { - public static readonly DEFAULT_FILENAME = 'manifest.json'; - - /** - * Reads a Cloud Assembly manifest from a file - */ - public static fromFile(fileName: string): AssemblyManifestReader { - try { - const obj = Manifest.loadAssemblyManifest(fileName); - return new AssemblyManifestReader(path.dirname(fileName), obj); - - } catch (e) { - throw new Error(`Cannot read integ manifest '${fileName}': ${e.message}`); - } - } - - /** - * Reads a Cloud Assembly manifest from a file or a directory - * If the given filePath is a directory then it will look for - * a file within the directory with the DEFAULT_FILENAME - */ - public static fromPath(filePath: string): AssemblyManifestReader { - let st; - try { - st = fs.statSync(filePath); - } catch (e) { - throw new Error(`Cannot read integ manifest at '${filePath}': ${e.message}`); - } - if (st.isDirectory()) { - return AssemblyManifestReader.fromFile(path.join(filePath, AssemblyManifestReader.DEFAULT_FILENAME)); - } - return AssemblyManifestReader.fromFile(filePath); - } - - /** - * The directory where the manifest was found - */ - public readonly directory: string; - - constructor(directory: string, private readonly manifest: AssemblyManifest) { - this.directory = directory; - } - - /** - * Get the stacks from the manifest - * returns a map of artifactId to CloudFormation template - */ - public get stacks(): Record { - const stacks: Record = {}; - for (const [artifactId, artifact] of Object.entries(this.manifest.artifacts ?? {})) { - if (artifact.type !== ArtifactType.AWS_CLOUDFORMATION_STACK) { continue; } - const props = artifact.properties as AwsCloudFormationStackProperties; - - const template = fs.readJSONSync(path.resolve(this.directory, props.templateFile)); - stacks[artifactId] = template; - } - return stacks; - } -} diff --git a/packages/@aws-cdk/integ-runner/lib/runner/private/integ-manifest.ts b/packages/@aws-cdk/integ-runner/lib/runner/private/integ-manifest.ts deleted file mode 100644 index 80b567dbb69ce..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/private/integ-manifest.ts +++ /dev/null @@ -1,76 +0,0 @@ -import * as path from 'path'; -import { IntegManifest, Manifest, TestCase } from '@aws-cdk/cloud-assembly-schema'; -import * as fs from 'fs-extra'; - -/** - * Test case configuration read from the integ manifest - */ -export interface IntegTestConfig { - /** - * Test cases contained in this integration test - */ - readonly testCases: { [testCaseName: string]: TestCase }; - - /** - * Whether to enable lookups for this test - * - * @default false - */ - readonly enableLookups: boolean; -} - -/** - * Reads an integration tests manifest - */ -export class IntegManifestReader { - public static readonly DEFAULT_FILENAME = 'integ.json'; - - /** - * Reads an integration test manifest from the specified file - */ - public static fromFile(fileName: string): IntegManifestReader { - try { - const obj = Manifest.loadIntegManifest(fileName); - return new IntegManifestReader(path.dirname(fileName), obj); - - } catch (e) { - throw new Error(`Cannot read integ manifest '${fileName}': ${e.message}`); - } - } - - /** - * Reads a Integration test manifest from a file or a directory - * If the given filePath is a directory then it will look for - * a file within the directory with the DEFAULT_FILENAME - */ - public static fromPath(filePath: string): IntegManifestReader { - let st; - try { - st = fs.statSync(filePath); - } catch (e) { - throw new Error(`Cannot read integ manifest at '${filePath}': ${e.message}`); - } - if (st.isDirectory()) { - return IntegManifestReader.fromFile(path.join(filePath, IntegManifestReader.DEFAULT_FILENAME)); - } - return IntegManifestReader.fromFile(filePath); - } - - /** - * The directory where the manifest was found - */ - public readonly directory: string; - constructor(directory: string, private readonly manifest: IntegManifest) { - this.directory = directory; - } - - /** - * List of integration tests in the manifest - */ - public get tests(): IntegTestConfig { - return { - testCases: this.manifest.testCases, - enableLookups: this.manifest.enableLookups ?? false, - }; - } -} diff --git a/packages/@aws-cdk/integ-runner/lib/runner/private/logger.ts b/packages/@aws-cdk/integ-runner/lib/runner/private/logger.ts deleted file mode 100644 index 55c7f80b24365..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/private/logger.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Writable } from 'stream'; -import * as util from 'util'; -import * as chalk from 'chalk'; - -type StyleFn = (str: string) => string; -const { stderr } = process; - -const logger = (stream: Writable, styles?: StyleFn[]) => (fmt: string, ...args: any[]) => { - let str = util.format(fmt, ...args); - if (styles && styles.length) { - str = styles.reduce((a, style) => style(a), str); - } - stream.write(str + '\n'); -}; - -export const print = logger(stderr); -export const error = logger(stderr, [chalk.red]); -export const warning = logger(stderr, [chalk.yellow]); -export const success = logger(stderr, [chalk.green]); -export const highlight = logger(stderr, [chalk.bold]); diff --git a/packages/@aws-cdk/integ-runner/lib/runner/runners.ts b/packages/@aws-cdk/integ-runner/lib/runner/runners.ts deleted file mode 100644 index 747d240c8f04d..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/runner/runners.ts +++ /dev/null @@ -1,606 +0,0 @@ -import * as path from 'path'; -import { Writable, WritableOptions } from 'stream'; -import { StringDecoder, NodeStringDecoder } from 'string_decoder'; -import { TestCase, RequireApproval, DefaultCdkOptions } from '@aws-cdk/cloud-assembly-schema'; -import { diffTemplate, formatDifferences } from '@aws-cdk/cloudformation-diff'; -import { AVAILABILITY_ZONE_FALLBACK_CONTEXT_KEY, FUTURE_FLAGS, TARGET_PARTITIONS } from '@aws-cdk/cx-api'; -import { CdkCliWrapper, ICdk } from 'cdk-cli-wrapper'; -import * as fs from 'fs-extra'; -import { Diagnostic, DiagnosticReason } from '../workers/common'; -import { canonicalizeTemplate } from './private/canonicalize-assets'; -import { AssemblyManifestReader } from './private/cloud-assembly'; -import { IntegManifestReader } from './private/integ-manifest'; - -const CDK_OUTDIR_PREFIX = 'cdk-integ.out'; -const CDK_INTEG_STACK_PRAGMA = '/// !cdk-integ'; -const PRAGMA_PREFIX = 'pragma:'; -const SET_CONTEXT_PRAGMA_PREFIX = 'pragma:set-context:'; -const VERIFY_ASSET_HASHES = 'pragma:include-assets-hashes'; -const ENABLE_LOOKUPS_PRAGMA = 'pragma:enable-lookups'; - -/** - * Options for creating an integration test runner - */ -export interface IntegRunnerOptions { - /** - * The name of the file that contains the integration test - * This should be a JavaScript file - */ - readonly fileName: string, - - /** - * Additional environment variables that will be available - * to the CDK CLI - * - * @default - no additional environment variables - */ - readonly env?: { [name: string]: string }, - - /** - * tmp cdk.out directory - * - * @default - directory will be `cdk-integ.out.${testName}` - */ - readonly integOutDir?: string, - - /** - * Instance of the CDK CLI to use - * - * @default - CdkCliWrapper - */ - readonly cdk?: ICdk; -} - -/** - * Represents an Integration test runner - */ -export abstract class IntegRunner { - /** - * The directory where the snapshot will be stored - */ - public readonly snapshotDir: string; - - /** - * An instance of the CDK CLI - */ - public readonly cdk: ICdk; - - /** - * Pretty name of the test - */ - public readonly testName: string; - - /** - * The path to the integration test file - */ - protected readonly sourceFilePath: string; - - /** - * The value used in the '--app' CLI parameter - */ - protected readonly cdkApp: string; - - /** - * The path where the `cdk.context.json` file - * will be created - */ - protected readonly cdkContextPath: string; - - /** - * The relative path from the cwd to the snapshot directory - */ - protected readonly relativeSnapshotDir: string; - - /** - * The integration tests that this runner will execute - */ - protected _tests?: { [testName: string]: TestCase }; - - /** - * The working directory that the integration tests will be - * executed from - */ - protected readonly directory: string; - - /** - * Default options to pass to the CDK CLI - */ - protected readonly defaultArgs: DefaultCdkOptions = { - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - } - - private _enableLookups?: boolean; - - /** - * The directory where the CDK will be synthed to - */ - protected readonly cdkOutDir: string; - - constructor(options: IntegRunnerOptions) { - const parsed = path.parse(options.fileName); - this.directory = parsed.dir; - this.testName = parsed.name.slice(6); - this.snapshotDir = path.join(this.directory, `${this.testName}.integ.snapshot`); - this.relativeSnapshotDir = `${this.testName}.integ.snapshot`; - this.sourceFilePath = path.join(this.directory, parsed.base); - this.cdkContextPath = path.join(this.directory, 'cdk.context.json'); - this.cdk = options.cdk ?? new CdkCliWrapper({ - directory: this.directory, - env: options.env, - }); - this.cdkOutDir = options.integOutDir ?? `${CDK_OUTDIR_PREFIX}.${this.testName}`; - this.cdkApp = `node ${parsed.base}`; - if (this.hasSnapshot()) { - this.loadManifest(); - } - } - - /** - * Whether or not lookups are enabled for a given test case - */ - protected get enableLookups(): boolean { - return this._enableLookups ?? false; - } - - /** - * Return this list of test cases for this integration test - */ - public get tests(): { [testName: string]: TestCase } | undefined { - return this._tests; - } - - /** - * Returns true if a snapshot already exists for this test - */ - public hasSnapshot(): boolean { - if (fs.existsSync(this.snapshotDir)) { - return true; - } else { - return false; - } - } - - protected loadManifest(dir?: string): void { - try { - const reader = IntegManifestReader.fromPath(dir ?? this.snapshotDir); - this._tests = reader.tests.testCases; - this._enableLookups = reader.tests.enableLookups; - } catch (e) { - this._tests = this.renderTestCasesForLegacyTests(); - this._enableLookups = this.pragmas().includes(ENABLE_LOOKUPS_PRAGMA); - } - } - - protected cleanup(): void { - const cdkOutPath = path.join(this.directory, this.cdkOutDir); - if (fs.existsSync(cdkOutPath)) { - fs.removeSync(cdkOutPath); - } - } - - protected createSnapshot(): void { - if (fs.existsSync(this.snapshotDir)) { - fs.removeSync(this.snapshotDir); - } - - // if lookups are enabled then we need to synth again - // using dummy context and save that as the snapshot - if (this.enableLookups) { - this.writeContext(); - this.cdk.synth({ - ...this.defaultArgs, - all: true, - app: this.cdkApp, - output: this.relativeSnapshotDir, - // TODO: figure out if we need this... - // env: { - // ...DEFAULT_SYNTH_OPTIONS.env, - // }, - }); - this.cleanupContextFile(); - } else { - fs.moveSync(path.join(this.directory, this.cdkOutDir), this.snapshotDir, { overwrite: true }); - } - } - - /** - * Returns the single test stack to use. - * - * If the test has a single stack, it will be chosen. Otherwise a pragma is expected within the - * test file the name of the stack: - * - * @example - * - * /// !cdk-integ - * - */ - private renderTestCasesForLegacyTests(): { [testName: string]: TestCase } { - const tests: TestCase = { - stacks: [], - }; - const pragma = this.readStackPragma(); - if (pragma.length > 0) { - tests.stacks.push(...pragma); - } else { - const stacks = (this.cdk.list({ - ...this.defaultArgs, - all: true, - app: this.cdkApp, - output: this.cdkOutDir, - })).split('\n'); - if (stacks.length !== 1) { - throw new Error('"cdk-integ" can only operate on apps with a single stack.\n\n' + - ' If your app has multiple stacks, specify which stack to select by adding this to your test source:\n\n' + - ` ${CDK_INTEG_STACK_PRAGMA} STACK ...\n\n` + - ` Available stacks: ${stacks.join(' ')} (wildcards are also supported)\n`); - } - tests.stacks.push(...stacks); - } - - return { - [this.testName]: tests, - }; - } - - /** - * Reads stack names from the "!cdk-integ" pragma. - * - * Every word that's NOT prefixed by "pragma:" is considered a stack name. - * - * @example - * - * /// !cdk-integ - */ - private readStackPragma(): string[] { - return (this.readIntegPragma()).filter(p => !p.startsWith(PRAGMA_PREFIX)); - } - - /** - * Read arbitrary cdk-integ pragma directives - * - * Reads the test source file and looks for the "!cdk-integ" pragma. If it exists, returns it's - * contents. This allows integ tests to supply custom command line arguments to "cdk deploy" and "cdk synth". - * - * @example - * - * /// !cdk-integ [...] - */ - private readIntegPragma(): string[] { - const source = fs.readFileSync(this.sourceFilePath, { encoding: 'utf-8' }); - const pragmaLine = source.split('\n').find(x => x.startsWith(CDK_INTEG_STACK_PRAGMA + ' ')); - if (!pragmaLine) { - return []; - } - - const args = pragmaLine.substring(CDK_INTEG_STACK_PRAGMA.length).trim().split(' '); - if (args.length === 0) { - throw new Error(`Invalid syntax for cdk-integ pragma. Usage: "${CDK_INTEG_STACK_PRAGMA} [STACK] [pragma:PRAGMA] [...]"`); - } - return args; - } - - /** - * Return the non-stack pragmas - * - * These are all pragmas that start with "pragma:". - * - * For backwards compatibility reasons, all pragmas that DON'T start with this - * string are considered to be stack names. - */ - protected pragmas(): string[] { - return (this.readIntegPragma()).filter(p => p.startsWith(PRAGMA_PREFIX)); - } - - /** - * There is not currently a way to pass structured context to the CLI - * so to workaround this we write the context to a file - */ - protected writeContext(additionalContext?: Record): void { - const ctxPragmaContext: Record = {}; - - // apply context from set-context pragma - // usage: pragma:set-context:key=value - const ctxPragmas = (this.pragmas()).filter(p => p.startsWith(SET_CONTEXT_PRAGMA_PREFIX)); - for (const p of ctxPragmas) { - const instruction = p.substring(SET_CONTEXT_PRAGMA_PREFIX.length); - const [key, value] = instruction.split('='); - if (key == null || value == null) { - throw new Error(`invalid "set-context" pragma syntax. example: "pragma:set-context:@aws-cdk/core:newStyleStackSynthesis=true" got: ${p}`); - } - - ctxPragmaContext[key] = value; - } - const context: Record = { - ...DEFAULT_SYNTH_OPTIONS.context, - ...ctxPragmaContext, - ...additionalContext, - }; - fs.writeFileSync(this.cdkContextPath, JSON.stringify(context, undefined, 2), { encoding: 'utf-8' }); - } - - protected cleanupContextFile() { - if (fs.existsSync(this.cdkContextPath)) { - fs.unlinkSync(this.cdkContextPath); - } - } -} - -/** - * Options for the integration test runner - */ -export interface IntegTestRunOptions { - /** - * The test case to execute - */ - readonly testCase: TestCase; - - /** - * Whether or not to run `cdk destroy` and cleanup the - * integration test stacks. - * - * Set this to false if you need to perform any validation - * or troubleshooting after deployment. - * - * @default true - */ - readonly clean?: boolean; - - /** - * If set to true, the integration test will not deploy - * anything and will simply update the snapshot. - * - * You should NOT use this method since you are essentially - * bypassing the integration test. - * - * @default false - */ - readonly dryRun?: boolean; -} - -/** - * An integration test runner that orchestrates executing - * integration tests - */ -export class IntegTestRunner extends IntegRunner { - constructor(options: IntegRunnerOptions) { - super(options); - } - - /** - * Orchestrates running integration tests. Currently this includes - * - * 1. Deploying the integration test stacks - * 2. Saving the snapshot - * 3. Destroying the integration test stacks - */ - public runIntegTestCase(options: IntegTestRunOptions): void { - const clean = options.clean ?? true; - try { - if (!options.dryRun) { - this.cdk.deploy({ - ...this.defaultArgs, - stacks: options.testCase.stacks, - requireApproval: RequireApproval.NEVER, - output: this.cdkOutDir, - app: this.cdkApp, - lookups: this.enableLookups, - }); - } else { - this.cdk.synth({ - ...this.defaultArgs, - stacks: options.testCase.stacks, - output: this.cdkOutDir, - app: this.cdkApp, - lookups: this.enableLookups, - }); - } - this.createSnapshot(); - } catch (e) { - throw e; - } finally { - if (!options.dryRun) { - if (clean) { - this.cdk.destroy({ - ...this.defaultArgs, - stacks: options.testCase.stacks, - force: true, - app: this.cdkApp, - output: this.cdkOutDir, - }); - } - } - this.cleanup(); - } - } - - /** - * Generate a snapshot if one does not exist - * This will synth and then load the integration test manifest - */ - public generateSnapshot(): void { - if (this.hasSnapshot()) { - throw new Error(`${this.testName} already has a snapshot: ${this.snapshotDir}`); - } - - this.cdk.synth({ - ...this.defaultArgs, - all: true, - app: this.cdkApp, - output: this.cdkOutDir, - }); - this.loadManifest(this.cdkOutDir); - } -} - -/** - * Runner for snapshot tests. This handles orchestrating - * the validation of the integration test snapshots - */ -export class IntegSnapshotRunner extends IntegRunner { - constructor(options: IntegRunnerOptions) { - super(options); - } - - /** - * Synth the integration tests and compare the templates - * to the existing snapshot. - */ - public testSnapshot(): Diagnostic[] { - try { - // read the existing snapshot - const expectedStacks = this.readAssembly(this.snapshotDir); - - // if lookups are enabled then write the dummy context file - if (this.enableLookups) { - this.writeContext(); - } - // synth the integration test - this.cdk.synth({ - ...this.defaultArgs, - all: true, - app: this.cdkApp, - output: this.cdkOutDir, - lookups: this.enableLookups, - }); - const actualStacks = this.readAssembly(path.join(this.directory, this.cdkOutDir)); - - // diff the existing snapshot (expected) with the integration test (actual) - const diagnostics = this.diffAssembly(expectedStacks, actualStacks); - return diagnostics; - } catch (e) { - throw e; - } finally { - this.cleanupContextFile(); - this.cleanup(); - } - } - - private diffAssembly(existing: Record, actual: Record): Diagnostic[] { - const verifyHashes = this.pragmas().includes(VERIFY_ASSET_HASHES); - const failures: Diagnostic[] = []; - for (const templateId of Object.keys(existing)) { - if (!actual.hasOwnProperty(templateId)) { - failures.push({ - testName: this.testName, - reason: DiagnosticReason.SNAPSHOT_FAILED, - message: `${templateId} exists in snapshot, but not in actual`, - }); - } - } - - for (const templateId of Object.keys(actual)) { - if (!existing.hasOwnProperty(templateId)) { - failures.push({ - testName: this.testName, - reason: DiagnosticReason.SNAPSHOT_FAILED, - message: `${templateId} does not exist in snapshot, but does in actual`, - }); - } else { - let actualTemplate = actual[templateId]; - let expectedTemplate = existing[templateId]; - - if (!verifyHashes) { - actualTemplate = canonicalizeTemplate(actualTemplate); - expectedTemplate = canonicalizeTemplate(expectedTemplate); - } - const diff = diffTemplate(expectedTemplate, actualTemplate); - if (!diff.isEmpty) { - const writable = new StringWritable({}); - formatDifferences(writable, diff); - failures.push({ - reason: DiagnosticReason.SNAPSHOT_FAILED, - message: writable.data, - testName: this.testName, - }); - } - } - } - - return failures; - } - - private readAssembly(dir: string): Record { - const assembly = AssemblyManifestReader.fromPath(dir); - const stacks = assembly.stacks; - - return stacks; - } -} - -class StringWritable extends Writable { - public data: string; - private _decoder: NodeStringDecoder; - constructor(options: WritableOptions) { - super(options); - this._decoder = new StringDecoder(); - this.data = ''; - } - - _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void { - if (encoding === 'buffer') { - chunk = this._decoder.write(chunk); - } - - this.data += chunk; - callback(); - } - - _final(callback: (error?: Error | null) => void): void { - this.data += this._decoder.end(); - callback(); - } -} - -// Default context we run all integ tests with, so they don't depend on the -// account of the exercising user. -const DEFAULT_SYNTH_OPTIONS = { - context: { - [AVAILABILITY_ZONE_FALLBACK_CONTEXT_KEY]: ['test-region-1a', 'test-region-1b', 'test-region-1c'], - 'availability-zones:account=12345678:region=test-region': ['test-region-1a', 'test-region-1b', 'test-region-1c'], - 'ssm:account=12345678:parameterName=/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2:region=test-region': 'ami-1234', - 'ssm:account=12345678:parameterName=/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2:region=test-region': 'ami-1234', - 'ssm:account=12345678:parameterName=/aws/service/ecs/optimized-ami/amazon-linux/recommended:region=test-region': '{"image_id": "ami-1234"}', - // eslint-disable-next-line max-len - 'ami:account=12345678:filters.image-type.0=machine:filters.name.0=amzn-ami-vpc-nat-*:filters.state.0=available:owners.0=amazon:region=test-region': 'ami-1234', - 'vpc-provider:account=12345678:filter.isDefault=true:region=test-region:returnAsymmetricSubnets=true': { - vpcId: 'vpc-60900905', - subnetGroups: [ - { - type: 'Public', - name: 'Public', - subnets: [ - { - subnetId: 'subnet-e19455ca', - availabilityZone: 'us-east-1a', - routeTableId: 'rtb-e19455ca', - }, - { - subnetId: 'subnet-e0c24797', - availabilityZone: 'us-east-1b', - routeTableId: 'rtb-e0c24797', - }, - { - subnetId: 'subnet-ccd77395', - availabilityZone: 'us-east-1c', - routeTableId: 'rtb-ccd77395', - }, - ], - }, - ], - }, - // Enable feature flags for all integ tests - ...FUTURE_FLAGS, - - // Restricting to these target partitions makes most service principals synthesize to - // `service.${URL_SUFFIX}`, which is technically *incorrect* (it's only `amazonaws.com` - // or `amazonaws.com.cn`, never UrlSuffix for any of the restricted regions) but it's what - // most existing integ tests contain, and we want to disturb as few as possible. - [TARGET_PARTITIONS]: ['aws', 'aws-cn'], - }, - env: { - CDK_INTEG_ACCOUNT: '12345678', - CDK_INTEG_REGION: 'test-region', - }, -}; diff --git a/packages/@aws-cdk/integ-runner/lib/workers/common.ts b/packages/@aws-cdk/integ-runner/lib/workers/common.ts deleted file mode 100644 index db196cc809937..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/workers/common.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { IntegTestConfig } from '../runner/integ-tests'; -import * as logger from '../runner/private/logger'; - -/** - * Integration test results - */ -export interface IntegBatchResponse { - failedTests: IntegTestConfig[]; -} - -/** - * Common options for running integration tests - */ -export interface IntegTestOptions { - /** - * A list of integration tests to run - * in this batch - */ - readonly tests: IntegTestConfig[]; - - /** - * Whether or not to destroy the stacks at the - * end of the test - * - * @default true - */ - readonly clean?: boolean; - - /** - * When this is set to `true` the snapshot will - * be created _without_ running the integration test - * The resulting snapshot SHOULD NOT be checked in - * - * @default false - */ - readonly dryRun?: boolean; - - /** - * Whether to enable verbose logging - * - * @default false - */ - readonly verbose?: boolean; -} - -/** - * Represents possible reasons for a diagnostic - */ -export enum DiagnosticReason { - /** - * The integration test failed because there - * is not existing snapshot - */ - NO_SNAPSHOT = 'NO_SNAPSHOT', - - /** - * The integration test failed - */ - TEST_FAILED = 'TEST_FAILED', - - /** - * The snapshot test failed because the actual - * snapshot was different than the expected snapshot - */ - SNAPSHOT_FAILED = 'SNAPSHOT_FAILED', - - /** - * The snapshot test succeeded - */ - SNAPSHOT_SUCCESS = 'SNAPSHOT_SUCCESS', - - /** - * The integration test succeeded - */ - TEST_SUCCESS = 'TEST_SUCCESS', -} - -/** - * Integration test diagnostics - * This is used to report back the status of each test - */ -export interface Diagnostic { - /** - * The name of the test - */ - readonly testName: string; - - /** - * The diagnostic message - */ - readonly message: string; - - /** - * The reason for the diagnostic - */ - readonly reason: DiagnosticReason; -} - -/** - * Print out the results from tests - */ -export function printResults(diagnostic: Diagnostic): void { - switch (diagnostic.reason) { - case DiagnosticReason.SNAPSHOT_SUCCESS: - logger.success(' %s No Change!', diagnostic.testName); - break; - case DiagnosticReason.TEST_SUCCESS: - logger.success(' %s Test Succeeded!', diagnostic.testName); - break; - case DiagnosticReason.NO_SNAPSHOT: - logger.error(' %s - No Snapshot!', diagnostic.testName); - break; - case DiagnosticReason.SNAPSHOT_FAILED: - logger.error(' %s - Snapshot changed!\n%s', diagnostic.testName, diagnostic.message); - break; - case DiagnosticReason.TEST_FAILED: - logger.error(' %s - Failed!\n%s', diagnostic.testName, diagnostic.message); - } -} diff --git a/packages/@aws-cdk/integ-runner/lib/workers/extract_worker.ts b/packages/@aws-cdk/integ-runner/lib/workers/extract_worker.ts deleted file mode 100644 index 42b0e63b1f9af..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/workers/extract_worker.ts +++ /dev/null @@ -1,35 +0,0 @@ -import * as workerpool from 'workerpool'; -import { IntegTestConfig } from '../runner/integ-tests'; -import { Diagnostic, IntegBatchResponse } from './common'; -import { singleThreadedSnapshotRunner } from './integ-snapshot-worker'; -import { singleThreadedTestRunner, IntegTestBatchRequest } from './integ-test-worker'; - -/** - * Options for running snapshot tests - */ -export interface SnapshotBatchRequest { - readonly tests: IntegTestConfig[]; -} - -/** - * Snapshot test results - */ -export interface SnapshotBatchResponse { - diagnostics: Diagnostic[]; - failedTests: IntegTestConfig[]; -} - -function integTestBatch(request: IntegTestBatchRequest): IntegBatchResponse { - const result = singleThreadedTestRunner(request); - return result; -} - -function snapshotTestBatch(request: SnapshotBatchRequest): IntegBatchResponse { - const result = singleThreadedSnapshotRunner(request.tests); - return result; -} - -workerpool.worker({ - snapshotTestBatch, - integTestBatch, -}); diff --git a/packages/@aws-cdk/integ-runner/lib/workers/integ-snapshot-worker.ts b/packages/@aws-cdk/integ-runner/lib/workers/integ-snapshot-worker.ts deleted file mode 100644 index f92efe543746a..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/workers/integ-snapshot-worker.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as workerpool from 'workerpool'; -import { IntegTestConfig } from '../runner/integ-tests'; -import { IntegSnapshotRunner } from '../runner/runners'; -import { DiagnosticReason, IntegBatchResponse } from './common'; - -/** - * Runs a single snapshot test batch request. - * For each integration test this will check to see - * if there is an existing snapshot, and if there is will - * check if there are any changes - */ -export function singleThreadedSnapshotRunner(tests: IntegTestConfig[]): IntegBatchResponse { - const failedTests = new Array(); - for (const test of tests) { - const runner = new IntegSnapshotRunner({ fileName: test.fileName }); - try { - if (!runner.hasSnapshot()) { - workerpool.workerEmit({ - reason: DiagnosticReason.NO_SNAPSHOT, - testName: runner.testName, - message: 'No Snapshot', - }); - failedTests.push(test); - } else { - const snapshotDiagnostics = runner.testSnapshot(); - if (snapshotDiagnostics.length > 0) { - snapshotDiagnostics.forEach(diagnostic => workerpool.workerEmit(diagnostic)); - failedTests.push(test); - } else { - workerpool.workerEmit({ - reason: DiagnosticReason.SNAPSHOT_SUCCESS, - testName: runner.testName, - message: 'Success', - }); - } - } - } catch (e) { - failedTests.push(test); - workerpool.workerEmit({ - message: e.message, - testName: runner.testName, - reason: DiagnosticReason.SNAPSHOT_FAILED, - }); - } - } - - return { - failedTests, - }; -} - diff --git a/packages/@aws-cdk/integ-runner/lib/workers/integ-test-worker.ts b/packages/@aws-cdk/integ-runner/lib/workers/integ-test-worker.ts deleted file mode 100644 index def9915d91c35..0000000000000 --- a/packages/@aws-cdk/integ-runner/lib/workers/integ-test-worker.ts +++ /dev/null @@ -1,124 +0,0 @@ -import * as workerpool from 'workerpool'; -import { IntegTestConfig } from '../runner/integ-tests'; -import * as logger from '../runner/private/logger'; -import { IntegTestRunner } from '../runner/runners'; -import { printResults, IntegBatchResponse, IntegTestOptions, DiagnosticReason } from './common'; - -/** - * Options for an integration test batch - */ -export interface IntegTestBatchRequest extends IntegTestOptions { - /** - * The AWS region to run this batch in - */ - readonly region: string; -} - -/** - * Options for running all integration tests - */ -export interface IntegTestRunOptions extends IntegTestOptions { - /** - * The regions to run the integration tests across. - * This allows the runner to run integration tests in parallel - */ - readonly regions: string[]; - - /** - * The workerpool to use - */ - readonly pool: workerpool.WorkerPool; -} - - -/** - * Runs a set of integration tests in parallel across a list of AWS regions. - * Only a single test can be run at a time in a given region. Once a region - * is done running a test, the next test will be pulled from the queue - */ -export async function runIntegrationTestsInParallel( - options: IntegTestRunOptions, -): Promise { - - const queue = options.tests; - const results: IntegBatchResponse[] = []; - - async function runTest(region: string): Promise { - do { - const test = queue.pop(); - if (!test) break; - logger.highlight(`Running test ${test.fileName} in ${region}`); - const response: IntegBatchResponse = await options.pool.exec('integTestBatch', [{ - region, - tests: [test], - clean: options.clean, - dryRun: options.dryRun, - verbose: options.verbose, - }], { - on: printResults, - }); - - results.push(response); - } while (queue.length > 0); - } - - const workers = options.regions.map((region) => runTest(region)); - await Promise.all(workers); - return results; -} - -/** - * Runs a single integration test batch request. - * If the test does not have an existing snapshot, - * this will first generate a snapshot and then execute - * the integration tests. - * - * If the tests succeed it will then save the snapshot - */ -export function singleThreadedTestRunner(request: IntegTestBatchRequest): IntegBatchResponse { - const failures: IntegTestConfig[] = []; - for (const test of request.tests) { - const runner = new IntegTestRunner({ - fileName: test.fileName, - env: { - AWS_REGION: request.region, - }, - }); - try { - if (!runner.hasSnapshot()) { - runner.generateSnapshot(); - } - - if (!runner.tests) { - throw new Error(`No tests defined for ${runner.testName}`); - } - for (const [testName, testCase] of Object.entries(runner.tests)) { - try { - runner.runIntegTestCase({ - testCase: testCase, - clean: request.clean, - dryRun: request.dryRun, - }); - workerpool.workerEmit({ - reason: DiagnosticReason.TEST_SUCCESS, - testName: testName, - message: 'Success', - }); - } catch (e) { - failures.push(test); - workerpool.workerEmit({ - reason: DiagnosticReason.TEST_FAILED, - testName: testName, - message: `Integration test failed: ${e}`, - }); - } - } - } catch (e) { - logger.error(`Errors running test cases: ${e}`); - } - } - - return { - failedTests: failures, - }; -} diff --git a/packages/@aws-cdk/integ-runner/package.json b/packages/@aws-cdk/integ-runner/package.json deleted file mode 100644 index af90b78aef132..0000000000000 --- a/packages/@aws-cdk/integ-runner/package.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "name": "@aws-cdk/integ-runner", - "description": "CDK Integration Testing Tool", - "version": "0.0.0", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "bin": { - "integ-runner": "bin/integ-runner" - }, - "scripts": { - "build": "cdk-build", - "lint": "cdk-lint", - "package": "cdk-package", - "awslint": "cdk-awslint", - "pkglint": "pkglint -f", - "test": "cdk-test", - "watch": "cdk-watch", - "build+test": "yarn build && yarn test", - "build+test+package": "yarn build+test && yarn package", - "compat": "cdk-compat", - "build+extract": "yarn build", - "build+test+extract": "yarn build+test" - }, - "author": { - "name": "Amazon Web Services", - "url": "https://aws.amazon.com", - "organization": true - }, - "license": "Apache-2.0", - "devDependencies": { - "@aws-cdk/cdk-build-tools": "0.0.0", - "@aws-cdk/pkglint": "0.0.0", - "@types/fs-extra": "^8.1.2", - "@types/jest": "^27.4.1", - "@types/node": "^10.17.60", - "@types/workerpool": "^6.1.0", - "@types/yargs": "^15.0.14", - "jest": "^27.5.1" - }, - "dependencies": { - "@aws-cdk/cloud-assembly-schema": "0.0.0", - "@aws-cdk/cloudformation-diff": "0.0.0", - "@aws-cdk/cx-api": "0.0.0", - "aws-cdk": "0.0.0", - "cdk-cli-wrapper": "0.0.0", - "chalk": "^4", - "fs-extra": "^9.1.0", - "workerpool": "^6.2.0", - "yargs": "^16.2.0" - }, - "repository": { - "url": "https://github.com/aws/aws-cdk.git", - "type": "git", - "directory": "packages/@aws-cdk/integ-runner" - }, - "keywords": [ - "aws", - "cdk" - ], - "homepage": "https://github.com/aws/aws-cdk", - "engines": { - "node": ">= 10.13.0 <13 || >=13.7.0" - }, - "cdk-package": { - "shrinkWrap": true - }, - "nozem": { - "ostools": [ - "unzip", - "diff", - "rm" - ] - }, - "stability": "experimental", - "maturity": "experimental", - "publishConfig": { - "tag": "latest" - } -} diff --git a/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts b/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts deleted file mode 100644 index 878f5bf5d2489..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as path from 'path'; -import { IntegrationTests } from '../../lib/runner/integ-tests'; - -const directory = path.join(__dirname, '../test-data'); - -describe('IntegrationTests', () => { - test('from cli args', async () => { - const tests = new IntegrationTests(directory); - - const integTests = await tests.fromCliArgs(['integ.integ-test1.js']); - - expect(integTests.length).toEqual(1); - expect(integTests[0].fileName).toEqual(expect.stringMatching(/integ.integ-test1.js$/)); - }); -}); diff --git a/packages/@aws-cdk/integ-runner/test/runner/runners.test.ts b/packages/@aws-cdk/integ-runner/test/runner/runners.test.ts deleted file mode 100644 index 8894f5ba92843..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/runner/runners.test.ts +++ /dev/null @@ -1,324 +0,0 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; -import { IntegTestRunner, IntegSnapshotRunner } from '../../lib/runner/runners'; -import { DiagnosticReason } from '../../lib/workers/common'; - -describe('IntegTest runSnapshotTests', () => { - let synthMock: jest.SpyInstance; - beforeEach(() => { - jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); - }); - afterEach(() => { - jest.clearAllMocks(); - jest.resetAllMocks(); - jest.restoreAllMocks(); - }); - test('with defaults no diff', () => { - // WHEN - const integTest = new IntegSnapshotRunner({ - fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot.js'), - integOutDir: 'test-with-snapshot.integ.snapshot', - }); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - integTest.testSnapshot(); - - // THEN - expect(synthMock).toHaveBeenCalledTimes(1); - expect(synthMock.mock.calls[0][0]).toEqual({ - all: true, - app: 'node integ.test-with-snapshot.js', - output: 'test-with-snapshot.integ.snapshot', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - lookups: false, - }); - }); - - test('with defaults and diff', () => { - // WHEN - const integTest = new IntegSnapshotRunner({ - fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot.js'), - integOutDir: 'test-with-snapshot-diff.integ.snapshot', - }); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - const diagnostics = integTest.testSnapshot(); - - // THEN - expect(synthMock).toHaveBeenCalledTimes(1); - expect(synthMock.mock.calls[0][0]).toEqual({ - all: true, - app: 'node integ.test-with-snapshot.js', - output: 'test-with-snapshot-diff.integ.snapshot', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - lookups: false, - }); - expect(diagnostics).toEqual(expect.arrayContaining([expect.objectContaining({ - reason: DiagnosticReason.SNAPSHOT_FAILED, - testName: integTest.testName, - message: expect.stringContaining('foobar'), - })])); - }); - - test('dont diff asset hashes', () => { - // WHEN - const integTest = new IntegSnapshotRunner({ - fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot-assets-diff.js'), - integOutDir: 'test-with-snapshot-assets.integ.snapshot', - }); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - expect(() => { - integTest.testSnapshot(); - }).not.toThrow(); - - // THEN - expect(synthMock).toHaveBeenCalledTimes(1); - expect(synthMock.mock.calls[0][0]).toEqual({ - all: true, - app: 'node integ.test-with-snapshot-assets-diff.js', - output: 'test-with-snapshot-assets.integ.snapshot', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - lookups: true, - }); - }); - - test('diff asset hashes', () => { - // WHEN - const integTest = new IntegSnapshotRunner({ - fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot-assets.js'), - integOutDir: 'test-with-snapshot-assets-diff.integ.snapshot', - }); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - const diagnostics = integTest.testSnapshot(); - - // THEN - expect(synthMock).toHaveBeenCalledTimes(1); - expect(synthMock.mock.calls[0][0]).toEqual({ - all: true, - app: 'node integ.test-with-snapshot-assets.js', - output: 'test-with-snapshot-assets-diff.integ.snapshot', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - lookups: false, - }); - expect(diagnostics).toEqual(expect.arrayContaining([expect.objectContaining({ - reason: DiagnosticReason.SNAPSHOT_FAILED, - testName: integTest.testName, - message: expect.stringContaining('Parameters'), - })])); - }); -}); - -describe('IntegTest runIntegTests', () => { - let integTest: IntegTestRunner; - let deployMock: jest.SpyInstance; - let destroyMock: jest.SpyInstance; - let synthMock: jest.SpyInstance; - let listMock: jest.SpyInstance; - // let stderrMock: jest.SpyInstance; - beforeEach(() => { - integTest = new IntegTestRunner({ fileName: path.join(__dirname, '../test-data/integ.integ-test1.js') }); - deployMock = jest.spyOn(integTest.cdk, 'deploy').mockImplementation(); - destroyMock = jest.spyOn(integTest.cdk, 'destroy').mockImplementation(); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - listMock = jest.spyOn(integTest.cdk, 'list').mockImplementation(); - jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); - }); - afterEach(() => { - jest.clearAllMocks(); - jest.resetAllMocks(); - jest.restoreAllMocks(); - }); - test('with defaults', () => { - // WHEN - integTest.runIntegTestCase({ - testCase: { - stacks: ['stack1'], - }, - }); - - // THEN - expect(deployMock).toHaveBeenCalledTimes(1); - expect(destroyMock).toHaveBeenCalledTimes(1); - expect(synthMock).toHaveBeenCalledTimes(0); - expect(deployMock.mock.calls[0][0]).toEqual({ - app: 'node integ.integ-test1.js', - requireApproval: 'never', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - lookups: false, - stacks: ['stack1'], - output: 'cdk-integ.out.integ-test1', - }); - expect(destroyMock.mock.calls[0][0]).toEqual({ - app: 'node integ.integ-test1.js', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - force: true, - stacks: ['stack1'], - output: 'cdk-integ.out.integ-test1', - }); - }); - - test('with lookups', () => { - // WHEN - integTest = new IntegTestRunner({ fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot-assets-diff.js') }); - deployMock = jest.spyOn(integTest.cdk, 'deploy').mockImplementation(); - destroyMock = jest.spyOn(integTest.cdk, 'destroy').mockImplementation(); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - listMock = jest.spyOn(integTest.cdk, 'list').mockImplementation(); - integTest.runIntegTestCase({ - testCase: { - stacks: ['test-stack'], - }, - }); - - // THEN - expect(deployMock).toHaveBeenCalledTimes(1); - expect(destroyMock).toHaveBeenCalledTimes(1); - expect(synthMock).toHaveBeenCalledTimes(1); - expect(deployMock.mock.calls[0][0]).toEqual({ - app: 'node integ.test-with-snapshot-assets-diff.js', - requireApproval: 'never', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - lookups: true, - stacks: ['test-stack'], - output: 'cdk-integ.out.test-with-snapshot-assets-diff', - }); - expect(synthMock.mock.calls[0][0]).toEqual({ - app: 'node integ.test-with-snapshot-assets-diff.js', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - all: true, - output: 'test-with-snapshot-assets-diff.integ.snapshot', - }); - expect(destroyMock.mock.calls[0][0]).toEqual({ - app: 'node integ.test-with-snapshot-assets-diff.js', - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - force: true, - stacks: ['test-stack'], - output: 'cdk-integ.out.test-with-snapshot-assets-diff', - }); - }); - - test('no clean', () => { - // WHEN - integTest.runIntegTestCase({ - clean: false, - testCase: { - stacks: ['stack1'], - }, - }); - - // THEN - expect(deployMock).toHaveBeenCalledTimes(1); - expect(destroyMock).toHaveBeenCalledTimes(0); - expect(synthMock).toHaveBeenCalledTimes(0); - }); - - test('dryrun', () => { - // WHEN - integTest.runIntegTestCase({ - dryRun: true, - testCase: { - stacks: ['stack1'], - }, - }); - - // THEN - expect(deployMock).toHaveBeenCalledTimes(0); - expect(destroyMock).toHaveBeenCalledTimes(0); - expect(synthMock).toHaveBeenCalledTimes(1); - }); - - test('determine test stack via pragma', () => { - // WHEN - integTest.generateSnapshot(); - - // THEN - expect(integTest.tests).toEqual(expect.objectContaining({ - 'integ-test1': { - stacks: ['stack1'], - }, - })); - expect(listMock).toHaveBeenCalledTimes(0); - }); - - test('generate snapshot', () => { - // WHEN - integTest.generateSnapshot(); - - // THEN - expect(synthMock).toHaveBeenCalledTimes(1); - expect(synthMock.mock.calls[0][0]).toEqual({ - all: true, - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - app: 'node integ.integ-test1.js', - output: 'cdk-integ.out.integ-test1', - }); - }); -}); - -describe('IntegTest no pragma', () => { - let integTest: IntegTestRunner; - let synthMock: jest.SpyInstance; - beforeEach(() => { - integTest = new IntegTestRunner({ fileName: path.join(__dirname, '../test-data/integ.integ-test2.js') }); - jest.spyOn(integTest.cdk, 'deploy').mockImplementation(); - jest.spyOn(integTest.cdk, 'destroy').mockImplementation(); - synthMock = jest.spyOn(integTest.cdk, 'synth').mockImplementation(); - jest.spyOn(integTest.cdk, 'list').mockImplementation(() => { - return 'stackabc'; - }); - jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); - }); - afterEach(() => { - jest.clearAllMocks(); - jest.resetAllMocks(); - jest.restoreAllMocks(); - }); - test('get stacks from list', async () => { - // WHEN - integTest.generateSnapshot(); - - // THEN - expect(integTest.tests).toEqual(expect.objectContaining({ - 'integ-test2': { - stacks: ['stackabc'], - }, - })); - expect(synthMock).toHaveBeenCalledTimes(1); - expect(synthMock.mock.calls[0][0]).toEqual({ - app: 'node integ.integ-test2.js', - all: true, - pathMetadata: false, - assetMetadata: false, - versionReporting: false, - output: 'cdk-integ.out.integ-test2', - }); - }); -}); diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/test-stack.template.json deleted file mode 100644 index 40f4c8238c04f..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/test-stack.template.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foo" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets-diff/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/test-stack.template.json deleted file mode 100644 index 40f4c8238c04f..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/test-stack.template.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foo" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/test-stack.template.json deleted file mode 100644 index 40f4c8238c04f..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/test-stack.template.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foo" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test1.ts b/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test1.ts deleted file mode 100644 index 26679b49d93bc..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test1.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// !cdk-integ stack1 pragma:ignore-assets -/// !cdk-integ pragma:ignore-assets diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test2.ts b/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test2.ts deleted file mode 100644 index bb0eb24f2756d..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test2.ts +++ /dev/null @@ -1 +0,0 @@ -/// !cdk-integ pragma:enable-lookups diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets-diff.ts b/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets-diff.ts deleted file mode 100644 index bcdc92fbcdcf2..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets-diff.ts +++ /dev/null @@ -1 +0,0 @@ -/// !cdk-integ test-stack pragma:enable-lookups diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets.ts b/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets.ts deleted file mode 100644 index ff230f9f7e58e..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets.ts +++ /dev/null @@ -1 +0,0 @@ -/// !cdk-integ test-stack pragma:include-assets-hashes diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot.ts b/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot.ts deleted file mode 100644 index c3548a8acffcc..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// !cdk-integ test-stack pragma:ignore-assets -/// !cdk-integ pragma:ignore-assets diff --git a/packages/@aws-cdk/integ-runner/test/test-data/not.integ-test.ts b/packages/@aws-cdk/integ-runner/test/test-data/not.integ-test.ts deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/test-stack.template.json deleted file mode 100644 index 969780cdf33e5..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/test-stack.template.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foo" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - }, - "Parameters": { - "AssetParametersDec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509S3BucketBF50F97C": { - "Type": "String", - "Description": "S3 bucket for asset \"Dec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509\"" - }, - "AssetParametersDec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509S3VersionKeyF21AC8C1": { - "Type": "String", - "Description": "S3 key for asset version \"Dec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509\"" - }, - "AssetParametersDec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509ArtifactHash5D8C129B": { - "Type": "String", - "Description": "Artifact hash for asset \"Dec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509\"" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/test-stack.template.json deleted file mode 100644 index ed2a09b94be23..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/test-stack.template.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foo" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - }, - "Parameters": { - "AssetParametersfec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509S3BucketBF50F97C": { - "Type": "String", - "Description": "S3 bucket for asset \"fec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509\"" - }, - "AssetParametersfec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509S3VersionKeyF21AC8C1": { - "Type": "String", - "Description": "S3 key for asset version \"fec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509\"" - }, - "AssetParametersfec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509ArtifactHash5D8C129B": { - "Type": "String", - "Description": "Artifact hash for asset \"fec1c56a3f23d9d27f58815e0c34c810cc02f431ac63a078f9b5d2aa44cc3509\"" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/test-stack.template.json deleted file mode 100644 index 3d62830b46139..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/test-stack.template.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foobar" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/cdk.out b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/cdk.out deleted file mode 100644 index 2efc89439fab8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/cdk.out +++ /dev/null @@ -1 +0,0 @@ -{"version":"18.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json deleted file mode 100644 index c0da3afe14484..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "version": "17.0.0", - "artifacts": { - "Tree": { - "type": "cdk:tree", - "properties": { - "file": "tree.json" - } - }, - "test-stack": { - "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", - "properties": { - "templateFile": "test-stack.template.json", - "validateOnSynth": false - }, - "metadata": { - "/test-stack/MyFunction1/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction1ServiceRole9852B06B", - "trace": [ - "new Role (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-iam/lib/role.js:50:22)", - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:82:35)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ], - "/test-stack/MyFunction1/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "MyFunction12A744C2E", - "trace": [ - "new Function (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-lambda/lib/function.js:154:26)", - "new TestStack (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:10:9)", - "Object. (/home/hallcor/work/aws-cdk/integ-test-runner/packages/@aws-cdk/aws-s3objectlambda/test/integ.lambda.js:18:1)", - "Module._compile (node:internal/modules/cjs/loader:1103:14)", - "Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)", - "Module.load (node:internal/modules/cjs/loader:981:32)", - "Function.Module._load (node:internal/modules/cjs/loader:822:12)", - "Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)", - "node:internal/main/run_main_module:17:47" - ] - } - ] - }, - "displayName": "test-stack" - } - } -} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/test-stack.template.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/test-stack.template.json deleted file mode 100644 index 40f4c8238c04f..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/test-stack.template.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "Resources": { - "MyFunction1ServiceRole9852B06B": { - "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" - ] - ] - } - ] - } - }, - "MyFunction12A744C2E": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "foo" - }, - "Role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "Handler": "index.handler", - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "MyFunction1ServiceRole9852B06B" - ] - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/tree.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/tree.json deleted file mode 100644 index b664bec74b37c..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/tree.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "version": "tree-0.1", - "tree": { - "id": "App", - "path": "", - "children": { - "Tree": { - "id": "Tree", - "path": "Tree", - "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" - } - }, - "test-stack": { - "id": "test-stack", - "path": "test-stack", - "children": { - "MyFunction1": { - "id": "MyFunction1", - "path": "test-stack/MyFunction1", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "test-stack/MyFunction1/ServiceRole", - "children": { - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/ServiceRole/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::IAM::Role", - "aws:cdk:cloudformation:props": { - "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" - ] - ] - } - ] - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "test-stack/MyFunction1/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "foo" - }, - "role": { - "Fn::GetAtt": [ - "MyFunction1ServiceRole9852B06B", - "Arn" - ] - }, - "handler": "index.handler", - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.Stack", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "@aws-cdk/core.App", - "version": "0.0.0" - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-runner/test/workers/mock-extract_worker.ts b/packages/@aws-cdk/integ-runner/test/workers/mock-extract_worker.ts deleted file mode 100644 index 7479d229302b8..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/workers/mock-extract_worker.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as workerpool from 'workerpool'; -import { IntegBatchResponse } from '../../lib/workers/common'; -import { IntegTestBatchRequest } from '../../lib/workers/integ-test-worker'; - - -function integTestBatch(request: IntegTestBatchRequest): IntegBatchResponse { - return { - failedTests: request.tests, - }; -} - -workerpool.worker({ - integTestBatch, -}); - diff --git a/packages/@aws-cdk/integ-runner/test/workers/workers.test.ts b/packages/@aws-cdk/integ-runner/test/workers/workers.test.ts deleted file mode 100644 index cc0be1ec8a9b0..0000000000000 --- a/packages/@aws-cdk/integ-runner/test/workers/workers.test.ts +++ /dev/null @@ -1,266 +0,0 @@ -import * as child_process from 'child_process'; -import * as path from 'path'; -import * as fs from 'fs-extra'; -import * as workerpool from 'workerpool'; -import { singleThreadedSnapshotRunner } from '../../lib/workers/integ-snapshot-worker'; -import { singleThreadedTestRunner, runIntegrationTestsInParallel } from '../../lib/workers/integ-test-worker'; - -const directory = path.join(__dirname, '../test-data'); -describe('Snapshot tests', () => { - beforeEach(() => { - jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); - }); - afterEach(() => { - jest.clearAllMocks(); - jest.resetAllMocks(); - jest.restoreAllMocks(); - }); - test('no snapshot', () => { - // WHEN - const test = { - fileName: path.join(directory, 'integ.integ-test1.js'), - directory: directory, - }; - const result = singleThreadedSnapshotRunner([test]); - - // THEN - expect(result.failedTests.length).toEqual(1); - expect(result.failedTests[0]).toEqual(test); - }); - - test('has snapshot', () => { - // WHEN - jest.spyOn(child_process, 'spawnSync').mockResolvedValue; - const test = { - fileName: path.join(directory, 'integ.test-with-snapshot.js'), - directory: directory, - }; - const result = singleThreadedSnapshotRunner([test]); - - // THEN - expect(result.failedTests.length).toEqual(0); - }); - - test('failed snapshot', () => { - // WHEN - jest.spyOn(child_process, 'spawnSync').mockRejectedValue; - const test = { - fileName: path.join(directory, 'integ.test-with-snapshot-assets.js'), - directory: directory, - }; - const result = singleThreadedSnapshotRunner([test]); - - // THEN - expect(result.failedTests.length).toEqual(1); - expect(result.failedTests[0]).toEqual(test); - }); -}); - -describe('test runner', () => { - beforeEach(() => { - jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); - }); - afterEach(() => { - jest.clearAllMocks(); - jest.resetAllMocks(); - jest.restoreAllMocks(); - }); - - test('no snapshot', () => { - // WHEN - const test = { - fileName: path.join(directory, 'integ.integ-test1.js'), - directory: directory, - }; - const spawnSyncMock = jest.spyOn(child_process, 'spawnSync').mockImplementation(); - singleThreadedTestRunner({ - tests: [test], - region: 'us-east-1', - }); - - expect(spawnSyncMock).toHaveBeenCalledWith( - expect.stringMatching(/cdk/), - ['synth', '--app', 'node integ.integ-test1.js', '--no-version-reporting', '--no-path-metadata', '--no-asset-metadata', '--output', 'cdk-integ.out.integ-test1', '--all'], - expect.anything(), - ); - }); -}); - -describe('parallel worker', () => { - let pool: workerpool.WorkerPool; - let stderrMock: jest.SpyInstance; - beforeEach(() => { - pool = workerpool.pool(path.join(__dirname, './mock-extract_worker.js')); - stderrMock = jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); - }); - afterEach(() => { - jest.clearAllMocks(); - jest.resetAllMocks(); - jest.restoreAllMocks(); - void pool.terminate(); - }); - test('run tests', async () => { - const tests = [{ - fileName: 'integ.test-with-snapshot.js', - directory, - }]; - const results = await runIntegrationTestsInParallel({ - tests, - pool, - regions: ['us-east-1'], - }); - - expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-1', - ); - expect(results).toEqual([ - { - failedTests: [{ - fileName: 'integ.test-with-snapshot.js', - directory, - }], - }, - ]); - }); - - test('run multiple tests', async () => { - const tests = [ - { - fileName: 'integ.test-with-snapshot.js', - directory, - }, - { - fileName: 'integ.another-test-with-snapshot.js', - directory, - }, - ]; - const results = await runIntegrationTestsInParallel({ - tests, - pool, - regions: ['us-east-1', 'us-east-2'], - }); - - expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-2', - ); - expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', - ); - expect(results).toEqual(expect.arrayContaining([ - { - failedTests: [ - { - fileName: 'integ.test-with-snapshot.js', - directory, - }, - ], - }, - { - failedTests: [ - { - fileName: 'integ.another-test-with-snapshot.js', - directory, - }, - ], - }, - ])); - }); - - test('more tests than regions', async () => { - const tests = [ - { - fileName: 'integ.test-with-snapshot.js', - directory, - }, - { - fileName: 'integ.another-test-with-snapshot.js', - directory, - }, - ]; - const results = await runIntegrationTestsInParallel({ - tests, - pool, - regions: ['us-east-1'], - }); - - expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-1', - ); - expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', - ); - expect(results).toEqual([ - { - failedTests: [ - { - fileName: 'integ.another-test-with-snapshot.js', - directory, - }, - ], - }, - { - failedTests: [ - { - fileName: 'integ.test-with-snapshot.js', - directory, - }, - ], - }, - ]); - }); - - test('more regions than tests', async () => { - const tests = [ - { - fileName: 'integ.test-with-snapshot.js', - directory, - }, - { - fileName: 'integ.another-test-with-snapshot.js', - directory, - }, - ]; - const results = await runIntegrationTestsInParallel({ - tests, - pool, - regions: ['us-east-1', 'us-east-2', 'us-west-2'], - }); - - expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-2', - ); - expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', - ); - expect(results).toEqual(expect.arrayContaining([ - { - failedTests: [ - { - fileName: 'integ.another-test-with-snapshot.js', - directory, - }, - ], - }, - { - failedTests: [ - { - fileName: 'integ.test-with-snapshot.js', - directory, - }, - ], - }, - ])); - }); -}); diff --git a/packages/@aws-cdk/integ-runner/tsconfig.json b/packages/@aws-cdk/integ-runner/tsconfig.json deleted file mode 100644 index 04e0404f04442..0000000000000 --- a/packages/@aws-cdk/integ-runner/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "commonjs", - "lib": ["es2018", "dom"], - "strict": true, - "alwaysStrict": true, - "declaration": true, - "inlineSourceMap": true, - "inlineSources": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "resolveJsonModule": true, - "composite": true, - "incremental": true - }, - "include": [ - "**/*.ts", - "**/*.d.ts", - "lib/init-templates/*/*/add-project.hook.ts" - ], - "exclude": [ - "lib/init-templates/*/typescript/**/*.ts" - ] -} - diff --git a/packages/aws-cdk/README.md b/packages/aws-cdk/README.md index 0ac2e08947ec8..f50fb6509b1f9 100644 --- a/packages/aws-cdk/README.md +++ b/packages/aws-cdk/README.md @@ -643,7 +643,7 @@ Some of the interesting keys that can be used in the JSON configuration files: ```json5 { "app": "node bin/main.js", // Command to start the CDK app (--app='node bin/main.js') - "build": "mvn package", // Specify pre-synth build (no command line option) + "build": "mvn package", // Specify pre-synth build (--build='mvn package') "context": { // Context entries (--context=key=value) "key": "value" }, diff --git a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts index 56cdb394fee31..534066445cc0b 100644 --- a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts +++ b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts @@ -360,6 +360,7 @@ const RESOURCE_TYPE_ATTRIBUTES_FORMATS: { [type: string]: { [attribute: string]: // the name attribute of the EventBus is the same as the Ref Name: parts => parts.resourceName, }, + 'AWS::DynamoDB::Table': { Arn: stdSlashResourceArnFmt }, 'AWS::AppSync::GraphQLApi': { ApiId: appsyncGraphQlApiApiIdFmt }, }; diff --git a/packages/aws-cdk/lib/cli.ts b/packages/aws-cdk/lib/cli.ts index b7c2931d233ae..1a20ed9edf279 100644 --- a/packages/aws-cdk/lib/cli.ts +++ b/packages/aws-cdk/lib/cli.ts @@ -56,6 +56,7 @@ async function parseCommandLineArguments() { .env('CDK') .usage('Usage: cdk -a COMMAND') .option('app', { type: 'string', alias: 'a', desc: 'REQUIRED: command-line for executing your app or a cloud assembly directory (e.g. "node bin/my-app.js")', requiresArg: true }) + .option('build', { type: 'string', desc: 'Command-line for a pre-synth build' }) .option('context', { type: 'array', alias: 'c', desc: 'Add contextual string parameter (KEY=VALUE)', nargs: 1, requiresArg: true }) .option('plugin', { type: 'array', alias: 'p', desc: 'Name or path of a node package that extend the CDK features. Can be specified multiple times', nargs: 1 }) .option('trace', { type: 'boolean', desc: 'Print trace for stack warnings' }) diff --git a/packages/aws-cdk/lib/settings.ts b/packages/aws-cdk/lib/settings.ts index ddb28be756292..7a213111f6c9f 100644 --- a/packages/aws-cdk/lib/settings.ts +++ b/packages/aws-cdk/lib/settings.ts @@ -265,6 +265,7 @@ export class Settings { return new Settings({ app: argv.app, browser: argv.browser, + build: argv.build, context, debug: argv.debug, tags, diff --git a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts index e5b84a1c7095c..54580f2927fc8 100644 --- a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts @@ -558,3 +558,82 @@ test('knows how to handle attributes of the AWS::Events::EventBus resource', asy }), }); }); + +test('knows how to handle attributes of the AWS::DynamoDB::Table resource', async () => { + // GIVEN + setup.setCurrentCfnStackTemplate({ + Resources: { + Table: { + Type: 'AWS::DynamoDB::Table', + Properties: { + KeySchema: [{ + AttributeName: 'name', + KeyType: 'HASH', + }], + AttributeDefinitions: [{ + AttributeName: 'name', + AttributeType: 'S', + }], + BillingMode: 'PAY_PER_REQUEST', + }, + }, + Machine: { + Type: 'AWS::StepFunctions::StateMachine', + Properties: { + DefinitionString: '{}', + StateMachineName: 'my-machine', + }, + }, + }, + }); + setup.pushStackResourceSummaries( + setup.stackSummaryOf('Table', 'AWS::DynamoDB::Table', 'my-dynamodb-table'), + ); + const cdkStackArtifact = setup.cdkStackArtifactOf({ + template: { + Resources: { + Table: { + Type: 'AWS::DynamoDB::Table', + Properties: { + KeySchema: [{ + AttributeName: 'name', + KeyType: 'HASH', + }], + AttributeDefinitions: [{ + AttributeName: 'name', + AttributeType: 'S', + }], + BillingMode: 'PAY_PER_REQUEST', + }, + }, + Machine: { + Type: 'AWS::StepFunctions::StateMachine', + Properties: { + DefinitionString: { + 'Fn::Join': ['', [ + '{"TableName":"', + { Ref: 'Table' }, + '","TableArn":"', + { 'Fn::GetAtt': ['Table', 'Arn'] }, + '"}', + ]], + }, + StateMachineName: 'my-machine', + }, + }, + }, + }, + }); + + // THEN + const result = await hotswapMockSdkProvider.tryHotswapDeployment(cdkStackArtifact); + + expect(result).not.toBeUndefined(); + expect(mockUpdateMachineDefinition).toHaveBeenCalledWith({ + stateMachineArn: 'arn:aws:states:here:123456789012:stateMachine:my-machine', + definition: JSON.stringify({ + TableName: 'my-dynamodb-table', + TableArn: 'arn:aws:dynamodb:here:123456789012:table/my-dynamodb-table', + }), + }); +}); diff --git a/packages/aws-cdk/test/settings.test.ts b/packages/aws-cdk/test/settings.test.ts index aef16e6bac946..8c2c894ae4634 100644 --- a/packages/aws-cdk/test/settings.test.ts +++ b/packages/aws-cdk/test/settings.test.ts @@ -144,3 +144,14 @@ test('should include outputs-file in settings', () => { // THEN expect(settings.get(['outputsFile'])).toEqual('my-outputs-file.json'); }); + +test('providing a build arg', () => { + // GIVEN + const settings = Settings.fromCommandLineArguments({ + _: [Command.SYNTH], + build: 'mvn package', + }); + + // THEN + expect(settings.get(['build'])).toEqual('mvn package'); +}); \ No newline at end of file diff --git a/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts b/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts index bfcd4983f776d..80bc2f407555a 100644 --- a/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts +++ b/packages/cdk-cli-wrapper/lib/cdk-wrapper.ts @@ -110,16 +110,11 @@ export class CdkCliWrapper implements ICdk { } } - private validateArgs(options: DefaultCdkOptions): void { - if (!options.stacks && !options.all) { - throw new Error('one of "app" or "stacks" must be provided'); - } - } - public list(options: ListOptions): string { const listCommandArgs: string[] = [ - ...renderBooleanArg('long', options.long), ...this.createDefaultArguments(options), + ...renderBooleanArg('long', options.long), + ...options.stacks, ]; return exec([this.cdk, 'ls', ...listCommandArgs], { @@ -133,6 +128,7 @@ export class CdkCliWrapper implements ICdk { */ public deploy(options: DeployOptions): void { const deployCommandArgs: string[] = [ + ...this.createDefaultArguments(options), ...renderBooleanArg('ci', options.ci), ...renderBooleanArg('execute', options.execute), ...renderBooleanArg('exclusively', options.exclusively), @@ -147,7 +143,7 @@ export class CdkCliWrapper implements ICdk { ...options.requireApproval ? ['--require-approval', options.requireApproval] : [], ...options.changeSetName ? ['--change-set-name', options.changeSetName] : [], ...options.toolkitStackName ? ['--toolkit-stack-name', options.toolkitStackName] : [], - ...this.createDefaultArguments(options), + ...options.stacks, ]; exec([this.cdk, 'deploy', ...deployCommandArgs], { @@ -162,9 +158,10 @@ export class CdkCliWrapper implements ICdk { */ public destroy(options: DestroyOptions): void { const destroyCommandArgs: string[] = [ + ...this.createDefaultArguments(options), ...renderBooleanArg('force', options.force), ...renderBooleanArg('exclusively', options.exclusively), - ...this.createDefaultArguments(options), + ...options.stacks, ]; exec([this.cdk, 'destroy', ...destroyCommandArgs], { @@ -179,10 +176,11 @@ export class CdkCliWrapper implements ICdk { */ public synth(options: SynthOptions): void { const synthCommandArgs: string[] = [ + ...this.createDefaultArguments(options), ...renderBooleanArg('validation', options.validation), ...renderBooleanArg('quiet', options.quiet), ...renderBooleanArg('exclusively', options.exclusively), - ...this.createDefaultArguments(options), + ...options.stacks, ]; exec([this.cdk, 'synth', ...synthCommandArgs], { @@ -211,8 +209,6 @@ export class CdkCliWrapper implements ICdk { } private createDefaultArguments(options: DefaultCdkOptions): string[] { - this.validateArgs(options); - const stacks = options.stacks ?? []; return [ ...options.app ? ['--app', options.app] : [], ...renderBooleanArg('strict', options.strict), @@ -234,8 +230,6 @@ export class CdkCliWrapper implements ICdk { ...options.caBundlePath ? ['--ca-bundle-path', options.caBundlePath] : [], ...options.roleArn ? ['--role-arn', options.roleArn] : [], ...options.output ? ['--output', options.output] : [], - ...stacks, - ...options.all ? ['--all'] : [], ]; } } diff --git a/packages/cdk-cli-wrapper/lib/commands/common.ts b/packages/cdk-cli-wrapper/lib/commands/common.ts index 01ab969b63098..78e027cd922ca 100644 --- a/packages/cdk-cli-wrapper/lib/commands/common.ts +++ b/packages/cdk-cli-wrapper/lib/commands/common.ts @@ -24,21 +24,8 @@ export enum RequireApproval { export interface DefaultCdkOptions { /** * List of stacks to deploy - * - * Requried if `all` is not set - * - * @default - [] - */ - readonly stacks?: string[]; - - /** - * Deploy all stacks - * - * Requried if `stacks` is not set - * - * @default - false */ - readonly all?: boolean; + readonly stacks: string[]; /** * command-line for executing your app or a cloud assembly directory diff --git a/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts b/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts index 5cc294f3b5b7b..2f25054632cae 100644 --- a/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts +++ b/packages/cdk-cli-wrapper/test/cdk-wrapper.test.ts @@ -1,6 +1,6 @@ import * as child_process from 'child_process'; import { CdkCliWrapper } from '../lib/cdk-wrapper'; -import { RequireApproval } from '../lib/commands'; +import { RequireApproval } from '../lib/commands/common'; let spawnSyncMock: jest.SpyInstance; beforeEach(() => { @@ -89,6 +89,8 @@ test('deploy with all arguments', () => { expect.stringMatching(/aws-cdk\/bin\/cdk/), expect.arrayContaining([ 'deploy', + '--app', + 'node bin/my-app.js', '--no-strict', '--no-trace', '--no-lookups', @@ -120,8 +122,6 @@ test('deploy with all arguments', () => { '--change-set-name', 'my-change-set', '--toolkit-stack-name', 'Toolkit', '--previous-parameters', - '--app', - 'node bin/my-app.js', 'test-stack1', ]), expect.objectContaining({ @@ -182,10 +182,10 @@ test('can parse parameters', () => { expect.stringMatching(/aws-cdk\/bin\/cdk/), [ 'deploy', - '--parameters', 'myparam=test', - '--parameters', 'test-stack1:myotherparam=test', '--app', 'node bin/my-app.js', + '--parameters', 'myparam=test', + '--parameters', 'test-stack1:myotherparam=test', 'test-stack1', ], expect.objectContaining({ @@ -246,10 +246,10 @@ test('can parse array arguments', () => { expect.stringMatching(/aws-cdk\/bin\/cdk/), [ 'deploy', - '--notification-arns', 'arn:aws:us-east-1:1111111111:some:resource', - '--notification-arns', 'arn:aws:us-east-1:1111111111:some:other-resource', '--app', 'node bin/my-app.js', + '--notification-arns', 'arn:aws:us-east-1:1111111111:some:resource', + '--notification-arns', 'arn:aws:us-east-1:1111111111:some:other-resource', 'test-stack1', ], expect.objectContaining({ @@ -355,7 +355,7 @@ test('destroy arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( expect.stringMatching(/aws-cdk\/bin\/cdk/), - ['destroy', '--force', '--no-exclusively', '--app', 'node bin/my-app.js', 'test-stack1'], + ['destroy', '--app', 'node bin/my-app.js', '--force', '--no-exclusively', 'test-stack1'], expect.objectContaining({ env: expect.objectContaining({ KEY: 'value', @@ -416,7 +416,7 @@ test('ls arguments', () => { // THEN expect(spawnSyncMock).toHaveBeenCalledWith( expect.stringMatching(/aws-cdk\/bin\/cdk/), - ['ls', '--long', '--app', 'node bin/my-app.js', '*'], + ['ls', '--app', 'node bin/my-app.js', '--long', '*'], expect.objectContaining({ env: expect.objectContaining({ KEY: 'value', diff --git a/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts b/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts index 83ca5563887e6..afc76b48bdefd 100644 --- a/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts +++ b/tools/@aws-cdk/cdk-build-tools/lib/package-info.ts @@ -83,7 +83,6 @@ export async function unitTestFiles(): Promise { } export async function hasIntegTests(): Promise { - if (currentPackageJson().name === '@aws-cdk/integ-runner') return false; const files = await listFiles('test', f => f.filename.startsWith('integ.') && f.filename.endsWith('.js')); return files.length > 0; } diff --git a/version.v1.json b/version.v1.json index 4e6db4f2ccf8c..53e80ec784dce 100644 --- a/version.v1.json +++ b/version.v1.json @@ -1,3 +1,3 @@ { - "version": "1.150.0" + "version": "1.151.0" } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 469782c499a97..dddaf06264d5a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1994,13 +1994,6 @@ resolved "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc" integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw== -"@types/workerpool@^6.1.0": - version "6.1.0" - resolved "https://registry.npmjs.org/@types/workerpool/-/workerpool-6.1.0.tgz#16c3b9d3c62a8f6e6ad2e4d6212a68130f0cd3b1" - integrity sha512-C+J/c1BHyc351xJuiH2Jbe+V9hjf5mCzRP0UK4KEpF5SpuU+vJ/FC5GLZsCU/PJpp/3I6Uwtfm3DG7Lmrb7LOQ== - dependencies: - "@types/node" "*" - "@types/wrap-ansi@^3.0.0": version "3.0.0" resolved "https://registry.npmjs.org/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz#18b97a972f94f60a679fd5c796d96421b9abb9fd"