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

Tried v3.0.0 - unexpected terraform replacement #84

Closed
1vanzamarripa opened this issue Jun 8, 2020 · 7 comments · Fixed by terraform-aws-modules/terraform-aws-lambda#20

Comments

@1vanzamarripa
Copy link

1vanzamarripa commented Jun 8, 2020

Tried using the new version , with this setup:

module "notify_slack_module" {
  source = "github.com/terraform-aws-modules/terraform-aws-notify-slack.git?ref=v3.0.0"
  sns_topic_name    = var.some_topic
  slack_webhook_url = var.slack_webhook_url
  slack_channel     = var.slack_channel
  slack_username    = var.slack_username
  lambda_function_name = "function_name"
}

First time terraform apply works perfectly fine, however on a re-run, this is the outcome:

  # module.notify_slack_module.module.lambda.null_resource.archive[0] must be replaced
-/+ resource "null_resource" "archive" {
      ~ id       = "5201291547049430426" -> (known after apply)
      ~ triggers = { # forces replacement
            "filename"  = "builds/d75764cc658ab477397eb09fabff2b67473cfe1246224a1e50360327a2c8e7a3.zip"
          ~ "timestamp" = "1591642297725210000" -> "1591643174300057800"
        }
    }

The resource shouldn't be expected to be replaced every time you run the terraform apply command just because there's a different timestamp.

@1vanzamarripa
Copy link
Author

Also tried this configuration:

  source = "terraform-aws-modules/notify-slack/aws"
  version = "3.0.0"

instead of
source = "github.com/terraform-aws-modules/terraform-aws-notify-slack.git?ref=v3.0.0"

@antonbabenko
Copy link
Member

I am trying to reproduce it now and I can't.

If resource null_resource.archive[0] is the only one which it says "must be replaced" it means that the deployment package should be recreated locally because it has wrong timestamp. This should not happen normally.

Which version of OS, Terraform, Python do you use?

@1vanzamarripa
Copy link
Author

1vanzamarripa commented Jun 8, 2020

Here you go:

python --version
Python 3.8.0
 terraform --version
Terraform v0.12.20

tested on macOS

Maybe my backend state is somehow messed up then? Trying to understand what I'm doing wrong.

@1vanzamarripa
Copy link
Author

This fails in my case because I'm running it on a CI/CD pipeline that clones the git repository every-time it runs and the module thinks that the zip file it generates in builds/ is a new one because it is always re-built on every pipeline run. I tried committing the builds directory to git source code but since the pipeline clones the repo everytime, the module always also thinks is a new zip file because the timestamp changes when the source code is cloned.

@antonbabenko
Copy link
Member

Here is the fix which allows users to run this module without having archive locally.

Please use v3.1.0 and let us know if the problem persists.

So, when you update the version of this module, you need to tell your CI/CD pipeline to set environment variable before running terraform:

TF_RECREATE_MISSING_LAMBDA_PACKAGE=false terraform apply

@1vanzamarripa
Copy link
Author

Here is the fix which allows users to run this module without having archive locally.

Please use v3.1.0 and let us know if the problem persists.

So, when you update the version of this module, you need to tell your CI/CD pipeline to set environment variable before running terraform:

TF_RECREATE_MISSING_LAMBDA_PACKAGE=false terraform apply

Thanks!

@github-actions
Copy link

github-actions bot commented Nov 8, 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 Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants