Files
opentf/website/source/docs/providers/consul/r/keys.html.markdown
Martin Atkins 19d0b42911 provider/consul: consul_keys data source (#7678)
Previously the consul_keys resource did double-duty as both a reader and
writer of values from the Consul key/value store, but that made its
interface rather confusing and complex, as well as having all of the other
general problems associated with read-only resources.

Here we split the functionality such that reading is done with the
consul_keys data source while writing is done with the consul_keys
resource.

The old read behavior of the resource is still supported, but it's no
longer documented (except as a deprecation note) and will generate
deprecation warnings when used.

In future it should be possible to simplify the consul_keys resource by
removing all of the read support, but that is deferred for now to give
users a chance to gracefully migrate to the new data source.
2016-07-26 18:23:38 +01:00

2.3 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
consul Consul: consul_keys docs-consul-resource-keys Writes values into the Consul key/value store.

consul_keys

consul_keys writes sets of individual values into Consul. This is a powerful way to expose infrastructure details to clients.

This resource manages individual keys, and thus it can create, update and delete the keys explicitly given. Howver, It is not able to detect and remove additional keys that have been added by non-Terraform means. To manage all keys sharing a common prefix, and thus have Terraform remove errant keys not present in the configuration, consider using the consul_key_prefix resource instead.

Example Usage

resource "consul_keys" "app" {
    datacenter = "nyc1"
    token = "abcd"

    # Set the CNAME of our load balancer as a key
    key {
        name = "elb_cname"
        path = "service/app/elb_address"
        value = "${aws_elb.app.dns_name}"
    }
}

Argument Reference

The following arguments are supported:

  • datacenter - (Optional) The datacenter to use. This overrides the datacenter in the provider setup and the agent's default datacenter.

  • token - (Optional) The ACL token to use. This overrides the token that the agent provides by default.

  • key - (Required) Specifies a key in Consul to be written. Supported values documented below.

The key block supports the following:

  • path - (Required) This is the path in Consul that should be written to.

  • value - (Required) The value to write to the given path.

  • delete - (Optional) If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.

Deprecated key arguments

Prior to Terraform 0.7 this resource was used both to read and write the Consul key/value store. The read functionality has moved to the consul_keys data source, whose documentation can be found via the navigation.

The pre-0.7 interface for reading is still supported for backward compatibilty, but will be removed in a future version of Terraform.

Attributes Reference

The following attributes are exported:

  • datacenter - The datacenter the keys are being written to.