You have to specify lambda layers as ARNs in terraform using layers parameter:

layers - (Optional) List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function.

Using the following syntax in terraform:

layers = ["layer-arn"]

For example, the ARN for AWSLambda-Python27-SciPy1x in us-east-1 region is:

arn:aws:lambda:us-east-1:668099181075:layer:AWSLambda-Python27-SciPy1x:24

If you not sure what is your ARN, you can create a dummy a Python 2.7 lambda function, add AWS layer AWSLambda-Python27-SciPy1x layer, and the console will give you its ARN.

Answer from Marcin on Stack Overflow
🌐
Terraform
registry.terraform.io › modules › terraform-aws-modules › lambda › aws › latest › examples › complete
terraform-aws-modules/lambda/aws | complete Example | Terraform Registry
module "lambda_example_complete" { source = "terraform-aws-modules/lambda/aws//examples/complete" version = "8.7.0" } Configuration in this directory creates AWS Lambda Function, Layers, Alias, and so on with the large variety of supported features showing this module in action.
Discussions

amazon web services - How to use an AWS provided lambda layer in Terraform? - Stack Overflow
I am trying to run a python function on an AWS Lambda layer, I don't find any documentation on terraform to use an AWS provided lambda layer. How do I use AWS Provided lambda layer AWSLambda-Pytho... More on stackoverflow.com
🌐 stackoverflow.com
How do you handle Lambdas when using terraform?
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. More on reddit.com
🌐 r/aws
56
29
May 29, 2024
I worked on an AWS + Terraform project and would like to upload it to Github, should I avoid uploading my Lambda layers? What's best practice for showcasing my work with Terraform on Github?
Terraform can package your lambda folder into a zip and then publish it as a function. Same with the layer: can be packaged same way and then published as lambda_layer_version . You definitely should not be committing your zip files to the repo, as those are generated artifacts. More on reddit.com
🌐 r/Terraform
8
4
December 3, 2023
Lambda functions in terraform
It should look something like this, using base64sha256 data "archive_file" "lambda_zip" { type = "zip" source_dir = "../dir/lambda.py" output_path = "../dir/lambda_package.zip" } resource "aws_lambda_function" "func" { description = "some description" function_name = "lambda" filename = data.archive_file.lambda_zip.output_path runtime = "python3.7" handler = "lambda_handler" source_code_hash = data.archive_file.lambda_zip.output_base64sha256 role = aws_iam_role.function_role.arn timeout = var.timeout publish = true } Excuse the formatting, I’m on mobile. Obviously change anything above to suit your code base. More on reddit.com
🌐 r/Terraform
19
7
November 10, 2022
🌐
GitHub
github.com › enter-at › terraform-aws-lambda-layer
GitHub - enter-at/terraform-aws-lambda-layer: Terraform module designed to facilitate the creation of AWS Lambda layers
module "layer" { source = "git::https://github.com/enter-at/terraform-aws-lambda-layer.git?ref=main" layer_name = "dependencies" source_dir = "../src/lib" source_type = "python" rsync_pattern = [ "--exclude='**tests**'", "--exclude='**__pycache__**'", "--include=module/{a,b,c}/", "--include='*.py'", "--exclude='module/*'" ] }
Starred by 13 users
Forked by 14 users
Languages   HCL 56.0% | Shell 35.2% | Makefile 8.8% | HCL 56.0% | Shell 35.2% | Makefile 8.8%
🌐
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 - Upon successful completion, Terraform will provide relevant outputs. Apply complete! Resources: 6 added, 0 changed, 0 destroyed. Outputs: lambda_function_url = "https://khpjd5gawsrgpjoo5ayqffr5c40udyuw.lambda-url.us-east-1.on.aws/" Lambda Function, showing (1) layer, function URL and code
Find elsewhere
🌐
LinkedIn
linkedin.com › pulse › how-deploy-aws-lambda-function-layer-using-terraform-hendrix-roa
How to deploy an AWS Lambda function with a layer using Terraform
June 10, 2023 - To create a layer, we just need to reference the module location (could be an external registry or local machine), in my the lambda layer location is one back folder at my root directory: module "lambda_noiselesstech" { source = "../terraform-aws-lambda" // A public registry path is allowed too code_location = "./lambdas/example" filename = "example.zip" lambda_function_name = "NoiselesstechExample" lambda_runtime = "nodejs14.x" layer_arn = module.layer.arn environment_variables = { secret = "super secret value" } }
🌐
My Devops Journal
skundunotes.com › 2024 › 09 › 29 › create-aws-lambda-layer-using-docker-terraform-and-github-actions
Create AWS Lambda Layer using Docker, Terraform and GitHub Actions – My Devops Journal
October 6, 2024 - In this use case, I am referencing two GitHub repositories. Repository#1 is aws-lambda-base-images where I executed the Docker commands and created the Docker image. Repository#2 is aws-lambda-layer-terraform where I have the Terraform code and the Python3.10 libraries to create the Lambda layer.
🌐
Shisho Cloud
shisho.dev › dojo › providers › aws › Lambda › aws-lambda-layer-version
AWS Lambda Layer Version - Examples and best practices | Shisho Dojo
AWS Lambda Layer Version is a resource for Lambda of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation. For Terraform, the Vizzyy/stunning-disco and cds-snc/forms-staging-terraform source code examples are useful.
🌐
Medium
mahira-technology.medium.com › the-ultimate-guide-to-creating-lambda-layers-using-terraform-f64fa34b9b19
The Ultimate Guide to Creating Lambda Layers Using Terraform. | by Mahira Technology- Innovate. Transform. Thrive. | Medium
April 29, 2024 - The Ultimate Guide to Creating Lambda Layers Using Terraform. Overview :- Imagine you’ve written several Lambda functions, and they all use the same utility library or a particular SDK. Instead of …
🌐
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 🇺🇦
This Terraform module is the part of serverless.tf framework, which aims to simplify all operations when working with the serverless in Terraform: Build and install dependencies - read more. Requires Python 3.6 or newer. Create, store, and use deployment packages - read more. Create, update, and publish AWS Lambda Function and Lambda Layer - see usage.
Starred by 1K users
Forked by 760 users
Languages   HCL 59.8% | Python 40.2%
🌐
Medium
aws.plainenglish.io › streamlining-serverless-applications-managing-aws-lambda-dependencies-with-layers-and-terraform-18968cf27811
Streamlining Serverless Applications: Managing AWS Lambda Dependencies with Layers and Terraform | by Yeldos Tanikin | AWS in Plain English
October 31, 2024 - To get the most out of Lambda, it’s crucial to understand how to upload and manage your function’s dependencies. This article will discuss the different ways to upload dependencies, introduce the concept of Lambda Layers, and demonstrate how to create a Lambda Layer using Terraform.
🌐
Rahul Lokurte Blog
rahullokurte.com › aws-lambda-using-terraform
AWS Lambda Using Terraform - Rahul Lokurte Blog
July 17, 2021 - Create the files lambda.tf and lambda_layer.tf in the root directory of the project and add the below content. ... module "profile_generator_lambda" { source = "terraform-aws-modules/lambda/aws" version = "2.7.0" # insert the 28 required variables here function_name = "profile-generator-lambda" description = "Generates a new profiles" handler = "index.handler" runtime = "nodejs14.x" source_path = "${path.module}/resources/profile-generator-lambda" layers = [module.profile_generator_lambda_layer.lambda_layer_arn] tags = { Name = "profile-generator-lambda" } }
🌐
Avangards
blog.avangards.io › 3-ways-to-publish-and-use-an-aws-lambda-layer-in-terraform
3 Ways To Publish and Use an AWS Lambda Layer in Terraform
April 2, 2025 - After we create the zip that contains the python directory that has the downloaded NumPy distributable files, we can publish the Lambda layer in Terraform using the aws_lambda_layer_version resource as follows: resource "aws_lambda_layer_version" "example_lambda_layer" { description = "Example lambda layer" filename = "${path.module}/lambda_layers/example-lambda-layer.zip" layer_name = "example-lambda-layer" compatible_runtimes = ["python3.11"] source_code_hash = filebase64sha256("${path.module}/lambda_layers/example-lambda-layer.zip") }
🌐
Chocksaway
chocksaway.com › code › 2024 › 01 › 21 › Terraform-Lambda-Layers.html
Terraform Lambda Layers | chocksaway.com
January 21, 2024 - resource "aws_lambda_function" "simple_node_lambda_function" { filename = "lambda.zip" function_name = "SimpleNodeLambdaFunction" role = aws_iam_role.simple-node-lambda_role.arn handler = "index.handler" source_code_hash = filebase64sha256("lambda.zip") runtime = "nodejs14.x" layers = [aws_lambda_layer_version.simple_node_lambda-layer.arn] } I found a useful terraform module, aws_lambda_invocation:
🌐
Spacelift
spacelift.io › learn › terraform-lambda-layer
How to Use AWS Lambda Layers With Terraform
January 8, 2026 - This keeps function packages slim, ... first example, let’s create a simple Python Lambda layer that contains shared dependencies, then attach that layer to a single Lambda function using Terraform....
🌐
Medium
medium.com › wescale › how-to-lightweight-your-python-aws-lambda-functions-with-aws-lambda-layer-docker-and-terraform-b48602e76e8b
How to lightweight your Python AWS Lambda functions with AWS Lambda Layer, Docker, and Terraform. | by Tanguy Combe | WeScale | Medium
April 11, 2022 - Fortunately, AWS developed a new feature named AWS Lambda Layer to let you build common packages usable by the runtime. We will dive into this use case: how can I package with ease a big Python library and use it through AWS console within one or multiple Lambda functions? Suppose that you have some data engineering stuff to do, you may need to use Pandas to workaround your application. ... Terraform ~> 0.11.12 to use filebase64hash256 for Terraform to detect code changes, it can also work with base64sha256(file()) for Terraform earlier versions.