https://github.com/mich0232/aws-lambda
AWS Lambda module creates a function with required IAM Roles and permissions. You can enable CW logs and X-Ray integration
https://github.com/mich0232/aws-lambda
aws aws-lambda terraform terraform-module
Last synced: about 2 months ago
JSON representation
AWS Lambda module creates a function with required IAM Roles and permissions. You can enable CW logs and X-Ray integration
- Host: GitHub
- URL: https://github.com/mich0232/aws-lambda
- Owner: Mich0232
- Created: 2022-11-27T17:07:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-20T17:51:34.000Z (over 3 years ago)
- Last Synced: 2025-01-13T19:21:46.021Z (over 1 year ago)
- Topics: aws, aws-lambda, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## AWS Lambda module
This module creates a simple AWS function.
Function can be integrated with AWS Package module to create an on-change triggered function deployment.
Note: Function will be granted access to the deployment bucket provided in the configuration.
### Provisioned Resources:
- AWS Lambda
- IAM Role with CloudWatch & S3 deployment bucket access policy
### Input Variables:
`project_name` - Name of the project (Project name will be included as a prefix in resources)
`function_name` - Lambda function name (Note: final lambda name will consist of project + lambda names)
`policies` - list or IAM policy arns that will be attached to lambda's IAM Role.
`layers` - list of AWS Layer's arns to attached to function.
`enable_cloudwatch_logs` - If true 'AWSLambdaBasicExecutionRole' will be attached. (default: true)
`enable_x_ray_tracing` - If true 'AWSXRayDaemonWriteAccess' will be attached. (default: false)
`deployment_bucket_arn` - ARN of S3 bucket containing the AWS lambda deployment package.
`deployment_bucket_name` - Name of S3 bucket containing the AWS lambda deployment package.
`deployment_package_key` - Key of S3 bucket object with the AWS lambda deployment package.
### Lambda settings
[AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html)
- `timeout` - 60s
- `memory` - 128mb
- `runtime` - python3.9
- `handler` - main.handler
- `architectures` - x86_64
`tags` - map of lambda tags (Up to 8 can be specified since, Name and Project will be added by default)
### Outputs
`function_name` - Function name
`arn` - ARN of created function
`invoke_arn` - Invoke ARN of created function
`version` - Latest published version of created function
### Example
```terraform
module "lambda" {
source = "github.com/Mich0232/aws-lambda.git"
project_name = "example-project"
function_name = "my-service"
deployment_bucket_arn = aws_s3_bucket.deployment_bucket.arn
deployment_bucket_name = aws_s3_bucket.deployment_bucket.bucket
deployment_package_key = "my-service/build.zip"
source_code_hash = "83bc6426i7b73ci"
}
```
Using [aws-package module](https://github.com/Mich0232/aws-package):
```terraform
module "code" {
source = "github.com/Mich0232/aws-package.git"
deployment_bucket_id = aws_s3_bucket.deployment_bucket.id
deployment_bucket_prefix = "example"
source_dir = "../src"
output_dir = "../output/code"
hash_sources = [ "*.py" ]
excluded_paths = [ "__pycache__" ]
}
module "lambda" {
source = "github.com/Mich0232/aws-lambda.git"
project_name = "example-project"
function_name = "my-service"
deployment_bucket_arn = aws_s3_bucket.deployment_bucket.arn
deployment_bucket_name = aws_s3_bucket.deployment_bucket.bucket
deployment_package_key = module.code.key
source_code_hash = module.code.output_base64sha256
}
```