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

Data source with computed value does not have attribute outputs #18956

Closed
hbuckle opened this issue Sep 27, 2018 · 2 comments
Closed

Data source with computed value does not have attribute outputs #18956

hbuckle opened this issue Sep 27, 2018 · 2 comments

Comments

@hbuckle
Copy link

hbuckle commented Sep 27, 2018

I suspect this is related to the already reported data source lifecycle issues but I couldn't see this use case exactly

Terraform Version

terraform -v
Terraform v0.11.8
+ provider.null v1.0.0
+ provider.random v2.0.0

Terraform Configuration Files

resource "random_string" "test" {
  length  = 6
  special = false
  upper   = false
}

data "null_data_source" "test" {
  count = 4

  inputs = {
    test = "${random_string.test.result}-${count.index}"
  }
}

resource "null_resource" "test" {
  count = 4

  triggers = {
    test = "${data.null_data_source.test.*.outputs.test[count.index]}"
  }
}

Output

terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
Error: Error running plan: 1 error(s) occurred:

* null_resource.test: 4 error(s) occurred:

* null_resource.test[2]: Resource 'data.null_data_source.test' does not have attribute 'outputs.test' for variable 'data.null_data_source.test.*.outputs.test'
* null_resource.test[3]: Resource 'data.null_data_source.test' does not have attribute 'outputs.test' for variable 'data.null_data_source.test.*.outputs.test'
* null_resource.test[0]: Resource 'data.null_data_source.test' does not have attribute 'outputs.test' for variable 'data.null_data_source.test.*.outputs.test'
* null_resource.test[1]: Resource 'data.null_data_source.test' does not have attribute 'outputs.test' for variable 'data.null_data_source.test.*.outputs.test'

If I replace ${random_string.test.result} in the data source input with a hardcoded string then the plan succeeds:

data "null_data_source" "test" {
  count = 4

  inputs = {
    test = "test-${count.index}"
  }
}

resource "null_resource" "test" {
  count = 4

  triggers = {
    test = "${data.null_data_source.test.*.outputs.test[count.index]}"
  }
}
terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.null_data_source.test[0]: Refreshing state...
data.null_data_source.test[1]: Refreshing state...
data.null_data_source.test[2]: Refreshing state...
data.null_data_source.test[3]: Refreshing state...

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  + null_resource.test[0]
      id:            <computed>
      triggers.%:    "1"
      triggers.test: "test-0"

  + null_resource.test[1]
      id:            <computed>
      triggers.%:    "1"
      triggers.test: "test-1"

  + null_resource.test[2]
      id:            <computed>
      triggers.%:    "1"
      triggers.test: "test-2"

  + null_resource.test[3]
      id:            <computed>
      triggers.%:    "1"
      triggers.test: "test-3"
@mildwonkey
Copy link
Contributor

Hi @hbuckle,
Sorry you've come across this unexpected behavior. There are other tickets covering this, such as #17034, so I am going to close this one - please go give a 👍 on #17034!

@ghost
Copy link

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

No branches or pull requests

2 participants