Terraform script to create infrastructure for static site hosting using S3 + Cloudfront + Route 53 Records
- update Provider with AWS REGION and AWS PROFILE
versions.tf
file
provider "aws" {
region = "us-east-1"
profile = "default"
}
- Update Variables default values in
variables.tf
file
variable "s3_bucket_name_for_hosting" {
type = string
description = "S3 bucket name for hosting code artifacts"
default = "s3_bucket_for_hosting_with_tf"
}
variable "aws_route53_record_name" {
type = string
description = "Route53 record name"
default = "dev.example.com"
}
variable "aws_route53_zone_id" {
type = string
description = "Route53 Zone ID"
default = ""
}
- Plan and Apply terraform
- Upload your artifacts to the newly created S3 bucket root folder
aws s3 sync /build .