github.com/adamar/terraform@v0.2.2-0.20141016210445-2e703afdad0e/website/source/intro/use-cases.html.markdown (about)

     1  ---
     2  layout: "intro"
     3  page_title: "Use Cases"
     4  sidebar_current: "use-cases"
     5  ---
     6  
     7  # Use Cases
     8  
     9  Before understanding use cases, it's useful to know [what Terraform is](/intro/index.html).
    10  This page lists some concrete use cases for Terraform, but the possible use cases are
    11  much broader than what we cover. Due to its extensible nature, providers and provisioners
    12  can be added to further extend Terraform's ability to manipulate resources.
    13  
    14  #### Heroku App Setup
    15  
    16  Heroku is a popular PaaS for hosting web apps. Developers create an app, and then
    17  attach add-ons, such as a database, or email provider. One of the best features is
    18  the ability to elastically scale the number of dynos or workers. However, most
    19  non-trivial applications quickly need many add-ons and external services.
    20  
    21  Terraform can be used to codify the setup required for a Heroku application, ensuring
    22  that all the required add-ons are available, but it can go even further: configuring
    23  DNSimple to set a CNAME, or setting up CloudFlare as a CDN for the
    24  app. Best of all, Terraform can do all of this in under 30 seconds without
    25  using a web interface.
    26  
    27  #### Multi-Tier Applications
    28  
    29  A very common pattern is the N-tier architecture. The most common 2-tier architecture is
    30  a pool of web servers that use a database tier. Additional tiers get added for API servers,
    31  caching servers, routing meshes, etc. This pattern is used because the tiers can be scaled
    32  independently and provide a separation of concerns.
    33  
    34  Terraform is an ideal tool for building and managing these infrastructures. Each tier can
    35  be described as a collection of resources, and the dependencies between each tier are handled
    36  automatically; Terraform will ensure the database tier is available before the web servers
    37  are started and that the load balancers are aware of the web nodes. Each tier can then be
    38  scaled easily using Terraform by modifying a single `count` configuration value. Because
    39  the creation and provisioning of a resource is codified and automated, elastically scaling
    40  with load becomes trivial.
    41  
    42  #### Self-Service Clusters
    43  
    44  At a certain organizational size, it becomes very challenging for a centralized
    45  operations team to manage a large and growing infrastructure. Instead it becomes
    46  more attractive to make "self-serve" infrastructure, allowing product teams to
    47  manage their own infrastructure using tooling provided by the central operations team.
    48  
    49  Using Terraform, the knowledge of how to build and scale a service can be codified
    50  in a configuration. Terraform configurations can be shared within an organization
    51  enabling customer teams to use the configuration as a black box and use Terraform as
    52  a tool to manage their services.
    53  
    54  #### Software Demos
    55  
    56  Modern software is increasingly networked and distributed. Although tools like
    57  [Vagrant](http://www.vagrantup.com/) exist to build virtualized environments
    58  for demos, it is still very challenging to demo software on real infrastructure
    59  which more closely matches production environments.
    60  
    61  Software writers can provide a Terraform configuration to create, provision and
    62  bootstrap a demo on cloud providers like AWS. This allows end users to easily demo
    63  the software on their own infrastructure, and even enables tweaking parameters like
    64  cluster size to more rigorously test tools at any scale.
    65  
    66  #### Disposable Environments
    67  
    68  It is common practice to have both a production and staging or QA environment.
    69  These environments are smaller clones of their production counterpart, but are
    70  used to test new applications before releasing in production. As the production
    71  environment grows larger and more complex, it becomes increasingly onerous to
    72  maintain an up-to-date staging environment.
    73  
    74  Using Terraform, the production environment can be codified and then shared with
    75  staging, QA or dev. These configurations can be used to rapidly spin up new
    76  environments to test in, and then be easily disposed of. Terraform can help tame
    77  the difficulty of maintaining parallel environments, and makes it practical
    78  to elastically create and destroy them.
    79  
    80  #### Software Defined Networking
    81  
    82  Software Defined Networking (SDN) is becoming increasingly prevalent in the
    83  datacenter, as it provides more control to operators and developers and
    84  allows the network to better support the applications running on top. Most SDN
    85  implementations have a control layer and infrastructure layer.
    86  
    87  Terraform can be used to codify the configuration for software defined networks.
    88  This configuration can then be used by Terraform to automatically setup and modify
    89  settings by interfacing with the control layer. This allows configuration to be
    90  versioned and changes to be automated. As an example, [AWS VPC](http://aws.amazon.com/vpc/)
    91  is one of the most commonly used SDN implementations, and [can be configured by
    92  Terraform](/docs/providers/aws/r/vpc.html).
    93  
    94  #### Resource Schedulers
    95  
    96  In large-scale infrastructures, static assignment of applications to machines
    97  becomes increasingly challenging. To solve that problem, there are a number
    98  of schedulers like Borg, Mesos, YARN, and Kubernetes. These can be used to
    99  dynamically schedule Docker containers, Hadoop, Spark, and many other software
   100  tools.
   101  
   102  Terraform is not limited to physical providers like AWS. Resource schedulers
   103  can be treated as a provider, enabling Terraform to request resources from them.
   104  This allows Terraform to be used in layers: to setup the physical infrastructure
   105  running the schedulers as well as provisioning onto the scheduled grid.
   106  
   107  #### Multi-Cloud Deployment
   108  
   109  It's often attractive to spread infrastructure across multiple clouds to increase
   110  fault-tolerance. By using only a single region or cloud provider, fault tolerance
   111  is limited by the availability of that provider. Having a multi-cloud deployment
   112  allows for more graceful recovery of the loss of a region or entire provider.
   113  
   114  Realizing multi-cloud deployments can be very challenging as many existing tools
   115  for infrastructure management are cloud-specific. Terraform is cloud-agnostic
   116  and allows a single configuration to be used to manage multiple providers, and
   117  to even handle cross-cloud dependencies. This simplifies management and orchestration,
   118  helping operators build large-scale multi-cloud infrastructures.
   119