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

"dummy interpolation" for data and resource dependencies don't work #33

Closed
Nmishin opened this issue Nov 3, 2017 · 2 comments
Closed

Comments

@Nmishin
Copy link

Nmishin commented Nov 3, 2017

Hi there,

I have an issue with data and resource dependencies.
"dummy interpolation" don't work ...

Terraform Version

Terraform v0.9.4

Affected Resource(s)

data "vault_generic_secret"
resource "vault_generic_secret"

Terraform Configuration Files

( please note: this is example .tf file - I don't want to put here role-id generation)

resource "vault_generic_secret" "roles" {
    count       = "${length(var.roles)}"

    path        = "auth/roles/role/${var.roles[count.index]}"
    data_json   = <<_EOT
{
  "foo":   "bar",
  "pizza": "cheese"
}
    _EOT
}

data "vault_generic_secret" "roles_id" {
    count       = "${length(var.roles)}"

    path = "${vault_generic_secret.roles.*.path[count.index]}/role-id"
}

resource "consul_keys" "roles_id" {
    count       = "${length(var.roles)}"

    key {
        path    = "vault-roles/${var.roles[count.index]}/role-id"
        value   = "${replace(data.vault_generic_secret.roles_id.*.data_json[count.index], "/.*:\"(.*)\".*/", "$1")}"
        delete  = "true"
    }   
}

variable "roles" {
    type        = "list"
    default     = [ 
        "default",
        "default1"
    ]
}

Expected Behavior

When I add a new role (yes I add new roles at the end of the list) to the var.roles list I do terraform apply new roles and it role_id added to the Vault and copied to the Consul.

Actual Behavior

I see the error:

Error refreshing state: 1 error(s) occurred:
* module.roles.data.vault_generic_secret.role_id: 1 error(s) occurred:
* module.roles.data.vault_generic_secret.roles_id[51]: index 51 out of range for list vault_generic_secret.roles_id.*.path (max 51) in:
${vault_generic_secret.roles.*.path[count.index]}/role-id

Steps to Reproduce

  1. terraform apply

References

I think this can be related to depends_on for data_source

@apparentlymart
Copy link
Contributor

Hi @Nmishin! Sorry for this odd behavior, and for the long delay in replying.

I think this may be the same problem as hashicorp/terraform#13828, which was fixed in Terraform 0.9.6. If possible, it would be useful to see if this problem still occurs for you on a more recent version of Terraform.

@Nmishin
Copy link
Author

Nmishin commented Jan 18, 2018

Hi @apparentlymart!
I checked this in Terraform 0.9.8 and seems to the problem was fixed.

@Nmishin Nmishin closed this as completed Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants