AWS Setup
S3 Bucket Creation
- Created a bucket:
believe-in-bucketon AWS Free Tier. - Bucket settings: default “Block Public Access ON”, Object Ownership: Bucket owner enforced.
EC2 Instance
- Launched an EC2 instance (Amazon Linux 2)
- Connected via SSH from WSL2 and VSCode Remote-SSH
- Verified IAM role attached to EC2 had **AmazonS3FullAccess **to communicate with S3.
2. EC2 → S3 Connectivity
Verified connection:
aws s3 ls
aws s3 ls s3://believe-in-bucket
- Success: EC2 could list the bucket, confirming IAM permissions are correct.
-
Troubleshooting::
- Initially had to create an IAM role with
AmazonS3FullAccessand attach to EC2
- Initially had to create an IAM role with
- Ensured EC2 uses that role by checking
aws sts get-caller-identity
SCP / VSCode Connectivity
SSH Connection Setup
Configured
~/.ssh/configon WSL2 and WindowsVerified connection:
ssh ec2-dev
Issue: SCP using
my-ec2host failed due to “Could not resolve hostname”Fix: Ensure the host alias in
~/.ssh/configmatches the SSH command. Using actual EC2 public DNS worked.VSCode Remote-SSH
Configured the same SSH config in VSCode
Connection worked, but public key permissions/paths needed corrections (used Windows paths in
IdentityFile)
Uploading DevOps Folder to EC2
Created
~/DevOpsfolder on EC2Copied
index.htmlfrom WSL to EC2 via scpObservation: Only
index.htmlexisted initially — no CSS/JS or subfolders.
Uploading to S3
- First attempt:
aws s3 cp ~/DevOps s3://believe-in-bucket/ --recursive --acl public-read
- Errors encountered:
-
AccessControlListNotSupported→ caused by bucket having owner enforced ACLs- Only
index.htmluploaded → folder structure and.gitskipped (by default & ACL errors) - Bucket policy changes failed → due to Block Public Access being ON
- Only
- Troubleshooting Steps:
Removed
--acl public-readExcluded
.gitfolder explicitly:
aws s3 cp ~/DevOps s3://believe-in-bucket/ --recursive --exclude ".git/*"
- Verified folder structure:
aws s3 ls s3://believe-in-bucket/ --recursive
-
Result: Files like
index.html,css/style.css,js/app.jsuploaded successfully.
Static Website Hosting
- Enabled S3 website hosting:
aws s3 website s3://believe-in-bucket/ --index-document index.html
- Error: 403 Forbidden when accessing the URL in a browser
Troubleshooting:
Cause: Bucket is private, Block Public Access ON
Solution:
Disable Block Public Access (for testing)
Add bucket policy for public read:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::believe-in-bucket/*"
}
]
}
After this, the S3 URL was accessible.
Issue: Blank page appeared → cause:
index.htmlhad no content in<body>Fix: Added minimal content to
<body>:
<body>
<h1>Welcome to AWS DevOps!</h1>
</body>
Final Folder Structure in S3
index.html
css/style.css
js/app.js
-
.gitwas excluded - Folder structure preserved, contents accessible via static website
Key Lessons / Gotchas
- S3 ACL vs Bucket Owner Enforced
-
--acl public-readfails on owner-enforced buckets → must use bucket policy for public access.
- ** Recursive uploads**
Only uploads existing files
Empty folders are not stored in S3
Exclude
.gitto avoid ACL/metadata issues
- Static Website
Needs public read via policy
URL must match folder structure (
index.htmlat root vs in subfolder)
- SSH / SCP / VSCode
Host alias in
~/.ssh/configmust match commandIdentity file path correct for WSL vs Windows
SCP requires correct relative path to copy folders
- Blank page troubleshooting
- Often caused by empty
<body>or wrong paths for CSS/JS
Outcome:
EC2 instance created and connected via SSH/VSCode
IAM role attached to allow S3 access
DevOps folder uploaded from WSL → EC2 → S3
Bucket policy allows public read, website enabled
Website successfully serves
index.htmland all static assets
Top comments (0)