-
Notifications
You must be signed in to change notification settings - Fork 63
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
Terraform always shows archive_file in plan #11
Comments
Hi @maroux! Sorry I didn't notice this issue before. What you are seeing here is actually a Terraform Core limitation, where The usual workaround for this is to use implicit dependencies rather than explicit dependencies. This works because the explicit dependency gives Terraform's planning engine more information: it can tell what aspect of the other resource is significant and thus determine when it is safe to produce the archive early, during the plan phase. Unfortunately this is hard to do directly with the resource "null_resource" "lambda_exporter" {
# (some local-exec provisioner blocks, presumably...)
triggers {
index = "${base64sha256(file("${path.module}/lambda-files/index.js"))}"
}
}
data "null_data_source" "wait_for_lambda_exporter" {
inputs = {
# This ensures that this data resource will not be evaluated until
# after the null_resource has been created.
lambda_exporter_id = "${null_resource.lambda_exporter.id}"
# This value gives us something to implicitly depend on
# in the archive_file below.
source_dir = "${path.module}/lambda-files/"
}
}
data "archive_file" "lambda_exporter" {
output_path = "${path.module}/lambda-files.zip"
source_dir = "${data.null_data_source.wait_for_lambda_exporter.outputs["source_dir"]}"
type = "zip"
} Introducing this extra data source allows us to use an implicit dependency rather than an explicit dependency in both cases: This extra complexity should be unnecessary after we complete the work described in hashicorp/terraform#17034. Please note that we do not generally recommend using Terraform to construct deployment artifacts, because it is not an application build tool; the |
Since this is a Terraform Core issue and we already have hashicorp/terraform#17034 open for it, I'm going to close this issue just to consolidate the discussion over there. Thanks for reporting this! |
Nice works for me |
@ChineduUzoka really? Just tried the pattern @apparentlymart suggested and it failed. I've reverted back to a |
@joestump Take a look at this file here - https://github.com/ChineduUzoka/tf-module-lambda-deployment/blob/master/aws/modules/lambda_deployment/main.tf it works flawlessly |
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. |
Hi there,
Terraform Version
Terraform v0.11.3
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
Debug Output
Apply once, and then re-plan:
Expected Behavior
Terraform shouldn't show any changes on
terraform plan
since the hash of file has not changed.Actual Behavior
Terraform shows a change with
read (data resources)
fordata.archive_file.lambda_exporter
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
terraform plan
The text was updated successfully, but these errors were encountered: