Build your resume in AWS S3
Local Folder Setup
- Create a directory in your local environment
- Inside that directory create a folder called
terraform - Create two files inside that directory
main.tfandprovider.tf - Contents of
provider.tf1terraform { 2 required_providers { 3 aws = { 4 source = "hashicorp/aws" 5 version = "~> 4.0" 6 } 7 } 8 } 9 10 # Configure the AWS Provider 11 provider "aws" { 12 region = "us-east-1" 13 } - Open Terminal
- Set the following environment variables
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY- For Linux
1export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE 2export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY - For Windows
1setx AWS_ACCESS_KEY_ID AKIAIOSFODNN7EXAMPLE 2setx AWS_SECRET_ACCESS_KEY wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- For Linux
- Initialize the current terraform directory
1terraform init - Validate the all the configurations by running
1terraform validate - Insert the below contents in your
main.tffile1# your bucket name 2variable "bucket_name" { 3 default = "datavedam-bucket" 4} 5 6resource "aws_s3_bucket" "web_bucket" { 7 bucket = var.bucket_name 8 force_destroy = true 9 tags = { 10 Name = "My Website" 11 Environment = "Dev" 12 } 13} 14 15resource "aws_s3_bucket_acl" "bucket_acl" { 16 bucket = aws_s3_bucket.web_bucket.id 17 acl = "public-read" 18} 19 20resource "aws_s3_bucket_website_configuration" "web_config" { 21 bucket = aws_s3_bucket.web_bucket.bucket 22 index_document { 23 suffix = "index.html" 24 } 25 error_document { 26 key = "error.html" 27 } 28} 29 30resource "aws_s3_bucket_policy" "bucket_policy" { 31 bucket = aws_s3_bucket.web_bucket.bucket 32 policy = <<POLICY 33 { 34 "Version": "2012-10-17", 35 "Statement": [ 36 { 37 "Sid": "PublicReadGetObject", 38 "Effect": "Allow", 39 "Principal": "*", 40 "Action": "s3:GetObject", 41 "Resource": "arn:aws:s3:::${var.bucket_name}/*" 42 } 43 ] 44 } 45 POLICY 46} - See what resource will be created in aws
1terraform plan - Create the bucket
1terraform apply - Follow the link to upload your resume.