HiveBrain v1.2.0
Get Started
← Back to all entries
snippetterraformMinor

How do I create multiple versions of a lambda function in terraform

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
howcreatefunctionmultipleversionslambdaterraform

Problem

I have it creating one version. It has latest and version 2 but can’t getting it to create more than one version of the same lambda?

resource "aws_lambda_function" "lambda" {
  function_name = "test-lambda2"
  publish = true
  runtime = "python2.7"
  source_code_hash =  "${data.archive_file.lambda_zip.output_base64sha256}"                                             handler = "index.handler"
  filename = "lambda_function.zip"
  role = "${aws_iam_role.iam_for_lambda_tf.arn}"
}

Solution

This is shown in the Hashicorp tutorial - "a new version of the lambda function. The suggestion there is to point to a different zipfile in S3.

I suppose in your case, the filename either needs to change, or the file contents need to change.

The suggestion from the tutorial is to use a variable for the filename, associated with the version of the application.

Context

StackExchange DevOps Q#9440, answer score: 2

Revisions (0)

No revisions yet.