Skip to content

Commit 2319485

Browse files
committed
docs: update README
1 parent 3921ae9 commit 2319485

File tree

1 file changed

+59
-24
lines changed

1 file changed

+59
-24
lines changed

README.md

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# terraform-aws-lambda-function
22

3-
> Minimal Lambda function with zip packaging for provided.al2023 runtime
3+
> Minimal Lambda function with zip packaging and container image support for provided.al2023 runtime
44
5-
Terraform module that creates a Lambda function with zip packaging, IAM execution role, and CloudWatch logs. Perfect for shell scripts and custom runtimes without container overhead.
5+
Terraform module that creates a Lambda function with zip packaging or container images, IAM execution role, and CloudWatch logs. Perfect for shell scripts and custom runtimes.
66

77
## Features
88

99
- **Zip packaging** from source directory
10+
- **Container image** deployment from ECR
1011
- **IAM execution role** with basic Lambda permissions
1112
- **CloudWatch log group** with configurable retention
1213
- **provided.al2023 runtime** optimized for shell scripts
1314
- **CloudPosse labeling** for consistent naming
1415

1516
## Usage
1617

17-
### Basic Usage with Template Generation
18+
### Basic Usage with Zip Packaging
1819

1920
```hcl
2021
module "lambda" {
@@ -31,17 +32,42 @@ module "lambda" {
3132

3233
This will automatically create `bootstrap`, `handler.sh`, and `Makefile` in your `../app/src` directory.
3334

34-
**Note:** This module integrates seamlessly with any existing Terraform setup. The example above shows integration with CloudPosse labeling, but you can use it standalone or with any naming convention.
35+
### Container Image Usage
3536

36-
## Advanced Usage
37+
```hcl
38+
module "lambda_function" {
39+
source = "git::https://github.com/ql4b/terraform-aws-lambda-function.git"
40+
41+
package_type = "Image"
42+
image_uri = "${aws_ecr_repository.example.repository_url}:latest"
43+
44+
image_config = {
45+
entry_point = ["/lambda-entrypoint.sh"]
46+
command = ["app.handler"]
47+
}
48+
49+
memory_size = 512
50+
timeout = 30
51+
52+
environment_variables = {
53+
THUMBNAILS_BUCKET = module.thumbnails_bucket.bucket_id
54+
}
55+
56+
context = module.label.context
57+
attributes = ["lambda"]
58+
}
59+
```
60+
61+
**Note:** This module integrates seamlessly with any existing Terraform setup. The examples above show integration with CloudPosse labeling, but you can use it standalone or with any naming convention.
62+
63+
## Advanced Zip Configuration
3764

3865
```hcl
3966
module "lambda_function" {
4067
source = "git::https://github.com/ql4b/terraform-aws-lambda-function.git"
4168
42-
source_dir = "./src"
43-
create_templates = true
44-
template_dir = "./src"
69+
package_type = "Zip"
70+
source_dir = "./src"
4571
4672
handler = "bootstrap"
4773
runtime = "provided.al2023"
@@ -64,25 +90,34 @@ module "lambda_function" {
6490
}
6591
```
6692

67-
## Integration with Existing Projects
93+
## Variables
94+
95+
| Name | Description | Type | Default | Required |
96+
|------|-------------|------|---------|:--------:|
97+
| package_type | Lambda deployment package type | `string` | `"Zip"` | no |
98+
| image_uri | ECR image URI for container image deployment | `string` | `null` | no |
99+
| image_config | Container image configuration | `object` | `null` | no |
100+
| source_dir | Path to source directory (Zip only) | `string` | n/a | yes |
101+
| handler | Lambda function handler (Zip only) | `string` | `"bootstrap"` | no |
102+
| runtime | Lambda runtime (Zip only) | `string` | `"provided.al2023"` | no |
103+
| architecture | Lambda function architecture | `string` | `"arm64"` | no |
104+
| memory_size | Memory in MB | `number` | `128` | no |
105+
| timeout | Timeout in seconds | `number` | `3` | no |
106+
| environment_variables | Environment variables | `map(string)` | `{}` | no |
68107

69-
This module is designed to plug into any existing Terraform setup:
108+
## Container Image Configuration
109+
110+
The `image_config` object supports:
70111

71112
```hcl
72-
# Add to your existing main.tf
73-
module "my_function" {
74-
source = "git::https://github.com/ql4b/terraform-aws-lambda-function.git"
75-
76-
source_dir = "./lambda-src"
77-
create_templates = true
78-
template_dir = "./lambda-src"
79-
80-
# Use your existing naming/tagging strategy
81-
context = var.context # or however you handle naming
113+
image_config = {
114+
entry_point = ["/lambda-entrypoint.sh"] # Optional
115+
command = ["app.handler"] # Optional
116+
working_directory = "/var/task" # Optional
82117
}
83118
```
84119

85-
## Template Generation
120+
## Template Generation (Zip Only)
86121

87122
Set `create_templates = true` to automatically generate starter files:
88123

@@ -157,7 +192,7 @@ export FUNCTION_NAME=$(terraform output -raw function_name)
157192
export FUNCTION_NAME=$(tf output --json lambda | jq -r .function_name)
158193
```
159194

160-
### 3. Use the Generated Makefile
195+
### 3. Use the Generated Makefile (Zip Only)
161196

162197
When `create_templates = true`, a `Makefile` is generated with deployment workflows:
163198

@@ -203,15 +238,15 @@ cat /tmp/response.json
203238

204239
- Terraform >= 1.0
205240
- AWS provider >= 5.0
206-
- Archive provider >= 2.0
241+
- Archive provider >= 2.0 (Zip packaging only)
207242

208243
## Outputs
209244

210245
- `function_name` - Lambda function name
211246
- `function_arn` - Lambda function ARN
212247
- `execution_role_arn` - IAM execution role ARN
248+
- `execution_role_name` - IAM execution role name
213249
- `log_group_name` - CloudWatch log group name
214-
- `template_files` - Paths to generated template files (when `create_templates = true`)
215250

216251
## Integration with Lambda Layers
217252

0 commit comments

Comments
 (0)