github.com/maheshbr/terraform@v0.3.1-0.20141020033300-deec7194a3ea/website/source/intro/examples/consul.html.markdown (about)

     1  ---
     2  layout: "intro"
     3  page_title: "Consul Example"
     4  sidebar_current: "examples-consul"
     5  ---
     6  
     7  # Consul Example
     8  
     9  [**Example Contents**](https://github.com/hashicorp/terraform/tree/master/examples/consul)
    10  
    11  [Consul](http://www.consul.io) is a tool for service discovery, configuration
    12  and orchestration. The Key/Value store it provides is often used to store
    13  application configuration and information about the infrastructure necessary
    14  to process requests.
    15  
    16  Terraform provides a [Consul provider](/docs/providers/consul/index.html) which
    17  can be used to interface with Consul from inside a Terraform configuration.
    18  
    19  For our example, we use the [Consul demo cluster](http://demo.consul.io)
    20  to both read configuration and store information about a newly created EC2 instance.
    21  The size of the EC2 instance will be determined by the "tf\_test/size" key in Consul,
    22  and will default to "m1.small" if that key does not exist. Once the instance is created
    23  the "tf\_test/id" and "tf\_test/public\_dns" keys will be set with the computed
    24  values for the instance.
    25  
    26  Before we run the example, use the [Web UI](http://demo.consul.io/ui/#/nyc1/kv/)
    27  to set the "tf\_test/size" key to "t1.micro". Once that is done,
    28  copy the configuration into a configuration file ("consul.tf" works fine).
    29  Either provide the AWS credentials as a default value in the configuration
    30  or invoke `apply` with the appropriate variables set.
    31  
    32  Once the `apply` has completed, we can see the keys in Consul by
    33  visiting the [Web UI](http://demo.consul.io/ui/#/nyc1/kv/). We can see
    34  that the "tf\_test/id" and "tf\_test/public\_dns" values have been
    35  set.
    36  
    37  We can now teardown the infrastructure following the
    38  [instructions here](/intro/getting-started/destroy.html). Because
    39  we set the 'delete' property of two of the Consul keys, Terraform
    40  will cleanup those keys on destroy. We can verify this by using
    41  the Web UI.
    42  
    43  The point of this example is to show that Consul can be used with
    44  Terraform both to enable dynamic inputs, but to also store outputs.
    45  
    46  Inputs like AMI name, security groups, puppet roles, bootstrap scripts,
    47  etc can all be loaded from Consul. This allows the specifics of an
    48  infrastructure to be decoupled from its overall architecture. This enables
    49  details to be changed without updating the Terraform configuration.
    50  
    51  Outputs from Terraform can also be easily stored in Consul. One powerful
    52  features this enables is using Consul for inventory management. If an
    53  application relies on ELB for routing, Terraform can update the application's
    54  configuration directly by setting the ELB address into Consul. Any resource
    55  attribute can be stored in Consul, allowing an operator to capture anything
    56  useful.