diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3ae4b8ba..7523e5a5 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
- rev: v1.92.2
+ rev: v1.94.3
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
@@ -29,3 +29,5 @@ repos:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
+ - id: mixed-line-ending
+ args: [--fix=lf]
diff --git a/README.md b/README.md
index dbbf0fb1..8661d7ee 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ This Terraform module is the part of [serverless.tf framework](https://github.co
## Features
- Build dependencies for your Lambda Function and Layer.
-- Support builds locally and in Docker (with or without SSH agent support for private builds).
+- Support builds locally and in Docker (with or without SSH agent support for private builds) for any runtime and architecture supported by AWS Lambda.
- Create deployment package or deploy existing (previously built package) from local, from S3, from URL, or from AWS ECR repository.
- Store deployment packages locally or in the S3 bucket.
- Support almost all features of Lambda resources (function, layer, alias, etc.)
@@ -384,7 +384,7 @@ When `source_path` is set to a list of directories the content of each will be t
### Combine various options for extreme flexibility
-This is the most complete way of creating a deployment package from multiple sources with multiple dependencies. This example is showing some of the available options (see [examples/build-package](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/build-package) for more):
+This is the most complete way of creating a deployment package from multiple sources with multiple dependencies. This example is showing some of the available options (see [examples/build-package](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/build-package) and [examples/runtimes](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/runtimes) for more):
```hcl
source_path = [
@@ -643,6 +643,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
- [Complete](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/complete) - Create Lambda resources in various combinations with all supported features.
- [Container Image](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/container-image) - Create a Docker image with a platform specified in the Dockerfile (using [docker provider](https://registry.terraform.io/providers/kreuzwerker/docker)), push it to AWS ECR, and create Lambda function from it.
- [Build and Package](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/build-package) - Build and create deployment packages in various ways.
+- [Runtimes](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/build-package) - Build and create deployment packages for various runtimes (such as Rust, Go, Java).
- [Alias](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/alias) - Create static and dynamic aliases in various ways.
- [Deploy](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/deploy) - Complete end-to-end build/update/deploy process using AWS CodeDeploy.
- [Async Invocations](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/async) - Create Lambda Function with async event configuration (with SQS, SNS, and EventBridge integration).
@@ -660,7 +661,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
- [1Mill/serverless-tf-examples](https://github.com/1Mill/serverless-tf-examples/tree/main/src)
-
+
## Requirements
| Name | Version |
@@ -904,7 +905,7 @@ No modules.
| [lambda\_role\_unique\_id](#output\_lambda\_role\_unique\_id) | The unique id of the IAM role created for the Lambda Function |
| [local\_filename](#output\_local\_filename) | The filename of zip archive deployed (if deployment was from local) |
| [s3\_object](#output\_s3\_object) | The map with S3 object data of zip archive deployed (if deployment was from S3) |
-
+
## Development
diff --git a/examples/alias/README.md b/examples/alias/README.md
index 6326614c..bc734f66 100644
--- a/examples/alias/README.md
+++ b/examples/alias/README.md
@@ -14,7 +14,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -83,4 +83,4 @@ No inputs.
| [lambda\_role\_name](#output\_lambda\_role\_name) | The name of the IAM role created for the Lambda Function |
| [local\_filename](#output\_local\_filename) | The filename of zip archive deployed (if deployment was from local) |
| [s3\_object](#output\_s3\_object) | The map with S3 object data of zip archive deployed (if deployment was from S3) |
-
+
diff --git a/examples/async/README.md b/examples/async/README.md
index 40c6fbb9..5223af96 100644
--- a/examples/async/README.md
+++ b/examples/async/README.md
@@ -14,7 +14,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -72,4 +72,4 @@ No inputs.
| [lambda\_role\_name](#output\_lambda\_role\_name) | The name of the IAM role created for the Lambda Function |
| [local\_filename](#output\_local\_filename) | The filename of zip archive deployed (if deployment was from local) |
| [s3\_object](#output\_s3\_object) | The map with S3 object data of zip archive deployed (if deployment was from S3) |
-
+
diff --git a/examples/build-package/README.md b/examples/build-package/README.md
index e77c0c59..f4856320 100644
--- a/examples/build-package/README.md
+++ b/examples/build-package/README.md
@@ -2,6 +2,8 @@
Configuration in this directory creates deployment packages in a variety of combinations.
+Look into [Runtimes Examples](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/examples/runtimes) for more ways to build and deploy AWS Lambda Functions using supported runtimes (Rust, Go, Java).
+
## Usage
To run this example you need to execute:
@@ -14,7 +16,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -69,4 +71,4 @@ No inputs.
## Outputs
No outputs.
-
+
diff --git a/examples/code-signing/README.md b/examples/code-signing/README.md
index feaa1b38..e1a5a692 100644
--- a/examples/code-signing/README.md
+++ b/examples/code-signing/README.md
@@ -14,7 +14,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -59,4 +59,4 @@ No inputs.
| [lambda\_function\_invoke\_arn](#output\_lambda\_function\_invoke\_arn) | The Invoke ARN of the Lambda Function |
| [lambda\_function\_signing\_job\_arn](#output\_lambda\_function\_signing\_job\_arn) | ARN of the signing job |
| [lambda\_function\_signing\_profile\_version\_arn](#output\_lambda\_function\_signing\_profile\_version\_arn) | ARN of the signing profile version |
-
+
diff --git a/examples/complete/README.md b/examples/complete/README.md
index 92c3256b..eba6ef49 100644
--- a/examples/complete/README.md
+++ b/examples/complete/README.md
@@ -15,7 +15,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -92,4 +92,4 @@ No inputs.
| [lambda\_role\_name](#output\_lambda\_role\_name) | The name of the IAM role created for the Lambda Function |
| [local\_filename](#output\_local\_filename) | The filename of zip archive deployed (if deployment was from local) |
| [s3\_object](#output\_s3\_object) | The map with S3 object data of zip archive deployed (if deployment was from S3) |
-
+
diff --git a/examples/container-image/README.md b/examples/container-image/README.md
index 4ee6505a..4053da3a 100644
--- a/examples/container-image/README.md
+++ b/examples/container-image/README.md
@@ -14,7 +14,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -79,4 +79,4 @@ No inputs.
| [lambda\_layer\_version](#output\_lambda\_layer\_version) | The Lambda Layer version |
| [lambda\_role\_arn](#output\_lambda\_role\_arn) | The ARN of the IAM role created for the Lambda Function |
| [lambda\_role\_name](#output\_lambda\_role\_name) | The name of the IAM role created for the Lambda Function |
-
+
diff --git a/examples/deploy/README.md b/examples/deploy/README.md
index b900c919..198f5cf4 100644
--- a/examples/deploy/README.md
+++ b/examples/deploy/README.md
@@ -14,7 +14,7 @@ $ terraform apply
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
-
+
## Requirements
| Name | Version |
@@ -63,4 +63,4 @@ No inputs.
| [codedeploy\_iam\_role\_name](#output\_codedeploy\_iam\_role\_name) | Name of IAM role used by CodeDeploy |
| [deploy\_script](#output\_deploy\_script) | Path to a deployment script |
| [script](#output\_script) | Deployment script |
-
+
diff --git a/examples/event-source-mapping/README.md b/examples/event-source-mapping/README.md
index 0f34132e..fcf53677 100644
--- a/examples/event-source-mapping/README.md
+++ b/examples/event-source-mapping/README.md
@@ -13,3 +13,66 @@ $ terraform apply
```
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
+
+
+## Requirements
+
+| Name | Version |
+|------|---------|
+| [terraform](#requirement\_terraform) | >= 1.0 |
+| [aws](#requirement\_aws) | >= 5.32 |
+| [random](#requirement\_random) | >= 2.0 |
+
+## Providers
+
+| Name | Version |
+|------|---------|
+| [aws](#provider\_aws) | >= 5.32 |
+| [random](#provider\_random) | >= 2.0 |
+
+## Modules
+
+| Name | Source | Version |
+|------|--------|---------|
+| [lambda\_function](#module\_lambda\_function) | ../../ | n/a |
+| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
+
+## Resources
+
+| Name | Type |
+|------|------|
+| [aws_dynamodb_table.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |
+| [aws_kinesis_stream.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kinesis_stream) | resource |
+| [aws_mq_broker.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/mq_broker) | resource |
+| [aws_secretsmanager_secret.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
+| [aws_secretsmanager_secret_version.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
+| [aws_sqs_queue.failure](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
+| [aws_sqs_queue.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
+| [random_password.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
+| [random_pet.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
+| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
+| [aws_organizations_organization.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source |
+
+## Inputs
+
+No inputs.
+
+## Outputs
+
+| Name | Description |
+|------|-------------|
+| [lambda\_event\_source\_mapping\_function\_arn](#output\_lambda\_event\_source\_mapping\_function\_arn) | The the ARN of the Lambda function the event source mapping is sending events to |
+| [lambda\_event\_source\_mapping\_state](#output\_lambda\_event\_source\_mapping\_state) | The state of the event source mapping |
+| [lambda\_event\_source\_mapping\_state\_transition\_reason](#output\_lambda\_event\_source\_mapping\_state\_transition\_reason) | The reason the event source mapping is in its current state |
+| [lambda\_event\_source\_mapping\_uuid](#output\_lambda\_event\_source\_mapping\_uuid) | The UUID of the created event source mapping |
+| [lambda\_function\_arn](#output\_lambda\_function\_arn) | The ARN of the Lambda Function |
+| [lambda\_function\_arn\_static](#output\_lambda\_function\_arn\_static) | The static ARN of the Lambda Function. Use this to avoid cycle errors between resources (e.g., Step Functions) |
+| [lambda\_function\_invoke\_arn](#output\_lambda\_function\_invoke\_arn) | The Invoke ARN of the Lambda Function |
+| [lambda\_function\_kms\_key\_arn](#output\_lambda\_function\_kms\_key\_arn) | The ARN for the KMS encryption key of Lambda Function |
+| [lambda\_function\_last\_modified](#output\_lambda\_function\_last\_modified) | The date Lambda Function resource was last modified |
+| [lambda\_function\_name](#output\_lambda\_function\_name) | The name of the Lambda Function |
+| [lambda\_function\_qualified\_arn](#output\_lambda\_function\_qualified\_arn) | The ARN identifying your Lambda Function Version |
+| [lambda\_function\_source\_code\_hash](#output\_lambda\_function\_source\_code\_hash) | Base64-encoded representation of raw SHA-256 sum of the zip file |
+| [lambda\_function\_source\_code\_size](#output\_lambda\_function\_source\_code\_size) | The size in bytes of the function .zip file |
+| [lambda\_function\_version](#output\_lambda\_function\_version) | Latest published version of Lambda Function |
+
diff --git a/examples/fixtures/runtimes/go/.gitignore b/examples/fixtures/runtimes/go/.gitignore
new file mode 100644
index 00000000..2da3a426
--- /dev/null
+++ b/examples/fixtures/runtimes/go/.gitignore
@@ -0,0 +1,2 @@
+go.sum
+bootstrap
diff --git a/examples/fixtures/runtimes/go/go.mod b/examples/fixtures/runtimes/go/go.mod
new file mode 100644
index 00000000..c572c2e4
--- /dev/null
+++ b/examples/fixtures/runtimes/go/go.mod
@@ -0,0 +1,5 @@
+module main
+
+go 1.22.6
+
+require github.com/aws/aws-lambda-go v1.47.0 // indirect
diff --git a/examples/fixtures/runtimes/go/main.go b/examples/fixtures/runtimes/go/main.go
new file mode 100644
index 00000000..6a5defa1
--- /dev/null
+++ b/examples/fixtures/runtimes/go/main.go
@@ -0,0 +1,23 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "github.com/aws/aws-lambda-go/lambda"
+)
+
+type MyEvent struct {
+ Name string `json:"name"`
+}
+
+func HandleRequest(ctx context.Context, event *MyEvent) (*string, error) {
+ if event == nil {
+ return nil, fmt.Errorf("received nil event")
+ }
+ message := fmt.Sprintf("Hello %s! serverless.tf was here!", event.Name)
+ return &message, nil
+}
+
+func main() {
+ lambda.Start(HandleRequest)
+}
diff --git a/examples/fixtures/runtimes/java21/.gitignore b/examples/fixtures/runtimes/java21/.gitignore
new file mode 100644
index 00000000..67bcc2f7
--- /dev/null
+++ b/examples/fixtures/runtimes/java21/.gitignore
@@ -0,0 +1,2 @@
+.gradle/
+build/
diff --git a/examples/fixtures/runtimes/java21/build.gradle b/examples/fixtures/runtimes/java21/build.gradle
new file mode 100644
index 00000000..53f6f6ee
--- /dev/null
+++ b/examples/fixtures/runtimes/java21/build.gradle
@@ -0,0 +1,40 @@
+plugins {
+ id 'java'
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation 'com.amazonaws:aws-lambda-java-core:1.2.1'
+ implementation 'org.slf4j:slf4j-nop:2.0.6'
+ implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
+}
+
+test {
+ useJUnitPlatform()
+}
+
+// Using terraform-aws-lambda module, there is no need to make Zip archive by Gradle. Terraform AWS module will make it for you.
+// task buildZip(type: Zip) {
+// from compileJava
+// from processResources
+// into('lib') {
+// from configurations.runtimeClasspath
+// }
+// }
+
+task copyFiles(type: Copy) {
+ into("$buildDir/output")
+
+ from sourceSets.main.output
+
+ into('lib') {
+ from configurations.runtimeClasspath
+ }
+}
+
+build.dependsOn copyFiles
diff --git a/examples/fixtures/runtimes/java21/src/main/java/example/Handler.java b/examples/fixtures/runtimes/java21/src/main/java/example/Handler.java
new file mode 100644
index 00000000..08b14d81
--- /dev/null
+++ b/examples/fixtures/runtimes/java21/src/main/java/example/Handler.java
@@ -0,0 +1,19 @@
+package example;
+
+import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.LambdaLogger;
+import com.amazonaws.services.lambda.runtime.RequestHandler;
+
+import java.util.Map;
+
+// Handler value: example.Handler
+public class Handler implements RequestHandler