Skip to content

Provision a static website hosted through S3 + CloudFront + Route53 in AWS

License

Notifications You must be signed in to change notification settings

meero-com/terraform-aws-static-website

 
 

Repository files navigation

GitHub

terraform-aws-static-website

Provision a static website hosted through S3 + CloudFront in AWS

Usage

module "website" {
  source = "realglobe-Inc/static-website/aws"
  version = "2.0.0"
  service_name = "your-service-name"
  aws_profile = "aws-profile-name"
  domain_names = list("foo.example.com", "bar.example.com")
  route53_zone_id = "ZXXXXXXXXXXXXX"
  s3_bucket_name = "your-s3-web-bucket"
  cloudfront_origin_path = "/dev" # optional
  save_access_log = true  # optional
}

Output CroudFront cache invalidation command.

output "cache_invalidation_command" {
  value = module.website.cache_invalidation_command
}

Create or switch workspace and apply.

$ terraform init
$ terraform workspace new development
$ terraform apply

Upload assets to S3.

$ aws s3 sync path/to/website/assets s3://your-s3-web-bucket/development/ --profile aws-profile-name

Then, access to your web site https://foo.example.com.

If responce is cached, invalidate CloudFront edge caches.

$ terraform output cache_invalidation_command
# Copy and paste printed command, overwrite paths and run.

About

Provision a static website hosted through S3 + CloudFront + Route53 in AWS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%