cloudmaniac / terraform-aws-static-website

Terraform Module to provision an AWS static website using Route53, S3, and CloudFront.
https://registry.terraform.io/modules/cloudmaniac/static-website/aws/
MIT License
48 stars 38 forks source link

Feature request - discussion #13

Open iongion opened 1 year ago

iongion commented 1 year ago

Highly appreciative of this module!

This is not a bug, more like a question for those new to terraform. I want to be able to have multiple subdomains provisioned just as the main domain. Each will host its own SPA application.

The domain: fx.domain

The apps

Will this create the following buckets ?

With their log buckets, together with the main fx.domain bucket ?

provider "aws" {
  region                  = "us-east-1"
  shared_credentials_file = "~/.aws/credentials_fxdomain"
}

module "aws_static_website_main" {
  source = "cloudmaniac/static-website/aws"
  # This is the domain as defined in Route53
  domains-zone-root = "fx.domain"
  # Pretty URL support using 404 redirect to index.html
  support-spa = true
  # Domains used for CloudFront
  website-domain-main        = "fx.domain"
  website-domain-redirect    = "www.fx.domain"
  website-additional-domains = []
}

module "aws_static_website_app1" {
  source = "cloudmaniac/static-website/aws"
  domains-zone-root = "fx.domain"
  support-spa = true
  website-domain-main = "app1.fx.domain"
}

module "aws_static_website_app2" {
  source = "cloudmaniac/static-website/aws"
  domains-zone-root = "fx.domain"
  support-spa = true
  website-domain-main = "app2.fx.domain"
}

Also, do you have a recommended way to have domains and buckets for environments, such as production, staging, development ?

enjoy2000 commented 1 year ago

I think we can achieve this by exposing variables and output for the website_logs bucket. Then you can reuse it from your main app. I'm curious, why do you need to reuse log buckets?