MIKAEELS

Explore the blog

What Is Terraform? Configuration, State, Plan, and Apply

Terraform is an infrastructure-as-code tool: write configuration describing resources, review a plan, and apply the approved changes through provider APIs. Its state connects configuration addresses to the infrastructure it manages.

The workflow is shared across providers, but AWS and Google Cloud resources are not interchangeable. A storage bucket, IAM policy, and network each retain the rules of their cloud platform. HashiCorp's Terraform introduction explains the configuration, provider, and lifecycle model.

The parts you need to understand

PartRole
ConfigurationHCL files describing desired resources and relationships
ProviderPlugin implementing operations against a platform API
StateResource identity and attribute tracking for this configuration
PlanProposed creates, updates, replacements, and deletions
BackendState storage and, where supported, locking

Install Terraform through the official instructions and authenticate the target provider separately. A Terraform backend login is not the same as AWS credentials.

A small private S3 example

Create a dedicated exercise directory and save main.tf:

terraform { required_version = ">= 1.5.0" required_providers { aws = { source = "hashicorp/aws" version = "~> 6.0" } } } provider "aws" { region = "us-east-1" } resource "aws_s3_bucket" "files" { bucket_prefix = "terraform-intro-" tags = { Environment = "learning" } } resource "aws_s3_bucket_public_access_block" "files" { bucket = aws_s3_bucket.files.id block_public_acls = true block_public_policy = true ignore_public_acls = true restrict_public_buckets = true } output "bucket_name" { value = aws_s3_bucket.files.id }

The provider chooses a unique suffix for the bucket prefix. No account-specific AMI, default VPC, or SSH setup is required. This is a configuration example, not a recorded cloud deployment. Storage and API usage can incur charges.

Review before applying

terraform init terraform fmt -check terraform validate terraform plan -out=exercise.tfplan

Confirm your AWS identity and region and read the plan. If it matches your intention, terraform apply exercise.tfplan applies that saved plan. Keep plan files private: they can include configuration values and secrets. Commit .terraform.lock.hcl so the provider selection is reproducible; do not commit state files or local credentials.

A normal plan refreshes tracked resources, so it can reveal changes made outside Terraform. It does not automatically adopt unrelated infrastructure. Importing an existing resource requires explicit ownership and configuration decisions.

State, cleanup, and next steps

Protect state with an appropriate backend and access controls. Sensitive values can remain in state even when terminal output is redacted. Choose locking and recovery practices before multiple people or CI systems manage the same environment.

Review a destroy plan only for this exercise configuration. A nonempty bucket may block deletion; inspect its data rather than enabling forced deletion casually. Destroy does not delete every resource in an account, and removing a local directory does not clean up cloud infrastructure.

Continue with GCP instance schedules in Terraform. For a TypeScript-based workflow, compare Pulumi's small storage exercises and the AWS CDK learning path.

Quick Recap

Does Terraform make AWS and Google Cloud interchangeable?

No. Terraform provides a common workflow, but provider resources and cloud-service behavior remain different. Moving clouds requires design and configuration changes.

Can Terraform detect changes made outside its configuration?

A normal plan refreshes managed resource information and can reveal drift. Detection depends on the provider schema and managed attributes; Terraform does not discover and manage every resource in an account automatically.

Does terraform destroy delete everything in my account?

No. It proposes deletion of resources managed by the selected state. Review that state, the workspace, and the plan; retained or externally managed resources can remain.

Add Mikaeels Blog as a preferred source on Google

Comments

Share your thoughts and questions below