-
Notifications
You must be signed in to change notification settings - Fork 4k
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: Reduce aws-cdk-lib package size by not bundling awscli Lambda Layer #21799
Conversation
…ate flag in package.json so it can be published separately
…at I can write a different implementation for it in v2 (this is a temporary measure, we still need a 'real' way to do make them differnt
… @aws-cdk/lambda-layer-awscli. This currently only works if the dependency is present in node_modules
This does not work, because the subsequent `require()` call fails to load the installed module, because it can't find the aws-cdk-lib and constructs peer-dependencies. Installing both of those seems like a performance cost we do not want to pay.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
const installParentDir = os.homedir() ?? os.tmpdir(); | ||
this.wellKnownInstallDir = path.join(installParentDir, '.awscdk/npm-cache'); | ||
|
||
const version = this.requireWrapper(path.join(__dirname, '../package.json')).devDependencies[this.packageName]; | ||
const pathOfModuleIfAlreadyInstalled = require.resolve(`${this.packageName}`); | ||
const versionAlreadyInstalled = this.requireWrapper(path.join(pathOfModuleIfAlreadyInstalled, '../../package.json')).version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will ultimately all go into a reusable function/class later, right? (I suppose it could go into core
)
"constructs": "^10.0.0", | ||
"lambda-layer-awscli-v1": "0.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get this in the @aws-cdk
namespace?
|
||
private installNpmPackage(): any { | ||
console.log(`Shelling out to run npm install ${this.packageName} --no-save --prefix ${this.wellKnownInstallDir}`); | ||
const result = childproc.execSync(`pwd; npm prefix; npm install ${this.packageName} --silent --no-save --prefix ${this.wellKnownInstallDir}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug commands in here?
Superseded by #21938 |
This PR is in draft state, and is not ready to be merged yet. A couple of notes for the reader:
require.main.paths
list. I tried to use a well-known "global" install location, but removed it in this commit because it didn't work.Todos:
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license