github.com/hugorut/terraform@v1.1.3/website/intro/use-cases.mdx (about) 1 --- 2 page_title: Use Cases 3 description: >- 4 Learn common use cases for Terraform including managing Heroku apps, 5 self-service clusters, and multi-cloud deployments. 6 --- 7 8 # Use Cases 9 10 This page lists a subset of use cases for [Terraform](/intro). 11 12 ## Multi-Cloud Deployment 13 14 It's often attractive to spread infrastructure across multiple clouds to 15 increase fault-tolerance. By using only a single region or cloud provider, 16 fault tolerance is limited by the availability of that provider. Multi-cloud 17 deployment allows for more graceful recovery of the loss of a region or entire 18 provider. 19 20 Realizing multi-cloud deployments can be very challenging as many existing 21 tools for infrastructure management are cloud-specific. Terraform is 22 cloud-agnostic and allows a single configuration to be used to manage multiple 23 providers, and to even handle cross-cloud dependencies. This simplifies 24 management and orchestration, helping operators build large-scale multi-cloud 25 infrastructures. 26 27 > **Hands-on:** Try the [Deploy Federated Multi-Cloud Kubernetes Clusters](https://learn.hashicorp.com/tutorials/terraform/multicloud-kubernetes) tutorial on HashiCorp Learn. 28 29 ## Heroku App Setup 30 31 Heroku is a popular PaaS for hosting web apps. Developers create an app, and then attach add-ons, such as a database, or email provider. One of the best features is the ability to elastically scale the number of dynos or workers. However, most non-trivial applications quickly need many add-ons and external services. 32 33 You can use Terraform to codify the setup required for a Heroku application, ensuring that all the required add-ons are available, but it can go even further: configuring DNSimple to set a CNAME, or setting up Cloudflare as a CDN for the app. Best of all, Terraform can do all of this in under 30 seconds without using a web interface. 34 35 ## Multi-Tier Applications 36 37 A very common pattern is the N-tier architecture. The most common 2-tier architecture is 38 a pool of web servers that use a database tier. Additional tiers get added for API servers, 39 caching servers, routing meshes, etc. This pattern is used because the tiers can be scaled 40 independently and provide a separation of concerns. 41 42 Terraform is an ideal tool for building and managing these infrastructures. You can group resources in each tier together, and Terraform will automatically handle the dependencies between each tier. For example, Terraform will ensure the database tier is available before provisioning the web servers and that the load balancers are connected to the web nodes. You can then use Terraform to easily scale each tier by modifying the `count` configuration value. Because resource creation and provisioning is codified and automated, elastically scaling 43 with load becomes trivial. 44 45 ## Self-Service Clusters 46 47 At a certain organizational size, it becomes very challenging for a centralized 48 operations team to manage a large and growing infrastructure. Instead it becomes 49 more attractive to make "self-serve" infrastructure, allowing product teams to 50 manage their own infrastructure using tooling provided by the central operations team. 51 52 You can use Terraform configuration to codify the knowledge of how to build and scale a service. You can then share these configurations throughout your organization, enabling customer teams to use Terraform to manage their services. 53 54 ## Software Demos 55 56 Modern software is increasingly networked and distributed. Although tools like 57 [Vagrant](https://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 the software on their own infrastructure, and even enables tweaking parameters like cluster size to more rigorously test tools at any scale. 63 64 ## Disposable Environments 65 66 It is common practice to have both a production and staging or QA environment. 67 These environments are smaller clones of their production counterpart, but are 68 used to test new applications before releasing in production. As the production 69 environment grows larger and more complex, it becomes increasingly onerous to 70 maintain an up-to-date staging environment. 71 72 Using Terraform, the production environment can be codified and then shared with 73 staging, QA or dev. These configurations can be used to rapidly spin up new 74 environments to test in, and then be easily disposed of. Terraform can help tame 75 the difficulty of maintaining parallel environments, and makes it practical 76 to elastically create and destroy them. 77 78 ## Software Defined Networking 79 80 Software Defined Networking (SDN) is becoming increasingly prevalent in the 81 datacenter, as it provides more control to operators and developers and 82 allows the network to better support the applications running on top. Most SDN 83 implementations have a control layer and infrastructure layer. 84 85 You can use Terraform to codify the configuration for software defined networks. 86 Terraform can then use this configuration to automatically set up and modify settings by interfacing with the control layer. This allows the configuration to be 87 versioned and changes to be automated. For example, you can [use Terraform to configure AWS VPC](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc). 88 89 ## Resource Schedulers 90 91 In large-scale infrastructures, static assignment of applications to machines 92 becomes increasingly challenging. To solve that problem, there are a number 93 of schedulers like Borg, Mesos, YARN, and Kubernetes. These can be used to 94 dynamically schedule Docker containers, Hadoop, Spark, and many other software 95 tools. 96 97 Terraform is not limited to physical providers like AWS. Resource schedulers 98 can be treated as a provider, enabling Terraform to request resources from them. 99 This allows Terraform to be used in layers: to setup the physical infrastructure 100 running the schedulers as well as provisioning onto the scheduled grid.