Terraform Flashcards
What is infrastructure as code?
Is provisioning infrastructure through software to achieve consistent and predictable environments.
What is the difference between declarative and imperative?
Imperative = step-by-step on how to do a task Declarative = I want the state X (declaring what I want).
What is idempotency?
If I run the same task twice I won’t have a duplicated item.
What is the difference between push and pull?
Push: a server actively pushes configs;
Pull: a client actively pulls configs;
Is terraform push-type-model?
Yes. A server pushes the configs.
What is workflow that terraform imposes?
Provisioning resources;
Planning Updates;
Using Source Control;
Reusing Templates;
What are the four components of terraform?
terraform executable, terraform files, terraform plugins and terraform state.
What is a terraform plugin?
Is an extension of terraform that allows interacting with providers (e.g: azure, aws etc.
What is the terraform state?
Keeps track of what the current state looks like
what is the data type?
a data-source
what a tf file contains?
terraform code itself.
what a tfvars file contain?
input to variables
how to reference a var?
var.my_var_name
What is a triplet?
resourceType.resourceName.property.
Does terraform support function? examples?
yes… file(path)
what does the output type do?
outputs the content of a variable
how to declare a var in a tfvar file?
variable “image_id” {
type = string
}
what is the caveat with backslash in a windows environment?
it’s escape… use double: \
What does terraform init do?
It checks the config files looking for providers (plugins) and download the necessary files.
What does terraform plan do?
Loads the config files (.tf) and variables (.tfvars) and compare against an existing state (if any) then shows what needs to be done to achieve the desired state.
what does terraform plan -out myplan.tfplan?
shows the plan and store it in the tfplan file for future usage (apply) / inspection.
what is “known after apply” value that shows in the plan?
stuff that will be known only after the resource is applied (such as IDs)
What does terraform apply “myplan.tfplan” do?
Will apply the plan (actually provision stuff)
Which file is created after the first time I do an apply?
a tfstate file will be created
What does the terraform destroy do?
destroy the resources that are stored in the state file
what is the format of tfstate? Should I manually change it?
JSON. DO NOT TOUCH IT.
what the tfstate file contain?
resource mappings and general metadata. locking, location…
what is a workspace in terraform?
each workspace has a state… so it is a separation.
what happens if the installed version of terraform is lower than the one that created the state file (someone else created it, for example)?
terraform won’t allow interactions on it (you’ll need to upgrade terraform)
what is the serial number of tfstate?
an incremental number that is increased when the state file is updated.
why is the serial number of tfstate necessary?
to match up the version I have in the plan and the one in the state (so that you can’t apply an old plan)
does the tfstate contain the output information that we define and see in the prompt?
yes.