@@ -14,11 +14,15 @@ Terraform module that creates a Lambda function with zip packaging, IAM executio
1414
1515## Usage
1616
17+ ### Basic Usage with Template Generation
18+
1719``` hcl
1820module "lambda_function" {
1921 source = "git::https://github.com/ql4b/terraform-aws-lambda-function.git"
2022
21- source_dir = "./src"
23+ source_dir = "./src"
24+ create_templates = true
25+ template_dir = "./src"
2226
2327 context = {
2428 namespace = "myorg"
@@ -27,18 +31,23 @@ module "lambda_function" {
2731}
2832```
2933
34+ This will automatically create ` bootstrap ` , ` handler.sh ` , and ` Makefile ` in your ` ./src ` directory.
35+
3036## Advanced Usage
3137
3238``` hcl
3339module "lambda_function" {
3440 source = "git::https://github.com/ql4b/terraform-aws-lambda-function.git"
3541
36- source_dir = "./src"
37- handler = "bootstrap"
38- runtime = "provided.al2023"
39- architecture = "arm64"
40- memory_size = 256
41- timeout = 30
42+ source_dir = "./src"
43+ create_templates = true
44+ template_dir = "./src"
45+
46+ handler = "bootstrap"
47+ runtime = "provided.al2023"
48+ architecture = "arm64"
49+ memory_size = 256
50+ timeout = 30
4251
4352 environment_variables = {
4453 HANDLER = "/var/task/handler.sh"
@@ -55,12 +64,21 @@ module "lambda_function" {
5564}
5665```
5766
58- ## Source Directory Structure
67+ ## Template Generation
68+
69+ Set ` create_templates = true ` to automatically generate starter files:
70+
71+ - ` bootstrap ` - Lambda runtime bootstrap (executable)
72+ - ` handler.sh ` - Example function handler
73+ - ` Makefile ` - Deployment and testing commands
74+
75+ ### Generated Directory Structure
5976
6077```
6178src/
6279├── bootstrap # Lambda runtime bootstrap (executable)
63- └── handler.sh # Your function code
80+ ├── handler.sh # Your function code
81+ └── Makefile # Deployment commands
6482```
6583
6684## Example Bootstrap
@@ -111,11 +129,20 @@ terraform init
111129terraform apply
112130```
113131
114- ### 2. Use the Included Makefile
132+ ### 2. Set Function Name
133+
134+ ``` bash
135+ export FUNCTION_NAME=$( terraform output -raw function_name)
136+ ```
137+
138+ ### 3. Use the Generated Makefile
115139
116- The module includes a ` Makefile ` for simple deployment workflows:
140+ When ` create_templates = true ` , a ` Makefile ` is generated with deployment workflows:
117141
118142``` bash
143+ # Set function name
144+ export FUNCTION_NAME=$( terraform output -raw function_name)
145+
119146# Deploy function code
120147make deploy
121148
@@ -132,7 +159,7 @@ make clean
132159make help
133160```
134161
135- ### 3 . Manual Deployment (Alternative)
162+ ### 4 . Manual Deployment (Alternative)
136163
137164``` bash
138165# Package and deploy manually
@@ -159,6 +186,7 @@ cat /tmp/response.json
159186- ` function_arn ` - Lambda function ARN
160187- ` execution_role_arn ` - IAM execution role ARN
161188- ` log_group_name ` - CloudWatch log group name
189+ - ` template_files ` - Paths to generated template files (when ` create_templates = true ` )
162190
163191## Integration with Lambda Layers
164192
0 commit comments