terraform-provider-random icon indicating copy to clipboard operation
terraform-provider-random copied to clipboard

random_uuid with keepers doesn't respect depends_on

Open ocervell opened this issue 6 years ago • 0 comments

Hi there,

I'm encountering a bug when trying to generate a file and then use keepers to generate a unique uuid updated based on the filemd5 hashes of the files within a directory.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v0.12.13
+ provider.archive v1.3.0
+ provider.google v2.19.0
+ provider.local v1.4.0
+ provider.null v2.1.2
+ provider.random v2.2.1

Affected Resource(s)

Please list the resources as a list, for example:

  • random_uuid If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "local_file" "generated-config" {
  content  = jsonencode({a=1, b=2})
  filename = "${path.module}/code/generated.json"
}

resource "random_uuid" "code_hash" {
  keepers = {
    for filename in fileset("${path.module}/code", "**/*") :
    filename => filemd5("${path.module}/code}/${filename}")
  }
  depends_on = [
    local_file.generated-config
  ]
}

Debug Output

Error: Provider produced inconsistent final plan

When expanding the plan for
module.slo-pipeline-cf-errors.random_uuid.code_hash to include new values
learned so far during apply, provider "random" produced an invalid new value
for .keepers["slo_config.json"]: was
cty.StringVal("d41d8cd98f00b204e9800998ecf8427e"), but now
cty.StringVal("4fd65632594f3361802ed49a5f5f6bf0").


This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened? The content of keepers including the fileset should have been evaluated after the file is dropped in the directory.

Actual Behavior

What actually happened? The provider produced an inconsistent plan. It seems that fileset was evaluated before the local_file resource was run, even if depends_on is specified.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

ocervell avatar Dec 07 '19 21:12 ocervell