Skip to main content

Command Palette

Search for a command to run...

Creating an S3 Bucket with Terraform

Published
1 min read
Creating an S3 Bucket with Terraform
S

DevOps Enginner

On Day 3 of my #30DaysOfAWSTerraform journey, I learned how to create an AWS S3 bucket using Terraform—a simple but powerful step toward managing cloud infrastructure as code.

Why S3 with Terraform?

Amazon S3 is widely used for:

  • Storing application assets

  • Backups & logs

  • Static website hosting

  • Data lakes

Using Terraform lets you version, automate, and reproduce S3 infrastructure safely and consistently.

Prerequisites

  • AWS account

  • AWS CLI configured (aws configure)

  • Terraform installed

Step 1: Configure the AWS Provider

provider "aws" {
  region = "ap-south-1"
}

Step 2: Create an S3 Bucket

resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-terraform-demo-bucket-123"
}

⚠️ S3 bucket names must be globally unique

(Optional) Add Versioning

resource "aws_s3_bucket_versioning" "versioning" {
  bucket = aws_s3_bucket.my_bucket.id

  versioning_configuration {
    status = "Enabled"
  }
}

Step 3: Initialize & Apply

terraform init
terraform plan
terraform apply

After confirmation, Terraform creates the S3 bucket automatically

Check Github:- https://github.com/sidharthhhh/terraform/tree/main/day3

check this vedio for more clear explaination:- https://youtu.be/09HQ_R1P7Lw?si=7eakIMRH_Bv4R_92