Terraform to create lambda layer by specify arn

I’m trying to use libre office lambda layer in my lambda function :

I can set this up manually from console. However, I’m not sure how to get it working in terraform. So far I have the following resource:

data “archive_file” “converttopdf_lambda” {
type = “zip”
source_dir = “./data/converttopdf”
output_path = “converttopdf.zip”

resource “aws_lambda_layer_version” “lambda_converttopdf_lambda” {
layer_name = var.converttopdf_layername
filename = “${data.archive_file.converttopdf_lambda.output_path}”

resource “aws_lambda_function” “converttopdf_lambda_funcn” {
filename = “{data.archive_file.converttopdf_lambda.output_path}" function_name = "copi_{var.environment}_converttopdf”
role = aws_iam_role.role_lambda.arn
handler = var.converttopdf_lambda_handler
runtime = var.converttopdf_lambda_runtime
publish = var.converttopdf_lambda_publish
timeout = var.lambdatimeout
memory_size = var.lambda_memorysize
layers = [aws_lambda_layer_version.lambda_converttopdf_lambda.arn]

Please check this image that how I created via manually.

please help!

I’m not seeing what the issue is. Are you getting an error? If so, what is that error?

The layers =[] declaration looks correct. What you’re doing looks correct to me from the AWS provider docs. You might also want to try (or search) the AWS provider category, where folks more familiar with that provider might help: AWS - HashiCorp Discuss

Thanks for the response. I am not getting any error. My request is different. Hope you referred the snip in my earlier post. I want to know how I can specify ARN in “aws_lambda_layer_version” resource? As per AWS Provider docs I dont find any argument reference to specify the ARN. So what I am expecting now is which argument reference I have to use to specify the ARN?

I have to specify following ARN in lambda layer.


Thanks again

I understand that your screenshot was created during creating a new lambda function not a layer.

Do you want to create another lambda layer version which is stacked on top of the arn provided?
Wouldn’t you rather include multiple layers within the lambda function?

No Lambda was already created, now I am trying to add layer for that Lambda that is what my screenshot looks. Ok what ever it would be is fine but my request is how to create layer by specifying another Lambda ARN through terraform?


I just found that we dont want to create new layer, just we can specify libre office ARN directly in Lambda configuration in terraform. Hence closing this.