This project demonstrates the use of Terraform v1.10+ with native S3 backend locking, a new feature that eliminates the need for a DynamoDB table when managing Terraform state.
Terraform now supports native .tflock files in S3. By enabling use_lockfile = true in your backend configuration, Terraform will automatically manage state locks using S3 β no external lock tables needed.
.
βββ main.tf # Creates a sample S3 bucket
βββ backend.tf # Configures S3 backend with native locking
βββ variables.tf # Input variables for region and bucket name
βββ outputs.tf # (Optional) Outputs to show bucket details
- Terraform v1.10 or later
- S3 bucket must exist (Terraform backend cannot create it)
terraform {
backend "s3" {
bucket = "akshay-my-terraform-state-bucket"
key = "state/terraform.tfstate"
region = "us-east-1"
encrypt = true
use_lockfile = true
}
}β Make sure the S3 bucket is created and versioning is enabled before initializing.
resource "aws_s3_bucket" "demo" {
bucket = var.bucket_name
tags = {
Name = "Terraform S3 Demo"
Environment = "Dev"
}
}terraform init
terraform applyDuring apply, youβll see a .tflock file appear in your S3 bucket. It disappears automatically when the plan/apply completes
- No need for DynamoDB
- Easier setup and maintenance
- Saved cost by removing DynamoDB

