Closed braun1928 closed 6 days ago
What if you create a separate resource like:
resource "null_resource" "node_build" {
...
provisioner "local-exec" {
command = "<build command>"
}
....
data "archive_file" "lambda_package" {
depends_on = [null_resource.function_binary]
type = "zip"
source_file = "<path>"
output_path = "<path>"
}
...
Then point your lambda resource block to that archive_file
resources.
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
Workaround/clean way: set docker environment variable NODE_ENVIRONMENT to production (using docker_additional_options), the desired behaviour is achieved and no need to customize commands or anything. If not building in docker (not my case) then needs to run terraform with that variable set.
Is your request related to a problem? Please describe.
When building node lambda, it runs just a
npm install
. If the package.json file has things indevDependencies
, the package file may get a bit bloated unnecessarily. Specific case: one lambda goes from 4MB to 28MB, and obviously, takes a little longer to install the dependencies.Describe the solution you'd like.
A way to signal the build process to append
--omit=dev
with node packages.Describe alternatives you've considered.
Using a command list in
source_path
works, BUT that makes it not possible to usebuild_in_docker
, which renders another list of issues (lots of different runtimes needed, CI pipelines, etc).