Skip to content

mediapop/terraform-aws-staticsite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-staticsite

Creates an AWS S3 bucket configured for website hosting and request logging.

Example Usage

locals {
  domain = "example.com"
}

module "staticsite" {
  source = "github.com/justincampbell/terraform-aws-staticsite"

  bucket = "www.${local.domain}"
  domain = "${local.domain}"
}
$ terraform init
$ terraform plan

Then, you can use the outputs for whichever DNS provider you use.

For example, to configure DNSimple to point to this static site:

resource "dnsimple_record" "apex" {
  domain = "${local.domain}"
  name   = ""
  type   = "ALIAS"
  value  = "${module.terraform-s3-website.website_endpoint}"
}

resource "dnsimple_record" "www" {
  domain = "${local.domain}"
  name   = "www"
  type   = "URL"
  value  = "http://${local.domain}"
}

Or, to configure an apex domain (without a www/hostname):

module "staticsite" {
  source = "github.com/justincampbell/terraform-aws-staticsite"

  bucket = "${local.domain}"
  domain = "${local.domain}"
}

resource "dnsimple_record" "apex" {
  domain = "${local.domain}"
  name   = ""
  type   = "ALIAS"
  value  = "${module.staticsite.website_endpoint}"
}

# Redirect www to the root domain
resource "dnsimple_record" "www" {
  domain = "${local.domain}"
  name   = "www"
  type   = "URL"
  value  = "http://${local.domain}"
}

About

Terraform module for an S3 website, logging, and DNSimple records

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%