2014-07-27 21:58:49 +02:00
---
layout: "intro"
page_title: "Example Configurations"
sidebar_current: "examples"
2014-10-22 05:21:56 +02:00
description: |-
These examples are designed to help you understand some of the ways Terraform can be used.
2014-07-27 21:58:49 +02:00
---
# Example Configurations
These examples are designed to help you understand some
of the ways Terraform can be used.
2014-10-14 03:07:54 +02:00
All examples are ready to run as-is. Terraform will
2014-10-13 21:14:56 +02:00
ask for input of things such as variables and API keys. If you want to
2015-01-03 19:31:53 +01:00
continue using the example, you should save those parameters in a
2016-03-10 02:10:16 +01:00
"terraform.tfvars" file or in a `provider` config block.
2014-07-27 21:58:49 +02:00
2014-10-22 16:01:17 +02:00
~> **Warning!** The examples use real providers that launch _real_ resources.
That means they can cost money to experiment with. To avoid unexpected charges,
be sure to understand the price of resources before launching them, and verify
any unneeded resources are cleaned up afterwards.
2014-07-27 21:58:49 +02:00
Experimenting in this way can help you learn how the Terraform lifecycle
works, as well as how to repeatedly create and destroy infrastructure.
If you're completely new to Terraform, we recommend reading the
2014-07-29 00:27:31 +02:00
[getting started guide ](/intro/getting-started/install.html ) before diving into
2014-07-27 21:58:49 +02:00
the examples. However, due to the intuitive configuration Terraform
uses it isn't required.
2014-10-14 03:07:54 +02:00
## Examples
All of the examples are in the
["examples" directory within the Terraform source code ](https://github.com/hashicorp/terraform/tree/master/examples ). Each example (as well as the examples
directory) has a README explaining the goal of the example.
2014-07-27 21:58:49 +02:00
To use these examples, Terraform must first be installed on your machine.
You can install Terraform from the [downloads page ](/downloads.html ).
2014-10-14 03:07:54 +02:00
Once installed, you can use two steps to view and run the examples.
2017-06-03 01:54:30 +02:00
To try these examples, first clone them with git as usual:
2014-10-14 03:07:54 +02:00
```
2017-06-03 01:54:30 +02:00
git clone https://github.com/hashicorp/terraform/examples/aws-two-tier
cd aws-two-tier
2014-10-14 03:07:54 +02:00
```
2017-06-03 01:54:30 +02:00
You can then use your own editor to read and browse the configurations.
To try out the example, initialize and then apply:
2014-10-14 03:07:54 +02:00
```
2017-06-03 01:54:30 +02:00
$ terraform init
...
2014-10-14 03:07:54 +02:00
$ terraform apply
...
```
Terraform will interactively ask for variable input and potentially
provider configuration, and will start executing.
When you're done with the example, run `terraform destroy` to clean up.