Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... ·...
Transcript of Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... ·...
![Page 1: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/1.jpg)
Deployment & Orchestration with
TerraformFind the latest, print-friendly version of this presentation at
https://christopherdemarco.com/terraform
![Page 2: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/2.jpg)
Copyright © 2017 Christopher DeMarco. All Rights Reserved.
The opinions and mistakes that follow are my own and do not represent my employer, Hashicorp, USENIX, or anyone else.
All code samples were believed correct at runtime. Your mileage may vary.
To my grandfather, who taught me how to write.To my father, who taught me why.
![Page 3: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/3.jpg)
Who has used Terraform before?
3
![Page 4: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/4.jpg)
Infrastructure Orchestration* Not configuration management!
All your vendors’ web interfaces are different, and they all suck.
How do you document mouse-and-keyboard? Playback?!
How can creating infrastructure become repeatable and reliable?
4
![Page 5: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/5.jpg)
Infrastructure as CodeBecause programming makes things easier!
Automation!
Scale / test / rollback
Version
Collaborate / audit
Have you tried turning it off & back on again?
Interface consistency
Make devs help!
5
![Page 6: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/6.jpg)
“Infrastructure” is broad:
• AWS • Google Compute Engine
• Azure • Oracle Public Cloud
• 1&1 • Digital Ocean • Scaleway
• VMWare • Docker • Heroku
• OpenStack • Kubernetes
• Rancher • Nomad
• CloudFlare • Dyn • DDNS
• Chef • Cobbler • Rundeck
• MySQL • PostgreSQL • RabbitMQ
• DataDog • Grafana • New Relic
• Icinga2 • Librato • StatusCake
• Mailgun • OpsGenie • PagerDuty
6
![Page 7: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/7.jpg)
Stop making toolsI don’t want a drill bit, I want a hole!
Stateful
Intelligent dependency graphing
Lightweight DSL
Incremental
Golang makes it fast and portable.
Commercial support available
7
![Page 8: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/8.jpg)
Stop talkingshow us something already
![Page 9: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/9.jpg)
Providers connect to a service that you’ll be managing.
Resources are the things you want to manage. They are declared with a type and an identifier.
A resource has arguments. They can be strings, lists, or maps.
Whitespace is flexible.
HCL can be converted to/from JSON.
9
![Page 10: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/10.jpg)
![Page 11: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/11.jpg)
tf init
Initialize the package directory. Copy in needed binaries.
Initialize empty state if none exists.
`tf init` is idempotent.
Terraform will prompt you to run `terraform init` if it can’t find what it needs.
11
![Page 12: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/12.jpg)
12
![Page 13: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/13.jpg)
tf plan
Interrogate the provider[s].
Compare with local state.
Calculate dependency graph.
Print what will be done.
The plan is not saved (unless expressly requested).
13
![Page 14: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/14.jpg)
14
![Page 15: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/15.jpg)
tf applyPlan.
Apply the dependency graph.
Update local state.
15
![Page 16: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/16.jpg)
16
![Page 17: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/17.jpg)
17
![Page 18: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/18.jpg)
Let’s change something.
18
![Page 19: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/19.jpg)
19
![Page 20: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/20.jpg)
20
![Page 21: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/21.jpg)
What if it’s a destructive change?
21
![Page 22: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/22.jpg)
22
![Page 23: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/23.jpg)
23
![Page 24: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/24.jpg)
What if we remove the resource?
24
![Page 25: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/25.jpg)
25
![Page 26: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/26.jpg)
26
![Page 27: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/27.jpg)
tf destroy
Teardown *all* resources.
Prompt for confirmation (unless `-force`).
There is no undo!
Calculate dependency graph so deletion is never* blocked.
27
![Page 28: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/28.jpg)
28
![Page 29: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/29.jpg)
In a demo, no-one can see your creds.
Use the provider’s default setup? (e.g. `~/.aws`)
Use env vars?
Set expressly?
Read a file?
29
![Page 30: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/30.jpg)
Let’s build a simple webserver.
30
![Page 31: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/31.jpg)
Terraform will load and evaluate everything in the current directory named like `*.tf` .
Configuration is declarative, order does not matter.
Dependencies will be discovered and graphed.
31
![Page 32: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/32.jpg)
Dependency graphing means that order does not matter!
Once a resource is instantiated, it exports attributes. Dereference them like `${type.name.attribute}` .
Outputs will become very useful later on.
32
![Page 33: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/33.jpg)
Dependencies can span files . . . this can become difficult to manage. Use common sense.
`name` attribute is *not* Terraform’s identifier!
33
![Page 34: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/34.jpg)
34
![Page 35: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/35.jpg)
tf output
35
![Page 36: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/36.jpg)
Sensitive outputs
36
![Page 37: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/37.jpg)
Variables
37
![Page 38: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/38.jpg)
Variables must be declared. Type may be declared, or inferred from the default. If neither type nor default is given, a string is assumed.
Use variables just like you use resource attributes.
Variables are scoped to the package in which they are declared.
38
![Page 39: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/39.jpg)
If `terraform.tfvars` exists, it will be evaluated.
Specify tfvars files, or set variables directly, on the command line.
Or set them via environment variables.
Terraform will prompt for values for any variables that haven’t been set otherwise.
39
![Page 40: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/40.jpg)
Precedence:
The last file or variable specified on the command line wins.
Otherwise, `terraform.tfvars` wins.
Otherwise, an env var wins.
Otherwise, the default is used.
Otherwise, you’re prompted.
*Maps are merged!
40
![Page 41: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/41.jpg)
Variable syntax summary
41
![Page 42: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/42.jpg)
Modules
42
![Page 43: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/43.jpg)
Modules are basically functions.
Recall that variables are scoped to a package. Therefore you must explicitly pass data into and out of modules.
43
![Page 44: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/44.jpg)
Declare the variables that will be passed in.
Output the variables that will be returned.
44
![Page 45: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/45.jpg)
When passing variables into a module, make sure the names match!
45
![Page 46: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/46.jpg)
46
![Page 47: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/47.jpg)
Copy the necessary modules into the working directory.
Local paths can be relative or absolute.
Load remote modules from Git, Mercurial, HTTP URIs; S3; Terraform Registry.
Read and evaluate any third-party modules before using them!
47
tf get
![Page 48: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/48.jpg)
48
![Page 49: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/49.jpg)
Provisioners
49
![Page 50: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/50.jpg)
Provisioners get resources ready for the next step.
Maybe we use Ansible and need to ensure we have Python.
The provisioner will eventually timeout if, for example, you can’t SSH there from here.
50
![Page 51: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/51.jpg)
Idempotent?
Multiple provisioners will be executed in the order they’re declared.
Terraform does not “grok” provisioners. A failed provisioner run will cause the entire resource to fail.
OTOH: a successful provisioner will never be re-run. What if you *want* to re-run a provisioner?
51
![Page 52: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/52.jpg)
`tf taint` marks a resource as “tainted”—it is to be destroyed & recreated.
`tf untaint`
52
tf taint
![Page 53: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/53.jpg)
53
![Page 54: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/54.jpg)
Is there a better way?
54
![Page 55: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/55.jpg)
A `null_resource` is a “virtual resource” created in the project’s state.
To re-run the provisioner, `tf taint null_resource.provision_me`!
55
![Page 56: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/56.jpg)
Other ways to use remote-exec
`inline` takes a list of strings.
`script` will upload a file and execute it.
`scripts` will upload a directory.
56
![Page 57: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/57.jpg)
More provisioners* Not configuration management!
Chef
File
Local-exec
Salt-masterless
57
![Page 58: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/58.jpg)
What if I want n of a thing? How do I loop?
58
![Page 59: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/59.jpg)
Terraform iterates over `count`, setting `count.index` each time.
If `count` is > 3, we will get duplicate Env tags.
`*` means “all resources”.
Select into a list with the `element()` function.
59
![Page 60: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/60.jpg)
OK, how about conditionals?
60
![Page 61: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/61.jpg)
This almost works . . .
61
![Page 62: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/62.jpg)
But the ternary operator is more flexible.
62
![Page 63: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/63.jpg)
Use functions to modify variables.https://www.terraform.io/docs/configuration/interpolation.html
![Page 64: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/64.jpg)
tf console
64
![Page 65: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/65.jpg)
Templates
65
![Page 66: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/66.jpg)
Use templates where string interpolation would be unwieldy.
66
![Page 67: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/67.jpg)
Data sources are dynamic, read-only ways to get at data.
Escape interpolation with `$$`.
Like modules, variables must be passed into a template expressly.
Unlike modules, template variables don’t get declared.
Also unlike modules, template variables are not accessed like `var.name`.
67
![Page 68: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/68.jpg)
68
![Page 69: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/69.jpg)
Well, that was anticlimactic . . .
69
![Page 70: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/70.jpg)
AWS lets you pass “user data”: scripts that hosts will run on first boot.
Load a template from a file with the `file()` function.
Render the template locally to assist debugging.
70
![Page 71: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/71.jpg)
71
![Page 72: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/72.jpg)
One-to-many is easy; what if we want many-to-one?
72
![Page 73: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/73.jpg)
73
![Page 74: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/74.jpg)
Here-doc syntax is available throughout Terraform.
The `local_file` resource will create directories as needed.
74
![Page 75: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/75.jpg)
You can use functions in templates, too.
75
![Page 76: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/76.jpg)
76
![Page 77: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/77.jpg)
breakreturn at 1100
![Page 78: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/78.jpg)
What happens if I lose state?
78
![Page 79: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/79.jpg)
79
![Page 80: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/80.jpg)
Use remote state!
Backup
Collaboration
Pipe data among tf projects
Pipe data among other tools
Update centralized SSOT
80
![Page 81: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/81.jpg)
State backends
Artifactory
AWS S3
Azure
Consul
etcd
Google Cloud Storage
HTTP REST
OpenStack
81
![Page 82: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/82.jpg)
Backends have specific configuration details.
Whichever backend you use, ensure that it is not publicly visible.
Turn on versioning if available.
82
![Page 83: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/83.jpg)
83
If the backend is already configured, `tf init` will proceed.
Existing state will be migrated to the new backend.
![Page 84: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/84.jpg)
If the backend is not configured, use `tf init` to fill in the details.
This is useful for automated configuration.
84
![Page 85: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/85.jpg)
85
Now that state is stored remotely, we can easily use it in other parts of our infrastructure.
`tf state pull` will fetch remote state.
![Page 86: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/86.jpg)
Reference state outside of the package.
86
![Page 87: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/87.jpg)
Security groups and an app
87
![Page 88: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/88.jpg)
Reference remote state just like any other resource.
If the remote state changes, any references will become stale.
Re-apply any referring packages.
88
![Page 89: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/89.jpg)
Happily, `terraform_remote_state` is a read-only reference. `destroy` does not touch it.
89
![Page 90: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/90.jpg)
Inspect state.
90
![Page 91: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/91.jpg)
91
tf showDump the state or planfile.
This is useful for figuring out how to reference a module we want to taint.
(But we can do better!)
![Page 92: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/92.jpg)
92
![Page 93: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/93.jpg)
tf state Select and pretty-print items from the state.
93
![Page 94: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/94.jpg)
94
![Page 95: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/95.jpg)
tf state pull | jq`pull` will dump the state as JSON.
Now you can use the AWESOME `jq` JSON parser!
95
![Page 96: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/96.jpg)
Use workspaces to namespace state.
96
![Page 97: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/97.jpg)
tf workspace
Use distinct directories for state.
`new` to create, `list` to list, `select` to switch. `show` if you can’t remember where you are.
Use with the Consul and S3 backends.
Use the variable `${terraform.workspace}` for e.g. naming things.
97
![Page 98: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/98.jpg)
Enough AWS already!What else can Terraform orchestrate?
98
![Page 99: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/99.jpg)
Let’s take a tour.Beware the bright light!
99
![Page 100: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/100.jpg)
Google Cloud
100
![Page 101: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/101.jpg)
PostgreSQL
101
![Page 102: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/102.jpg)
And of course, you can mix-and-match.
102
![Page 103: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/103.jpg)
103
![Page 104: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/104.jpg)
Recap: providers, resources & data sources
104
![Page 105: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/105.jpg)
Provider arguments
Providers vary as to authentication.
Creds may be provided inline, via environment variables, and/or filesystem paths.
Providers may require regions, cloud types, and/or projects to be specified.
Store your creds safely!
105
![Page 106: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/106.jpg)
Resource arguments and attributes
Arguments to resources may be required or optional.
Some arguments can be changed without re-creating the resource.
An attribute’s value always reflects its current state. Refresh via `plan` or `apply`.
106
![Page 107: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/107.jpg)
Data sourcesData sources are *read-only*.
Arguments provide filters to restrict the kind / quantity of results.
Attributes are typically numerous and contain nested data structure.
107
![Page 108: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/108.jpg)
Gotchas
![Page 109: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/109.jpg)
Gotcha!Module param mismatch
109
![Page 110: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/110.jpg)
Gotcha!Silent failure on missing output
110
![Page 111: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/111.jpg)
Silent failure on missing output(cont.)
111
![Page 112: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/112.jpg)
Gotcha!Useless var interpolation!
112
![Page 113: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/113.jpg)
Use `local` variables.
113
![Page 114: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/114.jpg)
Gotcha!Multiple accounts
114
![Page 115: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/115.jpg)
Gotcha!Bizarre errors
115
![Page 116: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/116.jpg)
Gotcha!State changed from under me!
116
![Page 117: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/117.jpg)
Gotcha!Destroy is scary!Insurance against co-workers?
117
![Page 118: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/118.jpg)
Gotcha!Timeout!
118
![Page 119: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/119.jpg)
Gotcha!Increase verbosity
`TF_LOG=<TRACE, DEBUG, WARN, INFO, ERROR>`
You get to drink from the firehose!
It’s mainly useful for proving you’ve found a bug.
119
![Page 120: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/120.jpg)
Gotcha! A bug in the provider!
Use the provider’s `version` argument to pin it.
Providers are in a separate GitHub organization from Terraform Core: https://github.com/terraform-providers . Look at the relevant CHANGELOG.
120
![Page 121: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/121.jpg)
Gotcha!tfstate is huge!
It’s just JSON. Use `jq` or your favorite programming language.
Go install `jq` and rejoice.
121
![Page 122: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/122.jpg)
Gotcha! Dependencies hurt my brain!
122
![Page 123: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/123.jpg)
123
![Page 124: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/124.jpg)
124
![Page 125: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/125.jpg)
. . . Getcha?Golang niceities
Terraform is a single binary. Download from http://terraform.io .
`tf fmt` will apply the standard Go formatter to canonicalize style—spacing, quoting, etc.
`tf validate` will check for syntax and dependency graph issues.
125
![Page 126: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/126.jpg)
Q & A
![Page 127: Orchestration with Deployment & Terraformchristopherdemarco.com/terraform/M4-Deployment-and... · If `terraform.tfvars` exists, it will be evaluated. Specify tfvars files, or set](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec819687980846d715bda2c/html5/thumbnails/127.jpg)
Thank you.Please fill out your surveys.