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 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 657 forks source link

Support lifecycle ignore_changes for lambda versions #408

Closed rgoomar closed 1 year ago

rgoomar commented 1 year ago

Is your request related to a problem? Please describe.

I'm running into an issue where we use Terraform to define our Lambdas and deploy new versions using a different pipeline (outside of Terraform) and the terraform plan output when using this module gives us a very long list of Objects have changed outside of Terraform block.

For every function we have, it shows something like this:

# module.some_name.module.aws_lambda.aws_lambda_function.this[0] has changed
    ~ resource "aws_lambda_function" "this" {
          id                             = "some_name"
        ~ last_modified                  = "2023-01-18T21:03:26.000+0000" -> "2023-01-30T18:17:27.000+0000"
        ~ qualified_arn                  = "arn:aws:lambda:region:***:function:some-name-production:277" -> "arn:aws:lambda:region:***:function:some-name-production:298"
        ~ source_code_hash               = "+aati4Nv1y5P6ff3sQ" -> "n2GS9AzOGctZsOEATDn2RlkDLc8g="
        ~ source_code_size               = 340626 -> 340701
        ~ version                        = "277" -> "298"
          # (18 unchanged attributes hidden)

          # (3 unchanged blocks hidden)
      }

This makes our terraform plan outputs very noisy and harder to parse. I would like for these to be ignored.

Describe the solution you'd like.

Given we, as consumers of the module can't use the lifecycle ignore_changes block, I was hoping that we could add an input variable that can add those ignore_changes if the intention is to have your function versions be updated elsewhere.

Something like:

lifecycle {
  ignore_changes = [
    last_modified,
    qualified_arn,
    source_code_hash,
    source_code_size,
    version,
  ]
}

Although given that lifecycle arguments can be literal values only, I'm unsure what the best approach here is to basically have this only show up based on an input variable.

antonbabenko commented 1 year ago

Please take a look in this example and make sure that you specify ignore_source_code_hash = true.

rgoomar commented 1 year ago

@antonbabenko That flag is set and we still get these outputs in the plan.

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.