TerraformGet Status

Getting the status using Terraform

Viewing the Status of Everything in Terraform

Terraform has several commands to inspect what it knows about your infrastructure. Here's the full toolkit:


1. terraform show — The Full Picture

Dumps the entire current state in a human-readable format. This is everything Terraform knows about every resource it manages.

terraform show

For JSON output (useful for scripting or piping to jq):

terraform show -json | python3 -m json.tool

2. terraform state list — List All Managed Resources

Shows a quick list of every resource Terraform is tracking, without the detail.

terraform state list

Example output:

data.oci_core_images.oracle_linux
data.oci_identity_availability_domains.ads
oci_core_instance.free_vm
oci_core_subnet.subnet
oci_identity_compartment.tf_compartment
oci_identity_policy.tf_compartment_policy

3. terraform state show <resource> — Inspect One Resource

Zoom in on a single specific resource and see all its attributes.

terraform state show oci_core_instance.free_vm
terraform state show oci_identity_compartment.tf_compartment

💡 Use the resource names from terraform state list as the argument.


4. terraform plan — What Would Change?

Compares your .tf files against the current state and shows a diff of what would be created, changed, or destroyed. Nothing is actually changed.

terraform plan

Output legend:

+ resource will be CREATED
~ resource will be UPDATED in-place
- resource will be DESTROYED
-/+ resource will be DESTROYED then re-created

5. terraform output — See Output Values Only

Shows just the output values defined in your outputs.tf — useful for quickly grabbing IPs, OCIDs, etc.

terraform output
# Get a specific output value
terraform output instance_public_ip

6. terraform refresh — Sync State with Reality

If resources were changed outside of Terraform (e.g., via OCI Console or CLI), this pulls the real-world state back into Terraform's state file.

terraform refresh

⚠️ As of Terraform 0.15+, refresh is built into terraform plan automatically. Use terraform apply -refresh-only as the modern equivalent.


Quick Reference Cheat Sheet

CommandWhat it does
terraform showFull state dump, all resources
terraform state listQuick list of all tracked resources
terraform state show <resource>Deep dive into one resource
terraform planWhat WOULD change if you applied
terraform outputShow output values only
terraform apply -refresh-onlySync state with real-world without changing anything

For Your OCI Setup Specifically

# See everything at once
cd ~/terraform_learn && terraform show

# Quick list of your resources
terraform state list

# Check your VM specifically
terraform state show oci_core_instance.free_vm

# Grab the public IP directly
terraform output instance_public_ip