Skip to content

nsbno/terraform-aws-multi-domain-static-site

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Domain Static Site

Host static frontend applications on AWS using CloudFront and S3.

This module creates a complete infrastructure for hosting static sites including ACM certificates, CloudFront distribution with Origin Access Control (OAC), and optionally an S3 bucket.

Usage

Remember to check out the variables and outputs to see all options.

Important
CloudFront distributions can take 15-30 minutes to deploy or update.

Basic Usage

module "static_site" {
  source = "github.com/nsbno/terraform-aws-multi-domain-static-site?ref=x.y.z"

  service_name = "petstore"

  domain_name = {
    name = "petstore.test.infrademo.vydev.io"
    zone = data.aws_route53_zone.main.name
  }
}

External Bucket

module "static_site" {
  source = "github.com/nsbno/terraform-aws-multi-domain-static-site?ref=x.y.z"

  service_name = "petstore"

  domain_name = {
    name = "petstore.test.infrademo.vydev.io"
    zone = data.aws_route53_zone.main.name
  }

  use_external_bucket = true
  website_bucket      = aws_s3_bucket.existing.id
}

Examples

These examples show you how to use this module in different configurations.

A simple single-domain static site setup.

Using multiple domains with subject alternative names (SANs).

Bring your own S3 bucket instead of creating a new one.

Configure cache TTL settings and CloudFront price class.

Upgrading from V1

V1 of this module uses Origin Access Identity (OAI) for CloudFront to access the S3 bucket.
V2 uses the newer Origin Access Control (OAC) which provides better security and performance.

To upgrade from V1 to V2, follow these steps:

  • Add this variable to the module:

keep_oai_for_migration = true

and run Terraform apply once to create the OAC while keeping the OAI for migration.

  • Remove or set variable to false:

keep_oai_for_migration = false

About

Create infrastructure for hosting a static website (SPA) with a domain

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages