-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[lambda] specify multiple folders as a single lambda asset #984
Comments
Wouldn't you pick the single directory that contains both your code and the
|
I've been thinking on the following structure / |
I think that's definitely an interesting idea. One would also need to map the sources to their location in the destination tree (for example, you would probably want |
@eladb right |
I have a mono-repo and so I can't just include the root of the project. I use Something like this would be great: const example = new Function(this, 'Example'), {
runtime: Runtime.NodeJS810,
handler: 'index.handler',
code: Code.files([
'dist/funcs/example/*',
'node_modules/*'
'!node_modules/aws-sdk'
}); Similar to the way gulp would let you include src files. Right now I'm looking at adding a package.json into my func folder and running |
I can see the value in this, and I think we can support something like that, but I was wondering if this is actually the best approach for bundling node.js dependencies for Lambda. Excluding certain modules from the root of your node_modules directory might really not be the right approach. I'd argue that your I wonder if perhaps there's something we can add to the CDK such that utilizing this approach will be straightforward (i.e. run It's definitely a topic of interest for us, which we would love to address end-to-end (for node and all other languages as well). Copy: @sam-goodwin |
@eladb I agree after digging into it more. I wrote a little script to do this, to illustrate the issue: #!/bin/bash
set -e
function prep-func {
func=$1
echo "$func:"
cp src/funcs/$func/package.json dist/funcs/$func/package.json
cp src/funcs/$func/package-lock.json dist/funcs/$func/package-lock.json
pushd dist/funcs/$func &> /dev/null
npm i --production --silent
popd &> /dev/null
}
echo "compiling..."
npx tsc
echo "preparing functions..."
prep-func "shared"
prep-func "exportDelivery"
echo "deploying to amazon..."
npx cdk deploy --app dist/cloud/index.js
echo "done." I think its fine to let people resolve this on their own on second thought, because I'm not sure how you could really solve this in a general way. These are steps for the pre-deploy build system of each individual project, and if I have a mono-repo I need to ensure that each of those sup-repos are building their dependencies at the correct time with the correct settings, not you. |
still relevant |
Any plan on this feature ? |
Perhaps @jogold will be interested to add this capability to our new shiny staging system. |
Hey has there been any movement on this since August? I could really use this feature in my mono-repo. |
+1 |
Would love this feature, have a somewhat intricate folder structure and I really don't want to duplicate a lot of files... |
+1 |
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
+1 |
I have created a draft PR for this, it is not finalized but I appreciate any review or feedback for it. |
+1 |
2 similar comments
+1 |
+1 |
#4776 looks to be related to this |
+1 |
1 similar comment
+1 |
so any way around except for using docker for packaging a custom folder structure? +1 |
+1 |
1 similar comment
+1 |
Hello,
Great framework, keep up the good work.
Right now in order to define a lambda function you need to set where the code resides, e.g.
code: lambda.Code.asset('lambda')
. Sometimes you would like to define multiple folders, for example the actual code andnode_modules
, although packing can be done as a preprocess step before actually runningcdk deploy
, it would be cleaner to do it as part of the lambda configuration.The text was updated successfully, but these errors were encountered: