Skip to main content

Terraform Certification Preparation


Certification overview

The HashiCorp Certified: Terraform Associate validates your Infrastructure as Code skills with Terraform.

Key information

CriterionDetail
Price~$70.50 USD
Duration60 minutes
Questions~57 questions
FormatMCQ, multi-select, true/false
Minimum score70%
Validity2 years
ModeOnline (proctored)

Exam objectives

1. Understand Infrastructure as Code (IaC)

  • Explain the benefits of IaC
  • Understand the Terraform workflow

Sample questions:

  • What are the benefits of IaC compared to manual management?
  • What is the order of the standard Terraform workflow?

2. Understand the purpose of Terraform

  • Multi-cloud and provider-agnostic
  • Benefits of Terraform vs other tools

Sample questions:

  • Why use Terraform rather than Bash scripts?
  • How does Terraform manage multiple cloud providers?

3. Understand Terraform basics

# Bloc de configuration de base
terraform {
required_version = ">= 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}

provider "aws" {
region = "eu-west-1"
}

resource "aws_instance" "example" {
ami = "ami-12345678"
instance_type = "t2.micro"

tags = {
Name = "example"
}
}

To master:

  • Blocks: terraform, provider, resource, data, variable, output, module
  • Data types: string, number, bool, list, map, object, tuple
  • Interpolation and expressions

4. Use the Terraform CLI

# Commandes essentielles
terraform init # Initialiser le répertoire
terraform validate # Valider la configuration
terraform plan # Prévisualiser les changements
terraform apply # Appliquer les changements
terraform destroy # Détruire l'infrastructure

# Commandes avancées
terraform fmt # Formater le code
terraform state list # Lister les ressources
terraform import # Importer une ressource existante
terraform taint # Marquer pour recréation
terraform workspace # Gérer les workspaces

5. Interact with modules

# Utiliser un module
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.0.0"

name = "my-vpc"
cidr = "10.0.0.0/16"
}

# Accéder aux outputs du module
output "vpc_id" {
value = module.vpc.vpc_id
}

Key points:

  • Sources: local, registry, GitHub, S3
  • Module versioning
  • Variables and outputs

6. Navigate the Terraform workflow

  • Core workflow: Write → Plan → Apply
  • Remote backends
  • State management

7. Implement and maintain state

# Backend S3
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "prod/terraform.tfstate"
region = "eu-west-1"
encrypt = true
dynamodb_table = "terraform-locks"
}
}

To know:

  • Purpose of state
  • Backends: local vs remote
  • State locking
  • Sensitive data in state

8. Read, generate, and modify configuration

# Variables
variable "instance_type" {
description = "EC2 instance type"
type = string
default = "t3.micro"

validation {
condition = contains(["t3.micro", "t3.small"], var.instance_type)
error_message = "Must be t3.micro or t3.small."
}
}

# Data sources
data "aws_ami" "amazon_linux" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-gp2"]
}
}

# Locals
locals {
common_tags = {
Environment = var.environment
ManagedBy = "Terraform"
}
}

# Outputs
output "instance_ip" {
description = "Public IP of the instance"
value = aws_instance.example.public_ip
sensitive = false
}

9. Understand Terraform Cloud/Enterprise

  • Remote execution
  • Private module registry
  • Sentinel policies
  • Teams and governance

Practice questions

Section 1: IaC Concepts

Q1. What are the benefits of Infrastructure as Code?

  • A) Infrastructure versioning
  • B) Repeatable deployment
  • C) Automatic documentation
  • D) All of the above

Answer: D


Q2. In what order does the standard Terraform workflow run?

  • A) Apply → Plan → Init
  • B) Init → Apply → Plan
  • C) Init → Plan → Apply
  • D) Plan → Init → Apply

Answer: C


Section 2: Terraform CLI

Q3. Which command formats Terraform code?

  • A) terraform format
  • B) terraform fmt
  • C) terraform lint
  • D) terraform style

Answer: B


Q4. What does terraform init -upgrade do?

  • A) Updates Terraform
  • B) Updates providers to the latest versions
  • C) Updates the state
  • D) Updates the modules

Answer: B (and D as well - it updates providers AND modules)


Q5. How do you apply changes without interactive confirmation?

  • A) terraform apply --yes
  • B) terraform apply -auto-approve
  • C) terraform apply -force
  • D) terraform apply --no-confirm

Answer: B


Section 3: State

Q6. Where is the Terraform state stored by default?

  • A) In the cloud provider
  • B) In a local file terraform.tfstate
  • C) In Terraform Cloud
  • D) In an S3 bucket

Answer: B


Q7. Which command lists the resources in the state?

  • A) terraform list
  • B) terraform state show
  • C) terraform state list
  • D) terraform resources

Answer: C


Q8. How do you remove a resource from the state without destroying it?

  • A) terraform destroy -target=resource
  • B) terraform state rm resource
  • C) terraform delete resource
  • D) terraform remove resource

Answer: B


Section 4: Configuration

Q9. Which block type retrieves existing data?

  • A) resource
  • B) data
  • C) query
  • D) fetch

Answer: B


Q10. How do you reference a variable in Terraform?

  • A) ${variable.name}
  • B) $variable.name
  • C) var.name
  • D) variable["name"]

Answer: C


Q11. What is the difference between count and for_each?

# count - basé sur un nombre
resource "aws_instance" "example" {
count = 3
ami = "ami-12345678"
}

# for_each - basé sur une collection
resource "aws_instance" "example" {
for_each = toset(["web", "app", "db"])
ami = "ami-12345678"
tags = {
Name = each.key
}
}
  • A) No difference
  • B) count uses indices, for_each uses keys
  • C) for_each is slower
  • D) count only supports numbers

Answer: B


Section 5: Modules

Q12. What are the valid sources for a module?

  • A) Local path
  • B) Terraform Registry
  • C) GitHub
  • D) All of the above

Answer: D


Q13. How do you access an output of a child module?

  • A) module.child.output_name
  • B) child.output_name
  • C) output.child.output_name
  • D) modules.child.outputs.output_name

Answer: A


Section 6: Providers

Q14. What happens if you do not specify a provider version?

  • A) Error
  • B) Uses the latest version
  • C) Uses version 1.0.0
  • D) Prompts interactively

Answer: B


Q15. How do you use multiple configurations of the same provider?

provider "aws" {
region = "eu-west-1"
}

provider "aws" {
alias = "us"
region = "us-east-1"
}

resource "aws_instance" "eu" {
# Utilise le provider par défaut
}

resource "aws_instance" "us" {
provider = aws.us # Utilise l'alias
}

Answer: Use the alias attribute


Section 7: Workspaces

Q16. Which command lists the workspaces?

  • A) terraform workspace show
  • B) terraform workspace list
  • C) terraform workspaces
  • D) terraform list workspace

Answer: B


Q17. Which workspace is created by default?

  • A) main
  • B) default
  • C) master
  • D) production

Answer: B


Exam tips

Before the exam

  1. Practice: Complete the projects in this course
  2. Read the documentation: terraform.io/docs
  3. Do labs: HashiCorp Learn
  4. Test yourself: Practice questions

During the exam

  1. Manage your time: ~1 min per question
  2. Read carefully: Watch out for "NOT", "EXCEPT"
  3. Eliminate: Narrow down the options
  4. Flag and return: Don't get stuck on a question

Topics you absolutely must master

TopicImportance
Workflow (init, plan, apply)⭐⭐⭐⭐⭐
State management⭐⭐⭐⭐⭐
Variables and outputs⭐⭐⭐⭐⭐
Modules⭐⭐⭐⭐
Providers⭐⭐⭐⭐
Data sources⭐⭐⭐⭐
Terraform Cloud⭐⭐⭐
Workspaces⭐⭐⭐

Resources

Official documentation

Hands-on labs

  • "Terraform: Up and Running" - Yevgeniy Brikman
  • "Infrastructure as Code" - Kief Morris

Course recap

Congratulations! You have completed the Terraform Advanced Practices course.

What you have learned

  1. ✅ Production-ready Multi-AZ VPC
  2. ✅ Highly available Web Application
  3. ✅ Kubernetes Cluster (EKS)
  4. ✅ Serverless Architecture
  5. ✅ Multi-environment management
  6. ✅ Complete CI/CD pipeline
  7. ✅ Monitoring stack
  8. ✅ Multi-cloud deployment
  9. ✅ Advanced troubleshooting
  10. ✅ Certification preparation

Next steps

  1. Practice: Redo the projects in your own AWS account
  2. Get certified: Take the Terraform Associate certification
  3. Grow: Explore Terraform Enterprise and Sentinel

Good luck with the certification! 🎯


← Troubleshooting | Table of contents →