github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/website/source/docs/providers/consul/r/key_prefix.html.markdown (about) 1 --- 2 layout: "consul" 3 page_title: "Consul: consul_key_prefix" 4 sidebar_current: "docs-consul-resource-key-prefix" 5 description: |- 6 Allows Terraform to manage a namespace of Consul keys that share a 7 common name prefix. 8 --- 9 10 # consul\_key\_prefix 11 12 Allows Terraform to manage a "namespace" of Consul keys that share a common 13 name prefix. 14 15 Like `consul_keys`, this resource can write values into the Consul key/value 16 store, but *unlike* `consul_keys` this resource can detect and remove extra 17 keys that have been added some other way, thus ensuring that rogue data 18 added outside of Terraform will be removed on the next run. 19 20 This resource is thus useful in the case where Terraform is exclusively 21 managing a set of related keys. 22 23 To avoid accidentally clobbering matching data that existed in Consul before 24 a `consul_key_prefix` resource was created, creation of a key prefix instance 25 will fail if any matching keys are already present in the key/value store. 26 If any conflicting data is present, you must first delete it manually. 27 28 ~> **Warning** After this resource is instantiated, Terraform takes control 29 over *all* keys with the given path prefix, and will remove any matching keys 30 that are not present in the configuration. It will also delete *all* keys under 31 the given prefix when a `consul_key_prefix` resource is destroyed, even if 32 those keys were created outside of Terraform. 33 34 ## Example Usage 35 36 ``` 37 resource "consul_key_prefix" "myapp_config" { 38 datacenter = "nyc1" 39 token = "abcd" 40 41 # Prefix to add to prepend to all of the subkey names below. 42 path_prefix = "myapp/config/" 43 44 subkeys = { 45 "elb_cname" = "${aws_elb.app.dns_name}" 46 "s3_bucket_name" = "${aws_s3_bucket.app.bucket}" 47 "database/hostname" = "${aws_db_instance.app.address}" 48 "database/port" = "${aws_db_instance.app.port}" 49 "database/username" = "${aws_db_instance.app.username}" 50 "database/password" = "${aws_db_instance.app.password}" 51 "database/name" = "${aws_db_instance.app.name}" 52 } 53 } 54 ``` 55 56 ## Argument Reference 57 58 The following arguments are supported: 59 60 * `datacenter` - (Optional) The datacenter to use. This overrides the 61 datacenter in the provider setup and the agent's default datacenter. 62 63 * `token` - (Optional) The ACL token to use. This overrides the 64 token that the agent provides by default. 65 66 * `path_prefix` - (Required) Specifies the common prefix shared by all keys 67 that will be managed by this resource instance. In most cases this will 68 end with a slash, to manage a "folder" of keys. 69 70 * `subkeys` - (Required) A mapping from subkey name (which will be appended 71 to the give `path_prefix`) to the value that should be stored at that key. 72 Use slashes as shown in the above example to create "sub-folders" under 73 the given path prefix. 74 75 ## Attributes Reference 76 77 The following attributes are exported: 78 79 * `datacenter` - The datacenter the keys are being read/written to.