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

enabled = 'false' causes "Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.x'' #14

Closed
lestephane opened this issue Dec 7, 2017 · 3 comments

Comments

@lestephane
Copy link

When i use enabled = "false":

module "mylabel" {
  enabled = "false"
  source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=0.3.1"
  namespace = "${var.namespace}"
  stage = "${var.stage}"
  name = "${var.cname_label}"
  tags = "${module.infrastructure.default_tags}"
}

I get errors because the module outputs refer to a resource that is not present when enabled is false:

Error: Error running plan: 7 error(s) occurred:

* module.mylabel.output.id: Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.id'
* module.mylabel.output.attributes: Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.attributes'
* module.mylabel.output.tags: Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.id'
* module.mylabel.output.stage: Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.stage'
* module.mylabel.output.name: Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.name'
* module.mylabel.output.namespace: Resource 'null_resource.default' not found for variable 'null_resource.default.triggers.namespace'

terragrunt -version

terragrunt version v0.13.23

terraform -version

Terraform v0.11.1

@aknysh
Copy link
Member

aknysh commented Dec 7, 2017

@lestephane thank you for testing the module and reporting the issue.
It's a known issue in the new versions of Terraform.

They made it a fatal error in 0.11.0 to reference a resource with count=0 even if that recource is not used.
hashicorp/terraform#16726

But then switched it to warning in 0.11.1
https://github.com/hashicorp/terraform/blob/v0.11.1/CHANGELOG.md

Since the new feature was already rolled out, and since development for 0.12 depends on the foundational changes that enabled it, we decided to compromise with an opt-out mechanism in 0.11.1, so those with configurations containing problematic output expressions have a means to use 0.11.1 without first fixing all modules. We understand that this is not the most ideal migration path -- if we could do this over again we would've introduced the warning in one of the 0.10 point releases -- but we hope that this compromise is acceptable so that we can continue to make progress towards 0.12.

To enable that behavior, you need to set the variable TF_WARN_OUTPUT_ERRORS=1

They mentioned they will make it an error again in 0.12, so it's a temporarily fix anyway.

But if they fix ternaries (to short-circuit and not evaluate left and right part at the same time), we can work around the issue very easily
hashicorp/hil#50

Since you mentioned you are using Terraform 0.11.1, could you please try to set TF_WARN_OUTPUT_ERRORS=1 and test again?

Thank you

@lestephane
Copy link
Author

lestephane commented Dec 9, 2017 via email

@aknysh
Copy link
Member

aknysh commented Dec 12, 2017

@lestephane let us know if you have any other questions or concerns, we'll try to address them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants