if you want to create a static web site with s3 you have to create some resources
- bucket
- route53
- iam
you have to use a domain for this configuration I've used
babak.local
. you can use anything you want.don't worry you don't need to buy a domain name for that
after you apply terraform configuration on you aws you can copy your static website into the bucket
aws s3 sync staticSite s3://babak.local
with this command you copy all the files within the staticSite folder
you can find it with this formula below
http://bucket-name.s3-website-Region.amazonaws.com
for example here bucket-name is babak.local
and region is eu-west-1
so the url is
http://babak.local.s3-website-eu-west-1.amazonaws.com
this is very easy! just do the following steps
mkdir testFolder
cd testFolder
testFolder> touch main.tf
and add the following configuration to the main.tf
provider "aws" {
profile = "default"
region = "eu-west-1"
}
variable "domain_name" {
type = string
}
module "bucket-website" {
source = "babakDoraniArab/bucket-website/aws"
version = "1.0.3"
domain_name = var.domain_name
# please check the link below and use the latest version
# https://registry.terraform.io/modules/babakDoraniArab/bucket-website/aws/latest
}
terraform init
terraform fmt
terraform validate
terraform apply