Terraform (.tf) Flashcards

(9 cards)

1
Q

What is Terraform?

A

Terraform (.tf) is a cloud-agnostic idempotent declarative virtual resource provisioning and defining IaC tool.

Declarative: You describe what you want, and Terraform figures out how to do it.

Idempotent: Run it multiple times, and it won’t create duplicates.

Cloud Agnostic: Works with Azure, AWS, GCP, etc. using providers (like azurerm for Azure).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a provider in Terraform?
A. A cloud support agent
B. A plugin that defines resources for a specific platform
C. A billing feature
D. A backup service

A

B. A plugin that defines resources for a specific platform = a provider in TF.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s the purpose of terraform apply (cmd)?
A. Show current config
B. Run tests
C. Deploy the planned changes
D. Remove all resources

A

C. Deploy the planned changes = terraform apply

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens if you manually change a resource in the Azure portal after using Terraform?
A. Terraform deletes the resource
B. Nothing changes
C. Terraform ignores manual edits
D. Terraform may detect drift and update it on next plan/apply

A

D. Terraform may detect drift and update it on next plan/apply

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does terraform destroy do?
A. Deletes the working directory
B. Uninstalls Terraform
C. Deletes all resources defined in your config
D. Erases the state file only

A

C. Deletes all resources defined in your config = terraform destroy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of terraform refresh?
A. Applies new changes
B. Updates the state file to match real infrastructure
C. Deletes old resources
D. Clears the config cache

A

B. Updates the state file to match real infrastructure - terraform refresh

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following best describes the Terraform state file (terraform.tfstate)?
A) A log of Terraform command history
B) A backup of your config files
C) A JSON file tracking real infrastructure and config
D) A temporary file used only during apply

A

C) A JSON file tracking real infrastructure and config = .tfstate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you create reusable groups of resources in Terraform?
A) Using providers
B) Using modules
C) Using variables
D) Using plans

A

B) Using modules creates reusable groups of resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Terraform Example
# Configure the Azure provider
provider “azurerm” {
features {} # Required block, can be empty
}

Define a resource group
resource “azurerm_resource_group” “example” {
name = “example-resources” # Name of the resource group
location = “eastus” # Azure region
}

Output the resource group name
output “resource_group_name” {
value = azurerm_resource_group.example.name
}

A

Configure the Azure provider
provider “azurerm” {
features {} # Required block, can be empty
}

Define a resource group
resource “azurerm_resource_group” “example” {
name = “example-resources” # Name of the resource group
location = “eastus” # Azure region
}

Output the resource group name
output “resource_group_name” {
value = azurerm_resource_group.example.name
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly