Skip to content

mcevoypeter/tf-aws-static-hosting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Languages