github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/website/source/docs/providers/consul/d/keys.html.markdown (about) 1 --- 2 layout: "consul" 3 page_title: "Consul: consul_keys" 4 sidebar_current: "docs-consul-data-source-keys" 5 description: |- 6 Reads values from the Consul key/value store. 7 --- 8 9 # consul\_keys 10 11 `consul_keys` reads values from the Consul key/value store. 12 This is a powerful way dynamically set values in templates. 13 14 ## Example Usage 15 16 ``` 17 data "consul_keys" "app" { 18 datacenter = "nyc1" 19 token = "abcd" 20 21 # Read the launch AMI from Consul 22 key { 23 name = "ami" 24 path = "service/app/launch_ami" 25 default = "ami-1234" 26 } 27 } 28 29 # Start our instance with the dynamic ami value 30 resource "aws_instance" "app" { 31 ami = "${data.consul_keys.app.var.ami}" 32 ... 33 } 34 ``` 35 36 ## Argument Reference 37 38 The following arguments are supported: 39 40 * `datacenter` - (Optional) The datacenter to use. This overrides the 41 datacenter in the provider setup and the agent's default datacenter. 42 43 * `token` - (Optional) The ACL token to use. This overrides the 44 token that the agent provides by default. 45 46 * `key` - (Required) Specifies a key in Consul to be read or written. 47 Supported values documented below. 48 49 The `key` block supports the following: 50 51 * `name` - (Required) This is the name of the key. This value of the 52 key is exposed as `var.<name>`. This is not the path of the key 53 in Consul. 54 55 * `path` - (Required) This is the path in Consul that should be read 56 or written to. 57 58 * `default` - (Optional) This is the default value to set for `var.<name>` 59 if the key does not exist in Consul. Defaults to the empty string. 60 61 ## Attributes Reference 62 63 The following attributes are exported: 64 65 * `datacenter` - The datacenter the keys are being read from to. 66 * `var.<name>` - For each name given, the corresponding attribute 67 has the value of the key.