Evolving Your Infrastructure with Terraform

HashiCorp, an IBM Company · 69K views · 2017 · 36:24

Open on YouTube

Cloud, DevOps & reliabilitySoftware architecture & designtalk

Why Stack Overflow recommends it

Stack Overflow users link it when answering Terraform structure questions, such as how to separate dev and prod, share code across customers, or migrate into modules.

Recommended by 3 people across 4 different months, 2017 to 2024.

What it is

A 36-minute HashiCorp conference talk by Nicki Watt of OpenCredo on how teams' Terraform usage typically evolves, from local laptop development to shared state and shared services with Consul and Vault. It covers common pain points, moving to CI/CD and DevOps, and the bootstrap problem of who builds the infrastructure that builds the infrastructure.

What people said

Strong rec Christian Banfi · 2024-09 · Stack Overflow · on “How can I create two separate environments (dev and prod) for deploying AWS resources using Terraform within a single AWS account”

First of all, there is no "best way". Besides of some general rules, it also depends on preferred ways to work. I can highly recommend Nicki Watt's talk on Evolving your Infrastructure with Terraform : [this video] To summarise it briefly: Separate your terraform code into re-usable modules, which are collections of terraform resources. Create logical components, which are compositions of the modules you created and optionally additional resources. Create environment-specific configurations of those logical components. The key is to have the same code for each environment, which differs only in configuration. I.e. the suffix in your case. Your current structure already looks pretty much like this

Recommends Farid Nouri Neshat · 2017-09 · Stack Overflow · on “Provisioning customer accounts with Terraform (workspaces, Modules, ?) Best Practice?”

You should modulerize your code [LINK] , then you can easily reuse that module(from a git repository) with different variables to be used for that customer. In this case for each customer, you will end up with only a file that configures the main module. Have one directory for each customer, with a terraform file that loads up the module(s) and configures it. If you use terraform apply in that directory then the state will also be in that directory. To make sure your team can also deploy and make changes it is suggested to use a backend [LINK] such as S3, so the state will be written there. Note that you have to configure a backend for each customer in their respective directory. Make sure t

Recommends ofirule · 2020-07 · Stack Overflow · on “How to swap between projects with terraform”

I know this lecture helped me when I started migrating to terraform: [this video] It's useful to some of your questions

Recommends ofirule · 2020-08 · Stack Overflow · on “Create a new project using outputs from Terraformer”

You need to create a terraform module [LINK] which will deploy whatever enviroment you want and will take as few parameters as possible, only name (e.g: "test-two") if possible. Converting your current state to use module is not the easiest , but is usually possible without destroying any resource when using terraform import I would also recommend watching this video [this video]