github.com/adrian-bl/terraform@v0.7.0-rc2.0.20160705220747-de0a34fc3517/website/source/docs/providers/consul/r/keys.html.markdown (about)

     1  ---
     2  layout: "consul"
     3  page_title: "Consul: consul_keys"
     4  sidebar_current: "docs-consul-resource-keys"
     5  description: |-
     6    Provides access to Key/Value data in Consul. This can be used to both read keys from Consul, but also to set the value of keys in Consul. This is a powerful way dynamically set values in templates, and to expose infrastructure details to clients.
     7  ---
     8  
     9  # consul\_keys
    10  
    11  Provides access to Key/Value data in Consul. This can be used
    12  to both read keys from Consul, but also to set the value of keys
    13  in Consul. This is a powerful way dynamically set values in templates,
    14  and to expose infrastructure details to clients.
    15  
    16  This resource manages individual keys, and thus it can create, update and
    17  delete the keys explicitly given. Howver, It is not able to detect and remove
    18  additional keys that have been added by non-Terraform means. To manage
    19  *all* keys sharing a common prefix, and thus have Terraform remove errant keys
    20  not present in the configuration, consider using the `consul_key_prefix`
    21  resource instead.
    22  
    23  ## Example Usage
    24  
    25  ```
    26  resource "consul_keys" "app" {
    27      datacenter = "nyc1"
    28      token = "abcd"
    29  
    30      # Read the launch AMI from Consul
    31      key {
    32          name = "ami"
    33          path = "service/app/launch_ami"
    34          default = "ami-1234"
    35      }
    36  
    37      # Set the CNAME of our load balancer as a key
    38      key {
    39          name = "elb_cname"
    40          path = "service/app/elb_address"
    41          value = "${aws_elb.app.dns_name}"
    42      }
    43  }
    44  
    45  # Start our instance with the dynamic ami value
    46  resource "aws_instance" "app" {
    47      ami = "${consul_keys.app.var.ami}"
    48      ...
    49  }
    50  ```
    51  
    52  ## Argument Reference
    53  
    54  The following arguments are supported:
    55  
    56  * `datacenter` - (Optional) The datacenter to use. This overrides the
    57    datacenter in the provider setup and the agent's default datacenter.
    58  
    59  * `token` - (Optional) The ACL token to use. This overrides the
    60    token that the agent provides by default.
    61  
    62  * `key` - (Required) Specifies a key in Consul to be read or written.
    63    Supported values documented below.
    64  
    65  The `key` block supports the following:
    66  
    67  * `name` - (Required) This is the name of the key. This value of the
    68    key is exposed as `var.<name>`. This is not the path of the key
    69    in Consul.
    70  
    71  * `path` - (Required) This is the path in Consul that should be read
    72    or written to.
    73  
    74  * `default` - (Optional) This is the default value to set for `var.<name>`
    75    if the key does not exist in Consul. Defaults to the empty string.
    76  
    77  * `value` - (Optional) If set, the key will be set to this value.
    78    This allows a key to be written to.
    79  
    80  * `delete` - (Optional) If true, then the key will be deleted when
    81    either its configuration block is removed from the configuration or
    82    the entire resource is destroyed. Otherwise, it will be left in Consul.
    83    Defaults to false.
    84  
    85  ## Attributes Reference
    86  
    87  The following attributes are exported:
    88  
    89  * `datacenter` - The datacenter the keys are being read/written to.
    90  * `var.<name>` - For each name given, the corresponding attribute
    91    has the value of the key.