2014-07-27 02:42:25 +02:00
|
|
|
---
|
|
|
|
layout: "consul"
|
|
|
|
page_title: "Consul: consul_keys"
|
|
|
|
sidebar_current: "docs-consul-resource-keys"
|
2014-10-22 05:21:56 +02:00
|
|
|
description: |-
|
2016-07-26 19:23:38 +02:00
|
|
|
Writes values into the Consul key/value store.
|
2014-07-27 02:42:25 +02:00
|
|
|
---
|
|
|
|
|
2017-04-10 18:19:36 +02:00
|
|
|
# consul_keys
|
2014-07-27 02:42:25 +02:00
|
|
|
|
2016-11-08 15:43:00 +01:00
|
|
|
The `consul_keys` resource writes sets of individual values into Consul.
|
2016-07-26 19:23:38 +02:00
|
|
|
This is a powerful way to expose infrastructure details to clients.
|
2014-07-27 02:42:25 +02:00
|
|
|
|
2016-11-08 15:43:00 +01:00
|
|
|
This resource manages individual keys, and thus it can create, update
|
|
|
|
and delete the keys explicitly given. However, 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.
|
2016-04-03 05:37:11 +02:00
|
|
|
|
2014-07-27 02:42:25 +02:00
|
|
|
## Example Usage
|
|
|
|
|
2017-04-10 18:19:36 +02:00
|
|
|
```hcl
|
2014-07-27 02:42:25 +02:00
|
|
|
resource "consul_keys" "app" {
|
2017-02-18 23:48:50 +01:00
|
|
|
datacenter = "nyc1"
|
|
|
|
token = "abcd"
|
|
|
|
|
|
|
|
# Set the CNAME of our load balancer as a key
|
|
|
|
key {
|
|
|
|
path = "service/app/elb_address"
|
|
|
|
value = "${aws_elb.app.dns_name}"
|
|
|
|
}
|
2014-07-27 02:42:25 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## 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.
|
|
|
|
|
2014-10-13 20:42:40 +02:00
|
|
|
* `token` - (Optional) The ACL token to use. This overrides the
|
|
|
|
token that the agent provides by default.
|
|
|
|
|
2016-07-26 19:23:38 +02:00
|
|
|
* `key` - (Required) Specifies a key in Consul to be written.
|
2014-07-27 02:42:25 +02:00
|
|
|
Supported values documented below.
|
|
|
|
|
|
|
|
The `key` block supports the following:
|
|
|
|
|
2016-07-26 19:23:38 +02:00
|
|
|
* `path` - (Required) This is the path in Consul that should be written to.
|
2014-07-27 02:42:25 +02:00
|
|
|
|
2016-07-26 19:23:38 +02:00
|
|
|
* `value` - (Required) The value to write to the given path.
|
2014-07-27 02:42:25 +02:00
|
|
|
|
|
|
|
* `delete` - (Optional) If true, then the key will be deleted when
|
2016-03-10 16:52:43 +01:00
|
|
|
either its configuration block is removed from the configuration or
|
|
|
|
the entire resource is destroyed. Otherwise, it will be left in Consul.
|
2014-07-27 02:42:25 +02:00
|
|
|
Defaults to false.
|
|
|
|
|
2016-07-26 19:23:38 +02:00
|
|
|
### Deprecated `key` arguments
|
|
|
|
|
2016-11-08 15:43:00 +01:00
|
|
|
Prior to Terraform 0.7, this resource was used both to read *and* write the
|
2016-07-26 19:23:38 +02:00
|
|
|
Consul key/value store. The read functionality has moved to the `consul_keys`
|
|
|
|
*data source*, whose documentation can be found via the navigation.
|
|
|
|
|
2016-11-08 15:43:00 +01:00
|
|
|
The pre-0.7 interface for reading keys is still supported for backward compatibility,
|
2016-07-26 19:23:38 +02:00
|
|
|
but will be removed in a future version of Terraform.
|
|
|
|
|
2014-07-27 02:42:25 +02:00
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
2016-07-26 19:23:38 +02:00
|
|
|
* `datacenter` - The datacenter the keys are being written to.
|