Terraform FAQ: Learning, Careers, Certification, State, and Production Use
Terraform FAQ
These are the questions learners, job-switchers, and new platform engineers tend to ask after the first tutorial but before Terraform feels safe. For structured theory, use the Terraform course. For real CLI practice without cloud credentials, use the 20 Terraform labs and command warmup sandbox.
---
Do I need a cloud account to learn Terraform?
No. Terraform itself is a CLI and language; providers translate resource configuration into API operations. You can learn initialization, planning, state, variables, modules, imports, workspaces, dependencies, lifecycle rules, and refactors with local or offline providers. ShellGenius uses the real Terraform CLI against an offline FakeCloud provider implementing instances, buckets, databases, DNS records, and certificates. A cloud account becomes useful later for learning one platform's identity, networking, billing, and provider-specific behavior, but it is not a prerequisite for learning Terraform well.
Should I learn Terraform or OpenTofu?
The core workflow and HCL concepts are closely related, so skills transfer substantially. Choose based on what your employer, target jobs, providers, modules, and managed platform support. Terraform has HashiCorp's ecosystem and services; OpenTofu is an open-source fork under the Linux Foundation with its own release path. Learn the durable concepts first: resource addressing, state, plans, graph dependencies, provider constraints, modules, and safe change review. Then read the compatibility and migration notes for the exact versions your team operates.
Terraform vs CloudFormation vs Pulumi: which should I learn?
Terraform is a strong first choice for multi-provider declarative infrastructure and broad job relevance. CloudFormation is valuable in AWS-heavy organizations because it is native to AWS and integrates deeply with its services. Pulumi suits teams that prefer general-purpose languages and software abstractions. None removes the need to understand cloud APIs, state, identity, and change safety. Search the roles you want: if most mention Terraform, start there, then learn enough of the organization’s native tool to compare operational tradeoffs rather than syntax alone.
Is Terraform only for cloud infrastructure?
No. Providers exist for SaaS platforms, source control, observability, DNS, Kubernetes, identity systems, and many other APIs. The key question is whether a provider can model the object's lifecycle predictably. Terraform is best at desired-state resources with stable read/create/update/delete behavior. It is less suitable for imperative application deployment steps, one-time database migrations, or actions whose side effects cannot be refreshed and reconciled. Use the right orchestration or deployment tool alongside Terraform rather than forcing every operation into a resource.
What is the difference between configuration and state?
Configuration is the desired model written in HCL. State records which resource address is bound to which remote object and stores metadata and attributes Terraform needs. During planning, Terraform refreshes managed objects and compares observed reality, prior state, and configuration. Changing state does not rewrite HCL; changing HCL does not automatically adopt a pre-existing object. This distinction explains import, drift, moved blocks, and why deleting a state file leaves cloud resources alive but unmanaged.
Why should teams use a remote backend?
A local terraform.tfstate is convenient for experiments but poor for collaboration. A remote backend centralizes state, can provide locking, keeps version history depending on the storage service, and supports controlled access. State frequently contains sensitive data, so encryption, least privilege, audit logs, and recovery versions matter. Backend capabilities differ; confirm locking and consistency rather than assuming every object store configuration is safe. Never use Git as a state collaboration mechanism.
Does marking a value sensitive encrypt it?
No. sensitive = true redacts values from normal CLI and UI presentation, reducing accidental disclosure in logs. Terraform still needs the value and may store it in state and plan files. Encrypt those artifacts, restrict who can retrieve them, mask pipeline output, and prefer short-lived credentials. Where possible, let workloads fetch secrets from a secrets manager at runtime so Terraform manages an identifier or access policy instead of plaintext secret material.
What is the difference between a provider and a module?
A provider plugin communicates with an API and defines resource and data-source schemas. A module is a collection of Terraform configuration that composes provider resources into a reusable unit. A database module might create a database, DNS record, and monitoring policy, but the provider performs the actual API calls. Root modules should declare required providers and pass provider configurations deliberately; reusable child modules should not embed environment credentials.
When should I write a module?
Write a module when a cohesive pattern is used more than once, when a platform team wants to encode a supported standard, or when a complex subsystem benefits from a narrow interface. Do not create a wrapper around every single resource just to say everything is modular. A useful module reduces decisions, validates inputs, exposes meaningful outputs, and has an owner and upgrade path. Start with working root configuration, observe the stable boundary, then extract it.
Are Terraform CLI workspaces the best way to manage dev and production?
Not usually when dev and production need separate credentials, permissions, or strong guardrails. CLI workspaces give one configuration and backend multiple named states. They work well for structurally identical preview stacks or sandboxes inside one trust boundary. Directory-per-environment roots calling shared modules make backend configuration, provider identity, variables, and approvals more explicit. HCP Terraform workspaces are a separate concept and can provide stronger per-workspace execution and access controls.
How do teams run Terraform safely in CI/CD?
A typical pipeline pins Terraform and provider versions, authenticates through short-lived identity, runs fmt -check, validate, security and policy checks, and creates a saved plan. Reviewers inspect the plan; protected environments require approval; the apply job consumes that same artifact and is serialized per state. State and plans receive restricted encrypted storage. Mature teams also run scheduled drift detection, retain audit logs, limit routine targeting, and block dangerous replacements or deletions through policy and ownership checks.
Should a pipeline automatically apply every approved pull request?
It depends on blast radius and controls. Automatic apply can be appropriate for low-risk development roots with strong tests. Production commonly adds an explicit approval, change window, or policy gate. The important property is that the applied plan is the reviewed plan, credentials are scoped to the target, and only one writer operates on a state at a time. A green pull request is not enough if the pipeline silently replans with different inputs during apply.
How should I handle drift caused by an emergency console change?
First run a refreshed plan and establish what changed and why. Then decide the desired state with the resource owner. If the console change was temporary or unauthorized, apply configuration to restore it. If it is now correct, update HCL and review the policy, cost, and dependency impact. A refresh-only apply can record observed attributes in state but does not update configuration, so the next normal plan can still try to reverse the change. Document emergency access and create a follow-up reconciliation owner.
Is terraform refresh still the right command?
No for normal modern workflows. The standalone terraform refresh command is deprecated because it updates state automatically without first giving you a reviewable proposal. Use terraform plan -refresh-only to inspect state-only changes and terraform apply -refresh-only if you intentionally want to persist them. Normal plan and apply already refresh managed resources by default. Be especially careful when provider credentials or regions are misconfigured, because an incorrect refresh can make existing objects appear absent.
What is the safest way to rename or move a resource?
Change the configuration and add a moved block mapping the old address to the new address. The next plan should report a move rather than destroy and create. This works for renames, module extraction, and many count-to-for_each migrations. Commit the move with the refactor and retain it until every relevant state has applied the migration. terraform state mv is useful for one-off state repair but is less visible and repeatable across environments.
How do I import infrastructure that already exists?
Write a resource block at the final desired address, then use a declarative import block or terraform import ADDRESS ID. Import creates the state binding; it does not prove your configuration matches the object. Run a normal plan, classify every difference, and adjust HCL until there is no change before introducing intentional modifications. Never bind one remote object to multiple addresses. The provider documentation defines whether a resource is importable and the required ID format.
Is the HashiCorp Terraform Associate certification worth it?
It can be useful for a structured learning goal, resume screening, or a role whose employer values it. It demonstrates vocabulary and workflow knowledge, not production judgment by itself. Check the current exam version and objectives before buying because products and exams evolve. Pair preparation with hands-on work: diagnose a lock, import an object, recover drift, refactor addresses, inspect a saved plan, and explain why an action is safe. A small repository and incident walkthrough often make certification knowledge more credible in an interview.
How much HCL do I need before applying for Terraform jobs?
You should be comfortable with variables and types, locals, expressions, collections, for_each, conditionals, outputs, modules, provider constraints, data sources, lifecycle rules, and resource addressing. More importantly, you should explain state and locking, read a plan, handle secrets, recognize replacement, and design a safe pipeline. Employers hiring platform engineers also expect cloud networking, IAM, Linux, Git, and CI/CD knowledge. Terraform orchestrates those systems; it does not replace understanding them.
What Terraform mistakes should beginners avoid?
Do not commit state or secrets, run unreviewed production applies from a laptop, use -target as a permanent workflow, disable locking to bypass contention, or paste ignore_changes over unexplained drift. Avoid unpinned providers, unstable for_each keys, giant all-in-one states, and modules that conceal every meaningful decision. The corrective habit is consistent: use small blast radii, explicit ownership, reviewed plans, durable addresses, remote protected state, and a full plan after exceptional recovery commands.
What should I build for a Terraform portfolio?
Build something that demonstrates change, not just creation. Start with a multi-resource service, extract a module, add typed validation and outputs, migrate count to for_each with moved blocks, import one pre-existing object, introduce and reconcile drift, and document a safe CI plan/apply flow. Include a README explaining state design, credentials, failure modes, and tradeoffs. ShellGenius's FakeCloud labs let you practice these operations without publishing cloud credentials or paying for idle resources.