Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lambda-layer-awscli): depend on @awscdk/asset-awscli-v1 and reduce aws-cdk-lib size #22823

Merged
merged 12 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/@aws-cdk/lambda-layer-awscli/layer/.dockerignore

This file was deleted.

54 changes: 0 additions & 54 deletions packages/@aws-cdk/lambda-layer-awscli/layer/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions packages/@aws-cdk/lambda-layer-awscli/layer/build.sh

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions packages/@aws-cdk/lambda-layer-awscli/lib/awscli-layer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from 'path';
import { ASSET_FILE, LAYER_SOURCE_DIR } from '@aws-cdk/asset-awscli-v1';
import * as lambda from '@aws-cdk/aws-lambda';
import { FileSystem } from '@aws-cdk/core';
import { Construct } from 'constructs';
Expand All @@ -9,9 +9,9 @@ import { Construct } from 'constructs';
export class AwsCliLayer extends lambda.LayerVersion {
constructor(scope: Construct, id: string) {
super(scope, id, {
code: lambda.Code.fromAsset(path.join(__dirname, 'layer.zip'), {
code: lambda.Code.fromAsset(ASSET_FILE, {
// we hash the layer directory (it contains the tools versions and Dockerfile) because hashing the zip is non-deterministic
assetHash: FileSystem.fingerprint(path.join(__dirname, '../layer')),
assetHash: FileSystem.fingerprint(LAYER_SOURCE_DIR),
}),
description: '/opt/awscli/aws',
});
Expand Down
5 changes: 2 additions & 3 deletions packages/@aws-cdk/lambda-layer-awscli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@
"dependencies": {
"@aws-cdk/aws-lambda": "0.0.0",
"@aws-cdk/core": "0.0.0",
"@aws-cdk/asset-awscli-v1": "^2.2.0",
"constructs": "^10.0.0"
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-lambda": "0.0.0",
"@aws-cdk/core": "0.0.0",
"@aws-cdk/asset-awscli-v1": "^2.2.0",
"constructs": "^10.0.0"
},
"engines": {
Expand All @@ -101,9 +103,6 @@
"announce": false
},
"cdk-build": {
"pre": [
"layer/build.sh"
],
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "21.0.0",
"files": {
"c409e6c5845f1f349df8cd84e160bf6f1c35d2b060b63e1f032f9bd39d4542cc": {
"5d8d1d0aacea23824c62f362e1e3c14b7dd14a31c71b53bfae4d14a6373c5510": {
"source": {
"path": "asset.c409e6c5845f1f349df8cd84e160bf6f1c35d2b060b63e1f032f9bd39d4542cc.zip",
"path": "asset.5d8d1d0aacea23824c62f362e1e3c14b7dd14a31c71b53bfae4d14a6373c5510.zip",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "c409e6c5845f1f349df8cd84e160bf6f1c35d2b060b63e1f032f9bd39d4542cc.zip",
"objectKey": "5d8d1d0aacea23824c62f362e1e3c14b7dd14a31c71b53bfae4d14a6373c5510.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down Expand Up @@ -40,15 +40,15 @@
}
}
},
"41a1734c33fd9c3cc7261b90655668aa62e16d78502a59eb764d96d8aca10c59": {
"f24d942c1e583931f0e686cd0957356dd6f7fefc76b5b425ef2564562d029e7e": {
"source": {
"path": "lambda-layer-awscli-integ-stack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "41a1734c33fd9c3cc7261b90655668aa62e16d78502a59eb764d96d8aca10c59.json",
"objectKey": "f24d942c1e583931f0e686cd0957356dd6f7fefc76b5b425ef2564562d029e7e.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "c409e6c5845f1f349df8cd84e160bf6f1c35d2b060b63e1f032f9bd39d4542cc.zip"
"S3Key": "5d8d1d0aacea23824c62f362e1e3c14b7dd14a31c71b53bfae4d14a6373c5510.zip"
},
"Description": "/opt/awscli/aws"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"version": "21.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"lambda-layer-awscli-integ-stack.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/41a1734c33fd9c3cc7261b90655668aa62e16d78502a59eb764d96d8aca10c59.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f24d942c1e583931f0e686cd0957356dd6f7fefc76b5b425ef2564562d029e7e.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand All @@ -42,7 +36,10 @@
"/lambda-layer-awscli-integ-stack/AwsCliLayer/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "AwsCliLayerF44AAF94"
"data": "AwsCliLayerF44AAF94",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
]
}
],
"/lambda-layer-awscli-integ-stack/Lambda$python3.7/ServiceRole/Resource": [
Expand Down Expand Up @@ -178,6 +175,12 @@
]
},
"displayName": "lambda-layer-awscli-integ-test/DefaultTest/DeployAssert"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.129"
}
},
"lambda-layer-awscli-integ-stack": {
"id": "lambda-layer-awscli-integ-stack",
"path": "lambda-layer-awscli-integ-stack",
Expand Down Expand Up @@ -56,7 +48,7 @@
"s3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"s3Key": "c409e6c5845f1f349df8cd84e160bf6f1c35d2b060b63e1f032f9bd39d4542cc.zip"
"s3Key": "5d8d1d0aacea23824c62f362e1e3c14b7dd14a31c71b53bfae4d14a6373c5510.zip"
},
"description": "/opt/awscli/aws"
}
Expand Down Expand Up @@ -733,11 +725,27 @@
"fqn": "@aws-cdk/core.CustomResource",
"version": "0.0.0"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "lambda-layer-awscli-integ-stack/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "lambda-layer-awscli-integ-stack/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.1.140"
}
},
"lambda-layer-awscli-integ-test": {
Expand All @@ -753,15 +761,33 @@
"path": "lambda-layer-awscli-integ-test/DefaultTest/Default",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.129"
"version": "10.1.140"
}
},
"DeployAssert": {
"id": "DeployAssert",
"path": "lambda-layer-awscli-integ-test/DefaultTest/DeployAssert",
"children": {
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "lambda-layer-awscli-integ-test/DefaultTest/DeployAssert/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "lambda-layer-awscli-integ-test/DefaultTest/DeployAssert/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.1.140"
}
}
},
Expand All @@ -775,6 +801,14 @@
"fqn": "@aws-cdk/integ-tests.IntegTest",
"version": "0.0.0"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.140"
}
}
},
"constructInfo": {
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"minimatch": "^3.1.2",
"punycode": "^2.1.1",
"semver": "^7.3.8",
"yaml": "1.10.2"
"yaml": "1.10.2",
"@aws-cdk/asset-awscli-v1": "^2.2.0"
},
"devDependencies": {
"@aws-cdk/alexa-ask": "0.0.0",
Expand Down
2 changes: 2 additions & 0 deletions tools/@aws-cdk/pkglint/lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,8 @@ export class MustDependonCdkByPointVersions extends ValidationRule {
'@aws-cdk/region-info',
// Private packages
...fs.readdirSync(path.join(monoRepoRoot(), 'tools', '@aws-cdk')).map((name) => `@aws-cdk/${name}`),

'@aws-cdk/asset-awscli-v1',
];

for (const [depName, depVersion] of Object.entries(pkg.dependencies)) {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@aws-cdk/asset-awscli-v1@^2.2.0":
version "2.2.0"
resolved "https://registry.npmjs.org/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.0.tgz#3982f8a2391aeedc3240da6d548c55f2190df0fa"
integrity sha512-mTmuXlnRMlbMwW8IzNlFXoZpfNEQ1RPLKRpJNQeB+dlDOEXllETIFomEyINM1LMpUmNMOOdbtO+vPKRZHCmMOQ==

"@aws-cdk/lambda-layer-kubectl-v23@^2.0.0":
version "2.0.0"
resolved "https://registry.npmjs.org/@aws-cdk/lambda-layer-kubectl-v23/-/lambda-layer-kubectl-v23-2.0.0.tgz#8e46c505c8ba106d7589c9bebda824b8d963463c"
Expand Down