Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.46 KB

README.md

File metadata and controls

42 lines (29 loc) · 1.46 KB

AWS Static Hosting

MIT license

This is a Terraform module for hosting a static bundle (i.e. static site or SPA) on AWS using S3 and CloudFront.

Inputs

See variables.tf.

Outputs

See output.tf.

Example

The following use of this module creates an S3 bucket named example.palmdrive.dev and an accompanying CloudFront distribution with the alias https://example.palmdrive.dev and an associated CloudFront function Example defined in ./ExampleViewerRequest.js that filters each request to the CloudFront distribution. Afterwards, navigating to https://example.palmdrive.dev serves the file index.html from the example.palmdrive.dev S3 bucket.

module "example" {
  source = "[email protected]:palm-drive/tf-aws-static-hosting.git"
  domain = "example.palmdrive.dev"
}

resource "aws_cloudfront_function" "example" {
  name    = "Example"
  runtime = "cloudfront-js-1.0"
  comment = "Example CloudFront viewer-request function"
  publish = true
  code    = file("${path.module}/ExampleViewerRequest.js")
}

License

This project is licensed under the terms of the MIT license.