From 0b8ee97b7c029c5195de694a1d2eea309c343f61 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 18 May 2021 17:35:04 +0200 Subject: [PATCH 1/4] fix(pipelines): synth fails if 'aws-cdk' is not in `package.json` (#14745) Our `aws-sdk` dependency has recently added a `postinstall` script to their package. For whatever reason, if the `unsafe_perm` NPM config flag is not set to `true` and `npx` needs to install the `aws-cdk` package (because it's not in the user's `package.json` and so didn't get installed as part of `npm ci`), then the `postinstall` script fails. I've confirmed that this fixes it but I haven't 100% put my finger on the smoking gun yet. * `npx package-without-postinstall` works fine, even without this setting. * `npm install -g package-with-postinstall` also works fine, even though it's still installed as `root`. It seems to be the combination of `npx`, `root` and `postinstall` that is causing the issue. Fixes #14658. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../lib/synths/simple-synth-action.ts | 20 ++++ .../@aws-cdk/pipelines/test/builds.test.ts | 25 +++++ .../integ.pipeline-with-assets.expected.json | 103 ++++++++++-------- .../test/integ.pipeline.expected.json | 103 ++++++++++-------- 4 files changed, 155 insertions(+), 96 deletions(-) diff --git a/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts b/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts index eec90185b9744..b43355789feb0 100644 --- a/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts +++ b/packages/@aws-cdk/pipelines/lib/synths/simple-synth-action.ts @@ -211,6 +211,16 @@ export class SimpleSynthAction implements codepipeline.IAction, iam.IGrantable { synthCommand: options.synthCommand ?? 'npx cdk synth', vpc: options.vpc, subnetSelection: options.subnetSelection, + environment: { + ...options.environment, + environmentVariables: { + // Need this in case the CDK CLI is not in the 'package.json' of the project, + // and 'npx' is going to download it; without this setting, 'npx' will not properly + // install the package into the root user's home directory + NPM_CONFIG_UNSAFE_PERM: { value: 'true' }, + ...options.environment?.environmentVariables, + }, + }, }); } @@ -228,6 +238,16 @@ export class SimpleSynthAction implements codepipeline.IAction, iam.IGrantable { synthCommand: options.synthCommand ?? 'npx cdk synth', vpc: options.vpc, subnetSelection: options.subnetSelection, + environment: { + ...options.environment, + environmentVariables: { + // Need this in case the CDK CLI is not in the 'package.json' of the project, + // and 'npx' is going to download it; without this setting, 'npx' will not properly + // install the package into the root user's home directory + NPM_CONFIG_UNSAFE_PERM: { value: 'true' }, + ...options.environment?.environmentVariables, + }, + }, }); } diff --git a/packages/@aws-cdk/pipelines/test/builds.test.ts b/packages/@aws-cdk/pipelines/test/builds.test.ts index 5f91472b458f1..1a8f9b5c41208 100644 --- a/packages/@aws-cdk/pipelines/test/builds.test.ts +++ b/packages/@aws-cdk/pipelines/test/builds.test.ts @@ -124,6 +124,31 @@ test.each([['npm'], ['yarn']])('%s build respects subdirectory', (npmYarn) => { }); }); +test.each([['npm'], ['yarn']])('%s build sets UNSAFE_PERM=true', (npmYarn) => { + // WHEN + new TestGitHubNpmPipeline(pipelineStack, 'Cdk', { + sourceArtifact, + cloudAssemblyArtifact, + synthAction: npmYarnBuild(npmYarn)({ + sourceArtifact, + cloudAssemblyArtifact, + }), + }); + + // THEN + expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', { + Environment: { + EnvironmentVariables: [ + { + Name: 'NPM_CONFIG_UNSAFE_PERM', + Type: 'PLAINTEXT', + Value: 'true', + }, + ], + }, + }); +}); + test.each([['npm'], ['yarn']])('%s assumes no build step by default', (npmYarn) => { // WHEN new TestGitHubNpmPipeline(pipelineStack, 'Cdk', { diff --git a/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json b/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json index 871d741989ca3..9d869296f2148 100644 --- a/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json +++ b/packages/@aws-cdk/pipelines/test/integ.pipeline-with-assets.expected.json @@ -1,36 +1,4 @@ { - "Parameters": { - "BootstrapVersion": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/cdk-bootstrap/hnb659fds/version", - "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store." - } - }, - "Rules": { - "CheckBootstrapVersion": { - "Assertions": [ - { - "Assert": { - "Fn::Not": [ - { - "Fn::Contains": [ - [ - "1", - "2", - "3" - ], - { - "Ref": "BootstrapVersion" - } - ] - } - ] - }, - "AssertDescription": "CDK bootstrap stack version 4 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." - } - ] - } - }, "Resources": { "PipelineArtifactsBucketEncryptionKeyF5BF0670": { "Type": "AWS::KMS::Key", @@ -63,6 +31,20 @@ "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, + "PipelineArtifactsBucketEncryptionKeyAlias94A07392": { + "Type": "AWS::KMS::Alias", + "Properties": { + "AliasName": "alias/codepipeline-pipelinestackpipelinee95eedaa", + "TargetKeyId": { + "Fn::GetAtt": [ + "PipelineArtifactsBucketEncryptionKeyF5BF0670", + "Arn" + ] + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, "PipelineArtifactsBucketAEA9A052": { "Type": "AWS::S3::Bucket", "Properties": { @@ -91,20 +73,6 @@ "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" }, - "PipelineArtifactsBucketEncryptionKeyAlias94A07392": { - "Type": "AWS::KMS::Alias", - "Properties": { - "AliasName": "alias/codepipeline-pipelinestackpipelinee95eedaa", - "TargetKeyId": { - "Fn::GetAtt": [ - "PipelineArtifactsBucketEncryptionKeyF5BF0670", - "Arn" - ] - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "PipelineRoleB27FAA37": { "Type": "AWS::IAM::Role", "Properties": { @@ -293,7 +261,7 @@ "ProjectName": { "Ref": "PipelineBuildSynthCdkBuildProject6BEFA8E6" }, - "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"a0d828d64c88aa603631eb7a08bc4748769f45d4b84d1b550cc85f41e49dc87e\"}]" + "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"da8c1ee6d645a5802d25355fec94a3f22a961102b74ac3846898d6b14e3a2c30\"}]" }, "InputArtifacts": [ { @@ -765,6 +733,13 @@ }, "Environment": { "ComputeType": "BUILD_GENERAL1_SMALL", + "EnvironmentVariables": [ + { + "Name": "NPM_CONFIG_UNSAFE_PERM", + "Type": "PLAINTEXT", + "Value": "true" + } + ], "Image": "aws/codebuild/standard:5.0", "ImagePullCredentialsType": "CODEBUILD", "PrivilegedMode": false, @@ -1507,5 +1482,37 @@ } } } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store." + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 4 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json b/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json index 68e86fd208660..304126cf148e6 100644 --- a/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json +++ b/packages/@aws-cdk/pipelines/test/integ.pipeline.expected.json @@ -1,36 +1,4 @@ { - "Parameters": { - "BootstrapVersion": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/cdk-bootstrap/hnb659fds/version", - "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store." - } - }, - "Rules": { - "CheckBootstrapVersion": { - "Assertions": [ - { - "Assert": { - "Fn::Not": [ - { - "Fn::Contains": [ - [ - "1", - "2", - "3" - ], - { - "Ref": "BootstrapVersion" - } - ] - } - ] - }, - "AssertDescription": "CDK bootstrap stack version 4 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." - } - ] - } - }, "Resources": { "PipelineArtifactsBucketEncryptionKeyF5BF0670": { "Type": "AWS::KMS::Key", @@ -63,6 +31,20 @@ "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, + "PipelineArtifactsBucketEncryptionKeyAlias94A07392": { + "Type": "AWS::KMS::Alias", + "Properties": { + "AliasName": "alias/codepipeline-pipelinestackpipelinee95eedaa", + "TargetKeyId": { + "Fn::GetAtt": [ + "PipelineArtifactsBucketEncryptionKeyF5BF0670", + "Arn" + ] + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, "PipelineArtifactsBucketAEA9A052": { "Type": "AWS::S3::Bucket", "Properties": { @@ -91,20 +73,6 @@ "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" }, - "PipelineArtifactsBucketEncryptionKeyAlias94A07392": { - "Type": "AWS::KMS::Alias", - "Properties": { - "AliasName": "alias/codepipeline-pipelinestackpipelinee95eedaa", - "TargetKeyId": { - "Fn::GetAtt": [ - "PipelineArtifactsBucketEncryptionKeyF5BF0670", - "Arn" - ] - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, "PipelineRoleB27FAA37": { "Type": "AWS::IAM::Role", "Properties": { @@ -283,7 +251,7 @@ "ProjectName": { "Ref": "PipelineBuildSynthCdkBuildProject6BEFA8E6" }, - "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"a0d828d64c88aa603631eb7a08bc4748769f45d4b84d1b550cc85f41e49dc87e\"}]" + "EnvironmentVariables": "[{\"name\":\"_PROJECT_CONFIG_HASH\",\"type\":\"PLAINTEXT\",\"value\":\"da8c1ee6d645a5802d25355fec94a3f22a961102b74ac3846898d6b14e3a2c30\"}]" }, "InputArtifacts": [ { @@ -698,6 +666,13 @@ }, "Environment": { "ComputeType": "BUILD_GENERAL1_SMALL", + "EnvironmentVariables": [ + { + "Name": "NPM_CONFIG_UNSAFE_PERM", + "Type": "PLAINTEXT", + "Value": "true" + } + ], "Image": "aws/codebuild/standard:5.0", "ImagePullCredentialsType": "CODEBUILD", "PrivilegedMode": false, @@ -1234,5 +1209,37 @@ } } } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store." + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 4 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } } -} +} \ No newline at end of file From beb01b549abc5a5c825e951649786589d2150a72 Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 18 May 2021 17:01:18 +0100 Subject: [PATCH 2/4] revert(lambda-layer-awscli): add awscli v2.2.5 (#14487) (#14744) This reverts commit 704946a9df25d73f1ebcb47f9df9c73d75d82acc. The addition of the new lambda layer increases the size of the bundled monocdk package. This causes our pipeline to fail during our integration test. Including the awscliv2 lambda layer, the artifact size for monocdk is 86MB. It's not clear if the limitation is one from npm or a limitation imposed by verdaccio; the latter is used by our release pipeline to test unreleased npm modules. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../ec2/integ.environment-file.expected.json | 42 ++++++------ .../@aws-cdk/aws-eks/lib/kubectl-provider.ts | 4 +- .../lib/bucket-deployment.ts | 4 +- .../aws-s3-deployment/lib/lambda/index.py | 2 +- ...bucket-deployment-cloudfront.expected.json | 42 ++++++------ .../integ.bucket-deployment.expected.json | 66 +++++++++---------- .../@aws-cdk/lambda-layer-awscli/README.md | 4 +- .../lambda-layer-awscli/layer/build.sh | 23 +++---- .../lambda-layer-awscli/layer/v2.Dockerfile | 21 ------ .../lambda-layer-awscli/lib/awscli-layer.ts | 19 +----- .../test/awscli-layer.test.ts | 17 +---- 11 files changed, 95 insertions(+), 149 deletions(-) delete mode 100644 packages/@aws-cdk/lambda-layer-awscli/layer/v2.Dockerfile diff --git a/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json b/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json index 18ba2efb78daf..c309c8a70f249 100644 --- a/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json +++ b/packages/@aws-cdk/aws-ecs/test/ec2/integ.environment-file.expected.json @@ -991,12 +991,12 @@ } } }, - "EnvFileDeploymentAwsCliV2Layer0F17A9A2": { + "EnvFileDeploymentAwsCliLayerA8FC897D": { "Type": "AWS::Lambda::LayerVersion", "Properties": { "Content": { "S3Bucket": { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7" }, "S3Key": { "Fn::Join": [ @@ -1009,7 +1009,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -1022,7 +1022,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -1219,7 +1219,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3BucketE7100B42" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3Bucket55EFA30C" }, "S3Key": { "Fn::Join": [ @@ -1232,7 +1232,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70" } ] } @@ -1245,7 +1245,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70" } ] } @@ -1264,7 +1264,7 @@ "Handler": "index.handler", "Layers": [ { - "Ref": "EnvFileDeploymentAwsCliV2Layer0F17A9A2" + "Ref": "EnvFileDeploymentAwsCliLayerA8FC897D" } ], "Runtime": "python3.6", @@ -1336,29 +1336,29 @@ "Type": "AWS::SSM::Parameter::Value", "Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7": { "Type": "String", - "Description": "S3 bucket for asset \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "S3 bucket for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F": { "Type": "String", - "Description": "S3 key for asset version \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "S3 key for asset version \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667ArtifactHashCF1F391F": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68ArtifactHashD9A515C3": { "Type": "String", - "Description": "Artifact hash for asset \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "Artifact hash for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3BucketE7100B42": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3Bucket55EFA30C": { "Type": "String", - "Description": "S3 bucket for asset \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "S3 bucket for asset \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70": { "Type": "String", - "Description": "S3 key for asset version \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "S3 key for asset version \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319ArtifactHash0F167E69": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfArtifactHash85F58E48": { "Type": "String", - "Description": "Artifact hash for asset \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "Artifact hash for asset \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, "AssetParameters972240f9dd6e036a93d5f081af9a24315b2053828ac049b3b19b2fa12d7ae64aS3Bucket1F1A8472": { "Type": "String", @@ -1385,4 +1385,4 @@ "Description": "Artifact hash for asset \"872561bf078edd1685d50c9ff821cdd60d2b2ddfb0013c4087e79bf2bb50724d\"" } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-eks/lib/kubectl-provider.ts b/packages/@aws-cdk/aws-eks/lib/kubectl-provider.ts index 0144a38a46e0e..b5bd8ed51b876 100644 --- a/packages/@aws-cdk/aws-eks/lib/kubectl-provider.ts +++ b/packages/@aws-cdk/aws-eks/lib/kubectl-provider.ts @@ -3,7 +3,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; import { Duration, Stack, NestedStack, Names } from '@aws-cdk/core'; import * as cr from '@aws-cdk/custom-resources'; -import { AwsCliV2Layer } from '@aws-cdk/lambda-layer-awscli'; +import { AwsCliLayer } from '@aws-cdk/lambda-layer-awscli'; import { KubectlLayer } from '@aws-cdk/lambda-layer-kubectl'; import { Construct } from 'constructs'; import { ICluster, Cluster } from './cluster'; @@ -86,7 +86,7 @@ export class KubectlProvider extends NestedStack { // allow user to customize the layer if (!props.cluster.kubectlLayer) { - handler.addLayers(new AwsCliV2Layer(this, 'AwsCliV2Layer')); + handler.addLayers(new AwsCliLayer(this, 'AwsCliLayer')); handler.addLayers(new KubectlLayer(this, 'KubectlLayer')); } else { handler.addLayers(props.cluster.kubectlLayer); diff --git a/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts b/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts index 09991219a1922..ca91f036dc5ed 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts +++ b/packages/@aws-cdk/aws-s3-deployment/lib/bucket-deployment.ts @@ -5,7 +5,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; -import { AwsCliV2Layer } from '@aws-cdk/lambda-layer-awscli'; +import { AwsCliLayer } from '@aws-cdk/lambda-layer-awscli'; import { Construct } from 'constructs'; import { ISource, SourceConfig } from './source'; @@ -196,7 +196,7 @@ export class BucketDeployment extends CoreConstruct { const handler = new lambda.SingletonFunction(this, 'CustomResourceHandler', { uuid: this.renderSingletonUuid(props.memoryLimit), code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')), - layers: [new AwsCliV2Layer(this, 'AwsCliV2Layer')], + layers: [new AwsCliLayer(this, 'AwsCliLayer')], runtime: lambda.Runtime.PYTHON_3_6, handler: 'index.handler', lambdaPurpose: 'Custom::CDKBucketDeployment', diff --git a/packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py b/packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py index f9a9ea69f4593..3935e3122529d 100644 --- a/packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py +++ b/packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py @@ -183,7 +183,7 @@ def create_metadata_args(raw_user_metadata, raw_system_metadata): #--------------------------------------------------------------------------------------------------- # executes an "aws" cli command def aws_command(*args): - aws="/opt/awscli/aws" # from AwsCliV2Layer + aws="/opt/awscli/aws" # from AwsCliLayer logger.info("| aws %s" % ' '.join(args)) subprocess.check_call([aws] + list(args)) diff --git a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json index abfcd004e8c4b..76f906941f2bd 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json +++ b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment-cloudfront.expected.json @@ -53,12 +53,12 @@ } } }, - "DeployWithInvalidationAwsCliV2Layer0A4BF3DF": { + "DeployWithInvalidationAwsCliLayerDEDD5787": { "Type": "AWS::Lambda::LayerVersion", "Properties": { "Content": { "S3Bucket": { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7" }, "S3Key": { "Fn::Join": [ @@ -71,7 +71,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -84,7 +84,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -295,7 +295,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3BucketE7100B42" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3Bucket55EFA30C" }, "S3Key": { "Fn::Join": [ @@ -308,7 +308,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70" } ] } @@ -321,7 +321,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70" } ] } @@ -340,7 +340,7 @@ "Handler": "index.handler", "Layers": [ { - "Ref": "DeployWithInvalidationAwsCliV2Layer0A4BF3DF" + "Ref": "DeployWithInvalidationAwsCliLayerDEDD5787" } ], "Runtime": "python3.6", @@ -353,29 +353,29 @@ } }, "Parameters": { - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7": { "Type": "String", - "Description": "S3 bucket for asset \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "S3 bucket for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F": { "Type": "String", - "Description": "S3 key for asset version \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "S3 key for asset version \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667ArtifactHashCF1F391F": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68ArtifactHashD9A515C3": { "Type": "String", - "Description": "Artifact hash for asset \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "Artifact hash for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3BucketE7100B42": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3Bucket55EFA30C": { "Type": "String", - "Description": "S3 bucket for asset \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "S3 bucket for asset \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70": { "Type": "String", - "Description": "S3 key for asset version \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "S3 key for asset version \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319ArtifactHash0F167E69": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfArtifactHash85F58E48": { "Type": "String", - "Description": "Artifact hash for asset \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "Artifact hash for asset \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3Bucket9CD8B20A": { "Type": "String", @@ -390,4 +390,4 @@ "Description": "Artifact hash for asset \"fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e\"" } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json index 054938cc10920..877298773816b 100644 --- a/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json +++ b/packages/@aws-cdk/aws-s3-deployment/test/integ.bucket-deployment.expected.json @@ -10,12 +10,12 @@ "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, - "DeployMeAwsCliV2LayerA4132521": { + "DeployMeAwsCliLayer5F9219E9": { "Type": "AWS::Lambda::LayerVersion", "Properties": { "Content": { "S3Bucket": { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7" }, "S3Key": { "Fn::Join": [ @@ -28,7 +28,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -41,7 +41,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -304,7 +304,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3BucketE7100B42" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3Bucket55EFA30C" }, "S3Key": { "Fn::Join": [ @@ -317,7 +317,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70" } ] } @@ -330,7 +330,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5" + "Ref": "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70" } ] } @@ -349,7 +349,7 @@ "Handler": "index.handler", "Layers": [ { - "Ref": "DeployMeAwsCliV2LayerA4132521" + "Ref": "DeployMeAwsCliLayer5F9219E9" } ], "Runtime": "python3.6", @@ -365,12 +365,12 @@ "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" }, - "DeployWithPrefixAwsCliV2Layer076E52D4": { + "DeployWithPrefixAwsCliLayerC9DDB597": { "Type": "AWS::Lambda::LayerVersion", "Properties": { "Content": { "S3Bucket": { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7" }, "S3Key": { "Fn::Join": [ @@ -383,7 +383,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -396,7 +396,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -473,12 +473,12 @@ "UpdateReplacePolicy": "Retain", "DeletionPolicy": "Retain" }, - "DeployWithMetadataAwsCliV2Layer791A6E48": { + "DeployWithMetadataAwsCliLayer2C774B41": { "Type": "AWS::Lambda::LayerVersion", "Properties": { "Content": { "S3Bucket": { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7" }, "S3Key": { "Fn::Join": [ @@ -491,7 +491,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -504,7 +504,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -584,12 +584,12 @@ "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" }, - "DeployMeWithoutDeletingFilesOnDestinationAwsCliV2Layer7C5D4E6E": { + "DeployMeWithoutDeletingFilesOnDestinationAwsCliLayer4D54C41C": { "Type": "AWS::Lambda::LayerVersion", "Properties": { "Content": { "S3Bucket": { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7" }, "S3Key": { "Fn::Join": [ @@ -602,7 +602,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -615,7 +615,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD" + "Ref": "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F" } ] } @@ -688,29 +688,29 @@ } }, "Parameters": { - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3Bucket4AD27E1E": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3BucketAEADE8C7": { "Type": "String", - "Description": "S3 bucket for asset \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "S3 bucket for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667S3VersionKeyDCC716CD": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68S3VersionKeyE415415F": { "Type": "String", - "Description": "S3 key for asset version \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "S3 key for asset version \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667ArtifactHashCF1F391F": { + "AssetParameterse9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68ArtifactHashD9A515C3": { "Type": "String", - "Description": "Artifact hash for asset \"9789bc66af5e585ba19c61644177b6f5c813f00545d0202416c16d332625a667\"" + "Description": "Artifact hash for asset \"e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3BucketE7100B42": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3Bucket55EFA30C": { "Type": "String", - "Description": "S3 bucket for asset \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "S3 bucket for asset \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319S3VersionKeyFB53BEE5": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfS3VersionKey60329B70": { "Type": "String", - "Description": "S3 key for asset version \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "S3 key for asset version \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, - "AssetParameters02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319ArtifactHash0F167E69": { + "AssetParametersc24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cfArtifactHash85F58E48": { "Type": "String", - "Description": "Artifact hash for asset \"02c8ff4f6d45dba3e787012cafd143192b2369a89115356da36548706b54f319\"" + "Description": "Artifact hash for asset \"c24b999656e4fe6c609c31bae56a1cf4717a405619c3aa6ba1bc686b8c2c86cf\"" }, "AssetParametersfc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222eS3Bucket9CD8B20A": { "Type": "String", @@ -725,4 +725,4 @@ "Description": "Artifact hash for asset \"fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e\"" } } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/lambda-layer-awscli/README.md b/packages/@aws-cdk/lambda-layer-awscli/README.md index 4132783bc3966..baad6362f5e21 100644 --- a/packages/@aws-cdk/lambda-layer-awscli/README.md +++ b/packages/@aws-cdk/lambda-layer-awscli/README.md @@ -10,13 +10,13 @@ -This module exports two classes called `AwsCliLayer` & `AwsCliV2Layer` which is a `lambda.Layer` that bundles the AWS CLI. +This module exports a single class called `AwsCliLayer` which is a `lambda.Layer` that bundles the AWS CLI. Usage: ```ts const fn = new lambda.Function(...); -fn.addLayers(new AwsCliV2Layer(stack, 'AwsCliV2Layer')); +fn.addLayers(new AwsCliLayer(stack, 'AwsCliLayer')); ``` The CLI will be installed under `/opt/awscli/aws`. diff --git a/packages/@aws-cdk/lambda-layer-awscli/layer/build.sh b/packages/@aws-cdk/lambda-layer-awscli/layer/build.sh index d1f547312dde7..a7c13263ebdce 100755 --- a/packages/@aws-cdk/lambda-layer-awscli/layer/build.sh +++ b/packages/@aws-cdk/lambda-layer-awscli/layer/build.sh @@ -3,21 +3,16 @@ set -euo pipefail cd $(dirname $0) -echo ">> Building AWS Lambda layer inside docker images..." +echo ">> Building AWS Lambda layer inside a docker image..." -V1_TAG="lambda-awscli-layer" -V2_TAG="lambda-awscli-v2-layer" +TAG='aws-lambda-layer' -docker build -t "${V1_TAG}" . -f Dockerfile -docker build -t "${V2_TAG}" . -f v2.Dockerfile +docker build -t ${TAG} . -echo ">> Extrating layer zip files from the build containers..." -V1_CONTAINER=$(docker run -d ${V1_TAG} false) -V2_CONTAINER=$(docker run -d ${V2_TAG} false) -docker cp "${V1_CONTAINER}:/layer.zip" ../lib/layer.zip -docker cp "${V2_CONTAINER}:/layer_v2.zip" ../lib/layer_v2.zip +echo ">> Extrating layer.zip from the build container..." +CONTAINER=$(docker run -d ${TAG} false) +docker cp ${CONTAINER}:/layer.zip ../lib/layer.zip -echo ">> Stopping containers..." -docker rm -f "${V1_CONTAINER}" -docker rm -f "${V2_CONTAINER}" -echo ">> lib/layer.zip & lib/layer_v2.zip is ready" +echo ">> Stopping container..." +docker rm -f ${CONTAINER} +echo ">> lib/layer.zip is ready" diff --git a/packages/@aws-cdk/lambda-layer-awscli/layer/v2.Dockerfile b/packages/@aws-cdk/lambda-layer-awscli/layer/v2.Dockerfile deleted file mode 100644 index 801dd434e4c3e..0000000000000 --- a/packages/@aws-cdk/lambda-layer-awscli/layer/v2.Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM public.ecr.aws/lambda/provided:latest - -ARG AWSCLI_V2_VERSION=2.2.5 -USER root -RUN set -ex; \ - yum update -y; \ - yum install -y zip unzip wget tar gzip; -WORKDIR /tmp -RUN set -ex; \ - mkdir -p /opt; \ - curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-$AWSCLI_V2_VERSION.zip" -o awscli-bundle.zip; \ - unzip awscli-bundle.zip; \ - mv ./aws/dist /opt/awscli; \ - rm -rf /opt/awscli/awscli/examples; \ - cd /opt; \ - zip --symlinks -r ../layer_v2.zip *; \ - ls -alh /layer_v2.zip; \ - /opt/awscli/aws --version; - -WORKDIR / -ENTRYPOINT [ "/bin/bash" ] diff --git a/packages/@aws-cdk/lambda-layer-awscli/lib/awscli-layer.ts b/packages/@aws-cdk/lambda-layer-awscli/lib/awscli-layer.ts index 58f7f39882bb3..525babcac82f3 100644 --- a/packages/@aws-cdk/lambda-layer-awscli/lib/awscli-layer.ts +++ b/packages/@aws-cdk/lambda-layer-awscli/lib/awscli-layer.ts @@ -5,7 +5,7 @@ import * as lambda from '@aws-cdk/aws-lambda'; import { Construct } from 'constructs'; /** - * An AWS Lambda layer that includes the AWS CLI V1. + * An AWS Lambda layer that includes the AWS CLI. */ export class AwsCliLayer extends lambda.LayerVersion { constructor(scope: Construct, id: string) { @@ -19,24 +19,9 @@ export class AwsCliLayer extends lambda.LayerVersion { } } -/** - * An AWS Lambda layer that includes the AWS CLI V2. - */ -export class AwsCliV2Layer extends lambda.LayerVersion { - constructor(scope: Construct, id: string) { - super(scope, id, { - code: lambda.Code.fromAsset(path.join(__dirname, 'layer_v2.zip'), { - // we hash the Dockerfile (it contains the tools versions) because hashing the zip is non-deterministic - assetHash: hashFile(path.join(__dirname, '..', 'layer', 'v2.Dockerfile')), - }), - description: '/opt/awscli/aws', - }); - } -} - function hashFile(fileName: string) { return crypto .createHash('sha256') .update(fs.readFileSync(fileName)) .digest('hex'); -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/lambda-layer-awscli/test/awscli-layer.test.ts b/packages/@aws-cdk/lambda-layer-awscli/test/awscli-layer.test.ts index dec56b52a1aed..2a5c4b7d80043 100644 --- a/packages/@aws-cdk/lambda-layer-awscli/test/awscli-layer.test.ts +++ b/packages/@aws-cdk/lambda-layer-awscli/test/awscli-layer.test.ts @@ -1,8 +1,8 @@ import { Stack } from '@aws-cdk/core'; -import { AwsCliLayer, AwsCliV2Layer } from '../lib'; +import { AwsCliLayer } from '../lib'; import '@aws-cdk/assert-internal/jest'; -test('synthesized to a v1 layer version', () => { +test('synthesized to a layer version', () => { //GIVEN const stack = new Stack(); @@ -14,16 +14,3 @@ test('synthesized to a v1 layer version', () => { Description: '/opt/awscli/aws', }); }); - -test('synthesized to a v2 layer version', () => { - //GIVEN - const stack = new Stack(); - - // WHEN - new AwsCliV2Layer(stack, 'MyLayer'); - - // THEN - expect(stack).toHaveResource('AWS::Lambda::LayerVersion', { - Description: '/opt/awscli/aws', - }); -}); From 2678b714a08f9756b02ce5217c9f8d836081968b Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Tue, 18 May 2021 17:33:11 +0100 Subject: [PATCH 3/4] chore: disable automated dependency upgrades (#14749) Temporary disable --- .github/workflows/yarn-upgrade.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/yarn-upgrade.yml b/.github/workflows/yarn-upgrade.yml index 13d551cf740cf..c0df170ff30ef 100644 --- a/.github/workflows/yarn-upgrade.yml +++ b/.github/workflows/yarn-upgrade.yml @@ -1,9 +1,10 @@ name: Yarn Upgrade on: - schedule: + # Disable this workflow + #schedule: # Every wednesday at 13:37 UTC - - cron: 37 13 * * 3 + #- cron: 37 13 * * 3 workflow_dispatch: {} jobs: From 773ca8c5d2a845f392f530d7710020075b884c72 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Wed, 19 May 2021 06:28:16 +0200 Subject: [PATCH 4/4] feat(custom-resources): restrict output of AwsCustomResource to list of paths (#14041) It was already possible to restrict to a single path. Add option to restrict to multiple paths and deprecate the single path option. Also document this option in the README. See https://github.com/aws/aws-cdk/issues/2825#issuecomment-814999890 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../test/integ.assign-public-ip.expected.json | 18 +++---- ...nteg.user-pool-domain-cfdist.expected.json | 18 +++---- ...elasticsearch.custom-kms-key.expected.json | 18 +++---- .../test/integ.elasticsearch.expected.json | 18 +++---- ...sticsearch.unsignedbasicauth.expected.json | 18 +++---- .../test/logs/integ.log-group.expected.json | 18 +++---- .../integ.globalaccelerator.expected.json | 18 +++---- .../aws-msk/test/integ.cluster.expected.json | 18 +++---- ...endpoint-service-domain-name.expected.json | 18 +++---- packages/@aws-cdk/custom-resources/README.md | 24 ++++++++++ .../aws-custom-resource.ts | 14 ++++++ .../lib/aws-custom-resource/runtime/index.ts | 27 +++++++++-- .../aws-custom-resource-provider.test.ts | 47 +++++++++++++++++++ 13 files changed, 190 insertions(+), 84 deletions(-) diff --git a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.assign-public-ip.expected.json b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.assign-public-ip.expected.json index 2ed4b9bb1fe3e..f3a7aeeb43fb1 100644 --- a/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.assign-public-ip.expected.json +++ b/packages/@aws-cdk-containers/ecs-service-extensions/test/integ.assign-public-ip.expected.json @@ -1190,7 +1190,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -1203,7 +1203,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -1216,7 +1216,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -1266,17 +1266,17 @@ "Type": "String", "Description": "Artifact hash for asset \"daeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } }, "Outputs": { diff --git a/packages/@aws-cdk/aws-cognito/test/integ.user-pool-domain-cfdist.expected.json b/packages/@aws-cdk/aws-cognito/test/integ.user-pool-domain-cfdist.expected.json index 6d825755af54d..31a16a8f26393 100644 --- a/packages/@aws-cdk/aws-cognito/test/integ.user-pool-domain-cfdist.expected.json +++ b/packages/@aws-cdk/aws-cognito/test/integ.user-pool-domain-cfdist.expected.json @@ -146,7 +146,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -159,7 +159,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -172,7 +172,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -213,17 +213,17 @@ } }, "Parameters": { - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.custom-kms-key.expected.json b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.custom-kms-key.expected.json index eb826dda1f40a..714b07a76c75b 100644 --- a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.custom-kms-key.expected.json +++ b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.custom-kms-key.expected.json @@ -343,7 +343,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -356,7 +356,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -369,7 +369,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -396,17 +396,17 @@ } }, "Parameters": { - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.expected.json b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.expected.json index 8788b810235ec..4644a8905a74b 100644 --- a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.expected.json +++ b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.expected.json @@ -275,7 +275,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -288,7 +288,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -301,7 +301,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -566,17 +566,17 @@ } }, "Parameters": { - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.expected.json b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.expected.json index 3a59982581776..35a39a6eea608 100644 --- a/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.expected.json +++ b/packages/@aws-cdk/aws-elasticsearch/test/integ.elasticsearch.unsignedbasicauth.expected.json @@ -191,7 +191,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -204,7 +204,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -217,7 +217,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -243,17 +243,17 @@ } }, "Parameters": { - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events-targets/test/logs/integ.log-group.expected.json b/packages/@aws-cdk/aws-events-targets/test/logs/integ.log-group.expected.json index 9764d7387b08a..8ef384b7f43a7 100644 --- a/packages/@aws-cdk/aws-events-targets/test/logs/integ.log-group.expected.json +++ b/packages/@aws-cdk/aws-events-targets/test/logs/integ.log-group.expected.json @@ -172,7 +172,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -185,7 +185,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -198,7 +198,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -472,17 +472,17 @@ } }, "Parameters": { - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json b/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json index 72b6e81da9827..9d516680000e1 100644 --- a/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json +++ b/packages/@aws-cdk/aws-globalaccelerator-endpoints/test/integ.globalaccelerator.expected.json @@ -920,7 +920,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -933,7 +933,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -946,7 +946,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -976,17 +976,17 @@ "Type": "AWS::SSM::Parameter::Value", "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-msk/test/integ.cluster.expected.json b/packages/@aws-cdk/aws-msk/test/integ.cluster.expected.json index 769c0533269cd..9a0d0db6e2325 100644 --- a/packages/@aws-cdk/aws-msk/test/integ.cluster.expected.json +++ b/packages/@aws-cdk/aws-msk/test/integ.cluster.expected.json @@ -524,7 +524,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3Bucket9DEDD0AB" + "Ref": "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3BucketB17E5ABD" }, "S3Key": { "Fn::Join": [ @@ -537,7 +537,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3VersionKeyA54743D3" + "Ref": "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3VersionKey77778F6A" } ] } @@ -550,7 +550,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3VersionKeyA54743D3" + "Ref": "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3VersionKey77778F6A" } ] } @@ -576,17 +576,17 @@ } }, "Parameters": { - "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3Bucket9DEDD0AB": { + "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3BucketB17E5ABD": { "Type": "String", - "Description": "S3 bucket for asset \"f56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483\"" + "Description": "S3 bucket for asset \"5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4\"" }, - "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483S3VersionKeyA54743D3": { + "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4S3VersionKey77778F6A": { "Type": "String", - "Description": "S3 key for asset version \"f56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483\"" + "Description": "S3 key for asset version \"5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4\"" }, - "AssetParametersf56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483ArtifactHash228F5AF4": { + "AssetParameters5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4ArtifactHash580E429C": { "Type": "String", - "Description": "Artifact hash for asset \"f56a9c742f3e99b26237d5d0912c69f9db8289c13656fdcb490fd017d801c483\"" + "Description": "Artifact hash for asset \"5c61041c12314e1ad8e67a0107fa3733382a206a78cdc1576fffa7e93caca5b4\"" } }, "Outputs": { diff --git a/packages/@aws-cdk/aws-route53/test/integ.vpc-endpoint-service-domain-name.expected.json b/packages/@aws-cdk/aws-route53/test/integ.vpc-endpoint-service-domain-name.expected.json index 02dfb6c770668..030333512f860 100644 --- a/packages/@aws-cdk/aws-route53/test/integ.vpc-endpoint-service-domain-name.expected.json +++ b/packages/@aws-cdk/aws-route53/test/integ.vpc-endpoint-service-domain-name.expected.json @@ -936,7 +936,7 @@ "Properties": { "Code": { "S3Bucket": { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9" }, "S3Key": { "Fn::Join": [ @@ -949,7 +949,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -962,7 +962,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7" + "Ref": "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B" } ] } @@ -988,17 +988,17 @@ } }, "Parameters": { - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3Bucket4DD075F7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3BucketD609D0D9": { "Type": "String", - "Description": "S3 bucket for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 bucket for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98S3VersionKeyBD0E03B7": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cS3VersionKey77CF589B": { "Type": "String", - "Description": "S3 key for asset version \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "S3 key for asset version \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" }, - "AssetParametersb965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98ArtifactHash35A756EB": { + "AssetParameters4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02cArtifactHash86CFA15D": { "Type": "String", - "Description": "Artifact hash for asset \"b965ea3084ec95e24846d4975623e62a02c21883c3ddea9366b2ae42d21cef98\"" + "Description": "Artifact hash for asset \"4600faecd25ab407ff0a9d16f935c93062aaea5d415e97046bb8befe6c8ec02c\"" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/custom-resources/README.md b/packages/@aws-cdk/custom-resources/README.md index 327ed2a62c0dd..693b60209d7a9 100644 --- a/packages/@aws-cdk/custom-resources/README.md +++ b/packages/@aws-cdk/custom-resources/README.md @@ -428,6 +428,30 @@ new AwsCustomResource(this, 'Customized', { }) ``` +### Restricting the output of the Custom Resource + +CloudFormation imposes a hard limit of 4096 bytes for custom resources response +objects. If your API call returns an object that exceeds this limit, you can restrict +the data returned by the custom resource to specific paths in the API response: + +```ts +new AwsCustomResource(stack, 'ListObjects', { + onCreate: { + service: 's3', + action: 'listObjectsV2', + parameters: { + Bucket: 'my-bucket', + }, + physicalResourceId: PhysicalResourceId.of('id'), + outputPaths: ['Contents.0.Key', 'Contents.1.Key'], // Output only the two first keys + }, + policy: AwsCustomResourcePolicy.fromSdkCalls({ resources: AwsCustomResourcePolicy.ANY_RESOURCE }), +}); +``` + +Note that even if you restrict the output of your custom resource you can still use any +path in `PhysicalResourceId.fromResponse()`. + ### Custom Resource Examples #### Verify a domain with SES diff --git a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index dd16c15a4646d..9d9c938f3f894 100644 --- a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -128,9 +128,23 @@ export interface AwsSdkCall { * Example for ECS / updateService: 'service.deploymentConfiguration.maximumPercent' * * @default - return all data + * + * @deprecated use outputPaths instead */ readonly outputPath?: string; + /** + * Restrict the data returned by the custom resource to specific paths in + * the API response. Use this to limit the data returned by the custom + * resource if working with API calls that could potentially result in custom + * response objects exceeding the hard limit of 4096 bytes. + * + * Example for ECS / updateService: ['service.deploymentConfiguration.maximumPercent'] + * + * @default - return all data + */ + readonly outputPaths?: string[]; + /** * Used for running the SDK calls in underlying lambda with a different role * Can be used primarily for cross-account requests to for example connect diff --git a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts index 807dc7e78fec5..56215192fb2f2 100644 --- a/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts +++ b/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime/index.ts @@ -150,9 +150,19 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent region: awsService.config.region, // For test purposes: check if region was correctly passed. ...flatten(response), }; - data = call.outputPath - ? filterKeys(flatData, k => k.startsWith(call.outputPath!)) - : flatData; + + let outputPaths: string[] | undefined; + if (call.outputPath) { + outputPaths = [call.outputPath]; + } else if (call.outputPaths) { + outputPaths = call.outputPaths; + } + + if (outputPaths) { + data = filterKeys(flatData, startsWithOneOf(outputPaths)); + } else { + data = flatData; + } } catch (e) { if (!call.ignoreErrorCodesMatching || !new RegExp(call.ignoreErrorCodesMatching).test(e.code)) { throw e; @@ -211,3 +221,14 @@ function decodeCall(call: string | undefined) { if (!call) { return undefined; } return JSON.parse(call); } + +function startsWithOneOf(searchStrings: string[]): (string: string) => boolean { + return function(string: string): boolean { + for (const searchString of searchStrings) { + if (string.startsWith(searchString)) { + return true; + } + } + return false; + }; +} diff --git a/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts b/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts index 66f4fbb5dfc08..8a4786a138468 100644 --- a/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts +++ b/packages/@aws-cdk/custom-resources/test/aws-custom-resource/aws-custom-resource-provider.test.ts @@ -302,6 +302,53 @@ test('restrict output path', async () => { expect(request.isDone()).toBeTruthy(); }); +test('restrict output paths', async () => { + const listObjectsFake = sinon.fake.resolves({ + Contents: [ + { + Key: 'first-key', + ETag: 'first-key-etag', + }, + { + Key: 'second-key', + ETag: 'second-key-etag', + }, + ], + } as SDK.S3.ListObjectsOutput); + + AWS.mock('S3', 'listObjects', listObjectsFake); + + const event: AWSLambda.CloudFormationCustomResourceCreateEvent = { + ...eventCommon, + RequestType: 'Create', + ResourceProperties: { + ServiceToken: 'token', + Create: JSON.stringify({ + service: 'S3', + action: 'listObjects', + parameters: { + Bucket: 'my-bucket', + }, + physicalResourceId: PhysicalResourceId.of('id'), + outputPaths: ['Contents.0.Key', 'Contents.1.Key'], + } as AwsSdkCall), + }, + }; + + const request = createRequest(body => + body.Status === 'SUCCESS' && + body.PhysicalResourceId === 'id' && + JSON.stringify(body.Data) === JSON.stringify({ + 'Contents.0.Key': 'first-key', + 'Contents.1.Key': 'second-key', + }), + ); + + await handler(event, {} as AWSLambda.Context); + + expect(request.isDone()).toBeTruthy(); +}); + test('can specify apiVersion and region', async () => { const publishFake = sinon.fake.resolves({});