I have a reusable module for lambdas that has a dummy zip file with one dummy text file in it. I provision the lambda, permissions, cron, env, whatever it needs. Then I use GitHub Actions to actually publish the real zip file. My IAC and app code live in different repos. Answer from derekmckinnon on reddit.com
Terraform Registry
registry.terraform.io › providers › - › aws › latest › docs › resources › lambda_function
aws_lambda_function | Resources | hashicorp/aws | Terraform | Terraform Registry
Registry · Please enable Javascript to use this application · Browse aws documentation · Report an issue
Reddit
reddit.com › r/aws › how do you handle lambdas when using terraform?
r/aws on Reddit: How do you handle Lambdas when using terraform?
May 29, 2024 -
mysterious straight bow telephone birds ask meeting scary boat terrific
This post was mass deleted and anonymized with Redact
Top answer 1 of 27
46
I have a reusable module for lambdas that has a dummy zip file with one dummy text file in it. I provision the lambda, permissions, cron, env, whatever it needs. Then I use GitHub Actions to actually publish the real zip file. My IAC and app code live in different repos.
2 of 27
10
Why not let terraform do the zipping for you? No need to S3 it to a bucket: data "archive_file" "my_function_lambda_payload" { type = "zip" source_dir = var.my_function_lambda_src_dir excludes = [ "venv", "_pycache_" ] output_path = "${var.my_function_lambda_payload_dir}/payload.zip" } resource "aws_lambda_function" "my_function" { filename = data.archive_file.my_function_lambda_payload.output_path source_code_hash = data.archive_file.my_function_lambda_payload.output_base64sha256 ... }
Videos
05:17
How to create and deploy AWS Lambda functions with Terraform - YouTube
22:06
🚀 Deploy AWS Lambda with Terraform — FULL Setup for Beginners ...
34:51
Create an AWS Lambda with Terraform - YouTube
24:03
AWS Lambda Terraform Tutorial with API Gateway - YouTube
How do I deploy AWS Lambda using Terraform?
28:08
Terraform AWS Api gateway + Lambda Integration 🚀 - YouTube
GitHub
github.com › terraform-aws-modules › terraform-aws-lambda
GitHub - terraform-aws-modules/terraform-aws-lambda: Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
Using SAM CLI, you can invoke the lambda functions defined in the terraform application locally using the sam local invoke command, providing the function terraform address, or function name, and to set the hook-name to terraform to tell SAM CLI that the underlying project is a terraform application. You can execute the sam local invoke command from your terraform application root directory as following: sam local invoke --hook-name terraform module.hello_world_function.aws_lambda_function.this[0]
Starred by 1K users
Forked by 760 users
Languages HCL 59.8% | Python 40.2%
Lumigo
lumigo.io › aws-lambda-deployment › aws-lambda-terraform
Deploying AWS Lambda with Terraform: Quick Tutorial and Basic Concepts · Dash0
3 weeks ago - Sign into the AWS Console, navigate to Amazon Identity and Access Management (IAM). Click Create IAM User and create a user with administrative privileges on both Amazon console and API. ... Now that everything is set up, we can start working in our default project directory. Create a directory for your project, for example {Terraform-folder}\lambda-test. Create a simple Hello World Lambda function with the following code, and name it hello.js.
DEV Community
dev.to › chinmay13 › configuring-an-aws-lambda-function-with-lambda-layers-and-function-url-using-terraform-25a0
Configuring an AWS Lambda Function with Lambda Layers and Function URL Using Terraform - DEV Community
February 10, 2025 - Now, create the Lambda function using Terraform. It will use the function code zip file, layer ARN and other parameters. ################################################################################ # Creating Lambda Function ################################################################################ resource "aws_lambda_function" "get_joke_lambda_function" { function_name = "ChuckNorrisJokes_Lambda" filename = "${path.module}/lambda_function.zip" runtime = "python3.12" handler = "chucknorris_jokes.lambda_handler" layers = [aws_lambda_layer_version.requests_layer.arn] memory_size = 128 timeout = 10 environment { variables = { API_URL = "https://api.chucknorris.io/jokes/random" } } source_code_hash = data.archive_file.lambda_function_archive.output_base64sha256 role = aws_iam_role.lambda_role.arn }
Medium
leejjon.medium.com › use-terraform-to-create-an-aws-lambda-function-that-runs-your-typescript-code-b805db667a93
Use Terraform to create an AWS Lambda function that runs your TypeScript code | by Leejjon | Medium
May 26, 2024 - The ugly part of AWS Lambda (and other AWS services such as Beanstalk) is that it’s not able to just grab an npm project and run npm start. That’s why in the above package.json I don’t specify a start script. It works with zip files like we live in the year 2000. We can create a deploy.sh file in our terraform folder to automate the creation of a zip file: function deploy { # Generate a version number based on a date timestamp so that it's unique TIMESTAMP=$(date +%Y%m%d%H%M%S) cd ../lambda/ && \ # Run the npm commands to transpile the TypeScript to JavaScript npm i && \ npm run build && \ npm prune --production &&\ # Create a dist folder and copy only the js files to dist.
Baeldung
baeldung.com › home › deployment tools › how to set up aws lambda function in terraform
How To Set Up AWS Lambda Function in Terraform | Baeldung on Ops
March 27, 2025 - This policy allows complete management of a specific Lambda function (hello_lambda), its associated CloudWatch Events rules, an IAM execution role (lambda_exec_role), and related CloudWatch Logs within the AWS account and region (us-east-1). ... $ aws iam create-policy \ --policy-name TerraformLambdaPolicy \ --policy-document file://terraform-policy.json { "Policy": { "PolicyName": "TerraformLambdaPolicy", "PolicyId": "ANPA4T4OCLX5U4EKMVY2C", "Arn": "arn:aws:iam::<ACCOUNT_ID>:policy/TerraformLambdaPolicy", "Path": "/", "DefaultVersionId": "v1", "AttachmentCount": 0, "PermissionsBoundaryUsageCount": 0, "IsAttachable": true, "CreateDate": "2025-02-14T15:51:06Z", "UpdateDate": "2025-02-14T15:51:06Z" } }
GitHub
github.com › cloudposse › terraform-aws-lambda-function
GitHub - cloudposse/terraform-aws-lambda-function: A module for launching Lambda Fuctions · GitHub
A module for launching Lambda Fuctions. Contribute to cloudposse/terraform-aws-lambda-function development by creating an account on GitHub.
Starred by 37 users
Forked by 45 users
Languages HCL 77.6% | Go 16.7% | Makefile 5.7%
Kosli
kosli.com › blog › how-to-provision-your-aws-lambda-function-using-terraform
How to Provision Your AWS Lambda Function Using Terraform
In real-world use cases, you would usually have distinct names for each of your functions and their attributes. The next steps are the same. First, see the effect of your changes without applying them by running terraform plan. It should let you know that one new Lambda resource will be created: ... Terraform will perform the following actions: # aws_lambda_function.terraform_basic_lambda_func_2 will be created + resource "aws_lambda_function" "terraform_basic_lambda_func_2" { + architectures = (known after apply) + arn = (known after apply) + filename = "./code_2/hello-world.zip" + function_n
Movestax
movestax.com › post › step-by-step-guide-to-aws-lambda-with-terraform
Step-by-Step Guide to AWS Lambda with Terraform
July 8, 2025 - Deploying a Lambda function with Terraform involves three key commands, each serving a specific purpose in the deployment process. ... Begin by running terraform init in your project directory. This command sets up your workspace by downloading the AWS provider and any necessary plugins:
Terraform Registry
registry.terraform.io › providers › hashicorp › aws › latest › docs › resources › lambda_invocation
aws_lambda_invocation | Resources | hashicorp/aws
Registry · Please enable Javascript to use this application
GitHub
github.com › mineiros-io › terraform-aws-lambda-function
GitHub - mineiros-io/terraform-aws-lambda-function: A Terraform module for deploying and managing Lambda functions on Amazon Web Services (AWS). https://aws.amazon.com/lambda/
A Terraform module for deploying and managing Serverless Lambda Functions on Amazon Web Services (AWS).
Starred by 41 users
Forked by 24 users
Languages HCL 74.8% | Go 13.9% | Makefile 11.3% | HCL 74.8% | Go 13.9% | Makefile 11.3%