Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.83 KB

File metadata and controls

54 lines (42 loc) · 1.83 KB

terraform-aws-cloudfront-s3-website

Terraform module for creating an s3 static website with Cloudfront distribution

The following resources will be created

  • S3 Bucket
  • CloudFront distribution
  • Route53 record
  • Upload sample HTML file (optional)

Prerequisites (Optional in example2):

  • Route 53 hosted zone for example.com
  • ACM certificate for *.example.com in us-east-1 region

Example 1

provider "aws" {
  region = "us-east-1"
}

module "cloudfront_s3_website_with_domain" {
    source                 = "chgangaraju/cloudfront-s3-website/aws"
    version                = "1.2.6"
    hosted_zone            = "example.com" 
    domain_name            = "test.abc.example.com"
    acm_certificate_domain = "*.abc.example.com"
    upload_sample_file     = true
}

Example 2

module "cloudfront_s3_website_without_domain" {
    source                 = "chgangaraju/cloudfront-s3-website/aws"
    version                = "1.2.6"
    domain_name            = "test-application-1232" // Any random identifier for s3 bucket name
    use_default_domain     = true
    upload_sample_file     = true
}

Cloudfront TTL settings

        # optional values
        cloudfront_min_ttl     = 10
        cloudfront_default_ttl = 1400
        cloudfront_max_ttl     = 86400