Day 3 - Creating My First S3 Bucket Using Terraform
Introduction
Day 3 felt like the first real interaction with AWS.
Not just writing Terraform code, but actually creating something in the cloud. A small step, a simple S3 bucket, but it carried an important lesson: before infrastructure, comes authentication.
Understanding the Basics
Before Terraform can create anything in AWS, it needs permission.
This is handled using AWS credentials. I configured mine using:
aws configure
Once set, Terraform can securely communicate with AWS APIs.
What is S3?
Amazon S3 (Simple Storage Service) is an object storage service.
It allows you to store files like:
- Images
- Backups
- Logs
- Application data
One key rule:
S3 bucket names must be globally unique across AWS.
Terraform Code
Here’s the simple configuration I used:
provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "my_bucket" {
bucket = "jay-day3-s3-bucket-123456"
tags = {
Name = "Day3Bucket"
Environment = "Learning"
}
}
Commands I Used
terraform init
terraform plan
terraform apply
After applying, I verified the bucket using:
Challenge Faced
I initially hit this error:
No valid credential sources found
This was due to missing AWS configuration.
Fix:
-
Ran
aws configure -
Verified credentials using
aws sts get-caller-identity
Key Learning
Most infrastructure issues don’t come from Terraform code, they come from misconfigured authentication.
Once credentials are set correctly, everything becomes smoother.
Conclusion
Today’s learning wasn’t just about creating an S3 bucket.
It was about understanding how Terraform connects with AWS, and why authentication is the foundation of everything in cloud.
A simple bucket but a meaningful step forward.
Comments
Post a Comment