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

Module Outputs #22502

Closed
eddytrex opened this issue Aug 17, 2019 · 5 comments
Closed

Module Outputs #22502

eddytrex opened this issue Aug 17, 2019 · 5 comments
Labels
bug config v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@eddytrex
Copy link

Terraform Version

terraform version
Terraform v0.12.5
+ provider.null v2.1.2

Terraform Configuration Files

module 1:

provider "null" {}

resource "null_resource" "name" {
  count    = 1
  triggers = { description = var.description }

  provisioner "local-exec" { command = "echo name " }
}

variable "description" {
  type = string
}

output "ids" {
  value = [for s in null_resource.name : s.id]
}

moduel2:

provider "null" {}

resource "null_resource" "hi" {
  count    = length(var.resources)
  triggers = { t = "${var.resources[count.index]}" }

  provisioner "local-exec" {
    command = "echo greattings ${var.resources[count.index]}"
  }
}

variable "resources" {
  type = list(string)
}

module3:

module "r" {
  source      = "../module1"
  description = var.description
}

module "hi" {
  source    = "../module2"
  resources = module.r.ids
}

variable "description" {
  type = string
}

Debug Output

https://gist.github.com/eddytrex/43c5bd47b273607705ae0f9bf1931503

Crash Output

Error: Cycle: module.r.output.ids, module.hi.var.resources, module.hi.null_resource.hi (prepare state), module.hi.null_resource.hi[0] (destroy), module.r.null_resource.name[0] (destroy), module.r.null_resource.name[0]

Expected Behavior

Renew the null_resource in the module 1
pass the values to the module 2
then Renew null_resource in module 2

Actual Behavior

Error Cycle

Steps to Reproduce

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

  1. terraform init
  2. terraform apply -var description=first module3
  3. terraform apply -var description=second module3

Additional Context

tested with terraform 0.12.6 with the same behavior

References

@eddytrex
Copy link
Author

Using the lifecycle crate before destroy on the null_resource name, it work fine. But maybe is not positive to use create before destroy in other resources.

@teamterraform
Copy link
Contributor

Thanks for the added info @eddytrex, that might be very useful in tracking this down.
You are correct that you should not need to use create_before_destroy to fix a cycle like this, it just coincidentally happens to break the cycle when destroying the instances.

@eddytrex
Copy link
Author

eddytrex commented Aug 23, 2019

I'm testing in 0.12.7, interesting if there is not count/for_each in the null_resource.hi in the module 2 that depends on the variable resources it works with out cycle error.

@hashibot hashibot added the v0.12 Issues (primarily bugs) reported against v0.12 releases label Aug 27, 2019
@jbardin
Copy link
Member

jbardin commented Dec 4, 2019

Closed by #22976

@jbardin jbardin closed this as completed Dec 4, 2019
@ghost
Copy link

ghost commented Mar 28, 2020

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.

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug config v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

4 participants