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

Terraform fails to interpolate a value with splat syntax #16907

Closed
yehorov opened this issue Dec 13, 2017 · 1 comment
Closed

Terraform fails to interpolate a value with splat syntax #16907

yehorov opened this issue Dec 13, 2017 · 1 comment

Comments

@yehorov
Copy link

yehorov commented Dec 13, 2017

Terraform Version

Terraform v0.11.1
+ provider.null v1.0.0

Terraform Configuration Files

main.tf

variable "role_level" { default = "vpc" }

resource "null_resource" "role" {
  count = "${var.role_level == "env" ? 1 : 0 }"
}

output "name" {
  value = "${join("", null_resource.role.*.id)}"
}

terraform.tfvars

role_level = "env"

Expected Behavior

I expect that after changing of a variable's value in terraform.tfvars all resources will be destroyed and the new value will be interpolated immediately.

Actual Behavior

If existed resources are deleted, terraform fails to interpolate value with splat syntax. But on the next invocations it run without any errors.

$ terraform apply -auto-approve
null_resource.role: Creating...
null_resource.role: Creation complete after 0s (ID: 4916734105907799574)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

name = 4916734105907799574
$ terraform apply -auto-approve
null_resource.role: Refreshing state... (ID: 4916734105907799574)
null_resource.role: Destroying... (ID: 4916734105907799574)
null_resource.role: Destruction complete after 0s

Error: Error applying plan:

1 error(s) occurred:

* output.name: Resource 'null_resource.role' does not have attribute 'id' for variable 'null_resource.role.*.id'

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
$ terraform apply -auto-approve

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

name =

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. Delete the terraform.tfvars file
  4. terraform apply
  5. terraform apply
@yehorov yehorov changed the title Terraform fails to interpolate an output value with splat syntax Terraform fails to interpolate a value with splat syntax Dec 13, 2017
@jbardin jbardin closed this as completed Jan 31, 2018
@ghost
Copy link

ghost commented Apr 5, 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 Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants