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

consul_key_prefix - variables in Consul KV add/replaced with every apply #15609

Closed
VAdamec opened this issue Jul 21, 2017 · 4 comments
Closed

Comments

@VAdamec
Copy link

VAdamec commented Jul 21, 2017

Terraform Version

Terraform v0.9.11

Terraform Configuration Files

resource "consul_key_prefix" "bastion-host" {
  path_prefix                = "demo/env/"
  subkeys                    = {
    "BASTION"                = "${baremetal_core_instance.proxy.0.public_ip}"
  }
}

resource "consul_key_prefix" "proxy-host" {
  path_prefix                = "demo/env/"
  subkeys                    = {
    "PROXY"                  = "${format("http://${baremetal_core_instance.proxy.0.private_ip}:3128/")}"
  }
}

Debug Output

https://gist.github.com/VAdamec/e3e3c2fe4a597707ac03c60e4fcebebb

Expected Behavior

add values to Consul KV and keep them till any change occurse

Actual Behavior

add and remove value with every run (first run add them, next remove them, next add them, ...)

Steps to Reproduce

Just run apply, no changes in code or vars

  1. terraform apply

Important Factoids

Using BMCS provider https://github.com/oracle/terraform-provider-baremetal

@VAdamec
Copy link
Author

VAdamec commented Jul 21, 2017

So I'm writing to the same path KV via two different resources. It is correct/expected behaviour ?

@apparentlymart
Copy link
Member

Hi @VAdamec,

(Please note that development of this provider has moved to a separate repo now, so our issue management bot will likely shuffle this issue over there soon.)

What you're seeing here is indeed the expected behavior. consul_key_prefix is distinguished from consul_keys in that the former specifies that Terraform manages all keys under a particular prefix, including the removal of keys specified in config, while the latter has Terraform manage only very specific keys in isolation.

In your case, it'd be necessary either to combine those two resources into a single resource, or (if that's not possible/suitable) use the consul_keys resource instead, to separately populate those keys individually.

@hashibot
Copy link
Contributor

This issue has been automatically migrated to hashicorp/terraform-provider-consul#17 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to this issue and let us know.

@ghost
Copy link

ghost commented Apr 8, 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 8, 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

3 participants