Validate the configuration
Learn
The terraform block and providers
The terraform block configures Terraform itself — most importantly which
providers it needs. A provider is a plugin that knows how to talk to a
specific platform (AWS, in our case):
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
source says where to download it from (the public registry), and version pins it.
~> 5.0 means "any 5.x": new features and fixes, but never the next major version,
which could break your configuration.
validate
terraform validate checks that the configuration is syntactically valid and
internally consistent (block types, argument names, references) without touching any
infrastructure or needing credentials:
Success! The configuration is valid.
It's the cheapest check there is, which is why CI pipelines run it on every push. Once it passes, try adding another local value, for example:
locals {
project = "course-platform"
region = "us-east-1"
}
Validate again and watch it stay green. Then try a typo, like a missing closing brace, and read the error: validate points at the file and line.
Your task
The editor has a terraform block declaring the AWS provider plus a locals block. Run validate — it confirms the config is well-formed without touching any infrastructure. Try adding a second local (for example region = "us-east-1") and validate again; it should stay green.
Interview prep
The basics interviewers expect you to state crisply.
What does terraform validate check — and what does it NOT?
validate confirms the configuration is syntactically valid and internally consistent (references resolve, argument types line up), entirely offline. It does NOT contact a provider, read state, or tell you what will change — that's plan.
What is a Terraform provider?
A plugin that maps Terraform resources onto a platform's API — hashicorp/aws knows how to create/read/update/delete AWS resources. The required_providers block declares which providers (and version constraints) a configuration needs.