https://github.com/jSherz/terraform-provider-node-lambda-packager
Bundles your Lambda code and zips it up ready to feed into aws_lambda_function.
https://github.com/jSherz/terraform-provider-node-lambda-packager
Last synced: 2 months ago
JSON representation
Bundles your Lambda code and zips it up ready to feed into aws_lambda_function.
- Host: GitHub
- URL: https://github.com/jSherz/terraform-provider-node-lambda-packager
- Owner: jSherz
- License: mpl-2.0
- Created: 2023-04-13T18:35:13.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T16:53:02.000Z (8 months ago)
- Last Synced: 2024-08-21T18:54:41.886Z (8 months ago)
- Language: Go
- Size: 132 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - jSherz/terraform-provider-node-lambda-packager - Bundles your Lambda code and zips it up ready to feed into aws_lambda_function. (Go)
README
# terraform-provider-node-lambda-packager
 
This Terraform provider helps you to co-locate your Lambda application code
with your Infrastructure as Code (IaC). It uses esbuild to produce a bundle
that's then zipped up and made ready for Terraform to consume.## Usage
```terraform
#
# 1. Use the data source to package up your NodeJS-based Lambda function.
#
data "node-lambda-packager_package" "create_user" {
#
# 2. Set esbuild arguments as appropriate.
#
# See: https://esbuild.github.io/api/#build-api
#
args = [
"--bundle",
"--minify",
"--platform=node",
"--sourcemap",
"--target=es2024",
"--sourcemap=inline",
]#
# 3. The entrypoint file is relative to the working directory and you can
# leave the working directory empty if it's already correct.
#
entrypoint = "src/handlers/v1/admin/users/create/index.ts"
working_directory = ""
}#
# 4. Define your Lambda function as normal!
#
resource "aws_lambda_function" "create_user" {
function_name = "create-user"
role = aws_iam_role.create_user.arn
architectures = ["arm64"]
handler = "index.handler"
memory_size = 1024
runtime = "nodejs22.x"#
# 5. Here's where our data source is used:
#
filename = data.node-lambda-packager_package.create_user.filename
source_code_hash = data.node-lambda-packager_package.create_user.source_code_hash
}
```See [jSherz/automate-aws-access-removal] for a more in-depth example of this
provider in use.[jSherz/automate-aws-access-removal]: https://github.com/jSherz/automate-aws-access-removal
## Build
```bash
make build
```## Install for local testing
```bash
make install
```## Test
```bash
make testacc
```## Linting
For install steps, see [golang-ci-lint on GitHub]. Find the correct version to
use in the `./github/workflows/golangci-lint.yml` file.[golang-ci-lint on GitHub]: https://github.com/golangci/golangci-lint
```bash
golangci-lint run
```### Fixing formatting or input problems
You can run a single linter in fix mode as follows:
```bash
golangci-lint run --no-config --enable gofumpt --fix
```[gci] and [gofumpt] have to be run in order to have both agree about the import
order and formatting:```bash
golangci-lint run --no-config --enable gci --fix
golangci-lint run --no-config --enable gofumpt --fix
```[gci]: https://github.com/daixiang0/gci
[gofumpt]: https://github.com/mvdan/gofumpt