Orchestration: infrastructure described as code
Describe rather than click: the declarative approach, Terraform blocks, the init, plan, apply, destroy cycle, the state file, the dependency graph, idempotence, drift and cloud-init at first boot.
- 30 cards
- 4 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- Scenarios
A few cards from the deck
Infrastructure as code: what is it?
Show the answer
The practice of describing servers, networks and services in versioned files, applied by a tool rather than created by hand in a console.
Infrastructure is reviewed, tested and reproduced like code: a change goes through review, and an identical environment is recreated with one command.
terraform apply is run twice in a row, without touching the code in between. What does the second run answer?
- It changes nothing (“No changes”)
- It recreates all the resources to start from a clean base
- It fails because the resources already exist
- It doubles the resources, two applies adding two sets
Show the answer
It changes nothing (“No changes”)
State, code and reality match: the plan is empty, and Terraform prints “No changes. Your infrastructure matches the configuration.” then “Apply complete! Resources: 0 added, 0 changed, 0 destroyed.” That is the idempotence of a declarative description.
A Terraform file is made of blocks: … to connect to a platform, … to describe an object to create, … for an input parameter and … for a value to display at the end.
Show the answer
A Terraform file is made of blocks: provider to connect to a platform, resource to describe an object to create, variable for an input parameter and output for a value to display at the end.
data blocks additionally read objects that already exist, without creating them.
Terraform state file: what is it?
Show the answer
The file where the tool records which real resources match which blocks of the code, so it can compute the difference at the next plan.
Without it, the tool would not know what it has already created. It is shared in a locked remote store so two people do not apply at the same time.
A firewall rule added by hand in the console disappears at the next deployment. What is the probable cause and what should be done?
- Terraform bug: a ticket must be opened with the vendor
- Drift: the code is the truth, add the rule to the code
- Corrupted state file: delete it and run again
- Propagation delay: wait a few minutes
Show the answer
Drift: the code is the truth, add the rule to the code
Terraform brings the infrastructure back to what the code describes, so it removes what it does not know. Deleting the state would be worse: the tool would know nothing about what it manages.