before apply

chevron-rightcheck this beofre applyhashtag

Perfect 👍 you’re almost there! Before you jump into terraform apply, here’s the enterprise-style checklist to avoid surprises 🚀:


✅ Pre-Apply Checklist

  1. Initialize Terraform

terraform init
  • Downloads AWS provider.

  • Sets up .terraform directory.

  • Important: Run this whenever you add new providers or modules.


  1. Validate Configuration

terraform validate
  • Ensures syntax is correct.

  • Catches typos, missing arguments, bad HCL.


  1. Format for Consistency

terraform fmt -recursive
  • Formats all .tf files.

  • Keeps repo clean (important for teams).


  1. Plan with Environment

terraform plan -var-file=environments/dev.tfvars
  • Shows what resources will be created/changed/destroyed.

  • Double-check bucket name, tags, lifecycle rules.

  • Enterprise rule: Never apply without plan first.


  1. Check IAM Permissions Since you said you have Admin IAM, you’re fine ✅. If not, make sure user/role has:

  • s3:CreateBucket

  • s3:PutBucket*

  • s3:GetBucket*

  • s3:DeleteBucket


  1. Check Region In provider.tf:

provider "aws" {
  region = "ap-south-1" # or your target region
}

Make sure region matches what you want — buckets are global names, but the region matters.


  1. Check Bucket Name Uniqueness

  • S3 bucket names are globally unique.

  • If my-enterprise-bucket exists in any AWS account worldwide, Terraform will fail.

  • Safer pattern:

    bucket = "${var.bucket_name}-${var.environment}"

    Example: mybucket-dev, mybucket-stage, mybucket-prod.


🚀 Now You Can Apply

terraform apply -var-file=environments/dev.tfvars
  • Review the plan.

  • Type yes to confirm.


👉 Do you want me to review your dev.tfvars content before you apply, so I can confirm bucket name, env, and variables are set correctly? That way, you don’t risk a failed run.

Last updated