github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/website/source/intro/examples/index.html.markdown (about)

     1  ---
     2  layout: "intro"
     3  page_title: "Example Configurations"
     4  sidebar_current: "examples"
     5  description: |-
     6    These examples are designed to help you understand some of the ways Terraform can be used.
     7  ---
     8  
     9  # Example Configurations
    10  
    11  These examples are designed to help you understand some
    12  of the ways Terraform can be used.
    13  
    14  All examples are ready to run as-is. Terraform will
    15  ask for input of things such as variables and API keys. If you want to
    16  continue using the example, you should save those parameters in a
    17  "terraform.tfvars" file or in a `provider` config bock.
    18  
    19  ~> **Warning!** The examples use real providers that launch _real_ resources.
    20  That means they can cost money to experiment with. To avoid unexpected charges,
    21  be sure to understand the price of resources before launching them, and verify
    22  any unneeded resources are cleaned up afterwards.
    23  
    24  Experimenting in this way can help you learn how the Terraform lifecycle
    25  works, as well as how to repeatedly create and destroy infrastructure.
    26  
    27  If you're completely new to Terraform, we recommend reading the
    28  [getting started guide](/intro/getting-started/install.html) before diving into
    29  the examples. However, due to the intuitive configuration Terraform
    30  uses it isn't required.
    31  
    32  ## Examples
    33  
    34  All of the examples are in the
    35  ["examples" directory within the Terraform source code](https://github.com/hashicorp/terraform/tree/master/examples). Each example (as well as the examples
    36  directory) has a README explaining the goal of the example.
    37  
    38  To use these examples, Terraform must first be installed on your machine.
    39  You can install Terraform from the [downloads page](/downloads.html).
    40  Once installed, you can use two steps to view and run the examples.
    41  
    42  To clone any examples, run `terraform init` with the URL to the example:
    43  
    44  ```
    45  $ terraform init github.com/hashicorp/terraform/examples/aws-two-tier
    46  ...
    47  ```
    48  
    49  This will put the example files within your working directory. You can then
    50  use your own editor to read and browse the configurations. This command will
    51  not _run_ any code.
    52  
    53  ~> If you want to browse the files before downloading them, you can [view
    54  them on GitHub](https://github.com/hashicorp/terraform/tree/master/examples/aws-two-tier).
    55  
    56  If you want to run the example, just run `terraform apply`:
    57  
    58  ```
    59  $ terraform apply
    60  ...
    61  ```
    62  
    63  Terraform will interactively ask for variable input and potentially
    64  provider configuration, and will start executing.
    65  
    66  When you're done with the example, run `terraform destroy` to clean up.