Hashicorp Terraform Cert Flashcards
What is IaC?
Infrastructure as Code
- writing what you want to deploy as human readable code
What are the benefits of IaC?
- Enabling DevOps
- Declaring your Infrastructure
- Speed, Cost, Reduced Risk
What is the Terraform Workflow?
- Write
- Plan
- Apply
What does “terraform plan” do?
- reads code and creates and shows a “plan of execution/deployment”
- does not actually deploy anything
- allows the user to “review” the action plan before executing anything
- Authentication Credentials are used to connect to your infrastructure if required
At what stage of the terraform workflow are Authentication Credentials used to connect to your infrastructure if required?
Terraform Plan
What does “terraform apply” do?
- Deploys the instructions and statements in the code
- Updates the State File
What does “terraform destroy” do?
- Looks at the recorded/stored State File created during deployment and destroys all resources created by your code
True of False: “terraform destroy” is non-reversible
True
What does “terraform init” do?
-Initializes the working directory that contains your Terraform code
– downloads the ancillary/supporting components (providers, modules, plug ins)
– sets up the backend for storing the terraform state file
What is a Resource Address?
- a way to access a resources in terraform code
What pattern does a Resource Address for the following look like?
resource “aws_instance” “web” {
ami = “ami-a1b2c3d4”
instance_type = “t2.micro”
aws_instance.web
What pattern does a Resource Address for the following look like?
data “aws_instance” “my-vm” {
instance_id = “i-1234567890abcdef0”
}
data.aws_instance.my-vm
What is the main difference between a data block and a resource block?
- Data blocks fetch and track details of already existing resources
- Resource block create resources from scratch
What file extension does terrafrom look for to execute terraform code?
.tf
Where does Terraform first look for providers?
In the Terraform Providers Registry
True or False: Providers can not be sourced locally and internally and referenced in your code
False
What are the two methods for installing Terraform?
Method 1: Download, Unzip, and Use
Method 2: Set up a Terraform Repository on Linux
What are Providers?
Providers are Terraform’s way of abstracting integrations with API control layer of the infrastructure vendors
(i.e. Terraform abstracts away all the API calls it makes under the hood using Providers)
basically like plug ins
- Each provider is a precompiled chunk of code which defines resources for Terraform to interact with the respective vendor
True or False: Providers are released on a separate rhythm from Terraform itself
True
Select which one is False:
A - Each Provider has their own series of version numbers
B - You can only use providers from the Terraform Provider’s registry
C - It is a Best Practice to Fix the version of the providers in your code
D - Providers updates and releases are seperate from Terraform’s
B
You can create your own custom providers!
where are providers stored?
in the hidden .terraform file
revelaed by ls -a
What is the purpose of provisioners?
Provisioners give users a way to execute custom scripts, commands, or actions
What are the 2 types of provisioners
Creation-time
Destruction-time
How can Terraform provisioners be run?
locally on the same system
or
remotely on resources spun up through the Terraform deployment