~/codewithstu

// open_source

AWS Lambda

OpenTofu module for provisioning AWS Lambda functions with CloudWatch logs, IAM roles, VPC support, and both zip and container image deployments

View on GitHub

Overview

This module creates an AWS Lambda function with CloudWatch logs, IAM role, and optional VPC configuration. It supports both Zip and container image deployments.

Key Features

  • Zip and container image (ECR) package types
  • Configurable memory, timeout, and reserved concurrency
  • Dead letter queue integration (SNS or SQS)
  • CloudWatch log group with configurable retention and optional KMS encryption
  • IAM role with inline policies and managed policy attachments
  • Optional VPC configuration with subnet and security group support
  • ARM64 architecture by default on provided.al2023 runtime

Usage

module "lambda" {
  source = "git::https://github.com/Im5tu/opentofu-aws-lambda.git?ref=main"
 
  name                  = "my-function"
  handler               = "bootstrap"
  dead_letter_target_arn = aws_sqs_queue.dlq.arn
  function_zip_name     = "lambda.zip"
  function_zip_hash     = filebase64sha256("lambda.zip")
}