Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_lambda_function always updates even with no changes #9786

Closed
gtirloni opened this issue Aug 15, 2019 · 14 comments
Closed

aws_lambda_function always updates even with no changes #9786

gtirloni opened this issue Aug 15, 2019 · 14 comments
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.

Comments

@gtirloni
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.6
terraform-provider-aws 2.23.0

Affected Resource(s)

aws_lambda_function

Terraform Configuration Files

resource "aws_lambda_function" "default" {
  filename = substr(
    "${path.module}/${local.lambda_filename}-${var.environment}.zip",
    length(path.cwd) + 1,
    -1,
  ) // +1 for removing the "/"
  function_name = local.name
  role          = aws_iam_role.default.arn
  handler       = "lambda_function.lambda_handler"

  runtime = "python3.7"
  source_code_hash = filebase64sha256(
    "${path.module}/${local.lambda_filename}-${var.environment}.zip",
  )
  timeout = "5"
  publish = "true"
  tags = local.tags

  lifecycle {
    ignore_changes = [
      filename,
      last_modified,
    ]
  }
}

Expected Behavior

Terraform should not try to update the resource.

Actual Behavior

Terraform always wants to update the resource, regardless if there are changes or not.

Debug output

  # module.xx.aws_lambda_function.default will be updated in-place
  ~ resource "aws_lambda_function" "default" {
        arn                            = "arn:aws:lambda:us-east-1:12345678:function:xx"
        filename                       = ".terraform/modules/xx/xx.zip"
        function_name                  = "xx"
        handler                        = "lambda_function.lambda_handler"
        id                             = "xx"
        invoke_arn                     = "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:12345678:function:xx/invocations"
        last_modified                  = "2019-08-08T11:31:32.783+0000"
        layers                         = []
        memory_size                    = 128
        publish                        = true
      ~ qualified_arn                  = "arn:aws:lambda:us-east-1:12345678:function:xx:1" -> (known after apply)
        reserved_concurrent_executions = -1
        role                           = "arn:aws:iam::12345678:role/xx"
        runtime                        = "python3.7"
        source_code_hash               = "xxxx"
        source_code_size               = 953
        timeout                        = 10
      ~ version                        = "1" -> (known after apply)

        tracing_config {
            mode = "PassThrough"
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. terraform apply

Important Factoids

A workaround is to ignore version and qualified_arn.

  lifecycle {
    ignore_changes = [
      filename,
      last_modified,
      qualified_arn,
      version,
    ]
  }
@ghost ghost added the service/lambda Issues and PRs that pertain to the lambda service. label Aug 15, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 15, 2019
@viewn
Copy link

viewn commented Jul 20, 2020

i have the same issue. how to solve it?

@danieladams456
Copy link
Contributor

In the latest TF

Terraform v0.14.0-beta2
+ provider registry.terraform.io/hashicorp/aws v3.13.0

I now get this error since it is a computed attribute.

Error: Cannot ignore argument not set in the configuration

  on ../../modules/lambda-function/lambda.tf line 56, in resource "aws_lambda_function" "lambda":
  56:       qualified_arn,

The ignore_changes argument is not set in the configuration.
The ignore_changes mechanism only applies to changes within the configuration,
and must be used with arguments set in the configuration and not computed by
the provider.

@Tiago-SD
Copy link

Tiago-SD commented Nov 18, 2020

I have the exact some issue but at least the workaround worked for me on the following versions:
Terraform v0.12.29

  • provider.aws v3.15.0

But I have some concerns if it will work for version 0.13.x since I'm planing to make the upgrade.

@fumantsu
Copy link

fumantsu commented Dec 16, 2020

I can also confirm this with provider.aws 3.21, terraform 0.13 with data.archive_file as source and using the outputsha256 as source in the layer.

Really annoying if you don't to changes since it is changing the version as well.

I have the exact some issue but at least the workaround worked for me on the following versions:
Terraform v0.12.29

  • provider.aws v3.15.0

But I have some concerns if it will work for version 0.13.x since I'm planing to make the upgrade.

Doesn't have to do anything with the terraform version. It is provider's bug. As you can see the previous comment from yours it is using 0.14 and me know I can confirm the same in 0.13

@chenjie
Copy link
Contributor

chenjie commented Jan 8, 2021

I can confirm that the same exact issue exists on 3.23.0

@maksym-iv
Copy link

Issue exists

Terraform v0.14.3
+ provider registry.terraform.io/hashicorp/aws v3.25.0

@nickjmv
Copy link

nickjmv commented Jan 25, 2021

+1

@reedflinch
Copy link

Unfortunately the workaround does not work if you use a Lambda alias pointing to your function version. Ignoring changes to version means the alias resource will not detect changes.

resource "aws_lambda_alias" "main" {
  name             = "LIVE"
  function_name    = aws_lambda_function.main.arn
  function_version = aws_lambda_function.main.version
  description      = var.tag
}

@kitos9112
Copy link

kitos9112 commented Feb 13, 2021

This is probably the root cause or may be intrinsically correlated to #17385

@deyvsh
Copy link

deyvsh commented Apr 28, 2021

Optimistic that this might be fixed by #17610

@bill-rich
Copy link
Contributor

Hi All,
I haven't been able to reproduce this issue with the provided configuration. Is anyone still experiencing this problem? If so, please post a copy of your configuration to help with reproducing the issue.

@eschulma
Copy link

eschulma commented Sep 8, 2021

I had this problem with 3.31. But updating to 3.57 fixed it.

@breathingdust breathingdust added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 17, 2021
@breathingdust
Copy link
Member

👋 It looks like this may have been fixed by either #17385 or #17610, I will close this issue for now, please comment to reopen if this continues to be an issue. Thanks!

@github-actions
Copy link

github-actions bot commented Jun 7, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
Development

No branches or pull requests