Skip to content

Terraform module creating a AWS Cloudfront distribution from AWS S3 hosting bucket. Custom domain is required to be provided

Notifications You must be signed in to change notification settings

Mich0232/aws-cloudfront-hosting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Cloudfront hosting

This package is a Terraform module, responsible for creating hosting from S3 bucket using AWS Cloudfront.
Hosted website can be access only over HTTPS.

You will need to provide the domain along with ACM certificate.

AWS Cloudfront

Provisioned resources

  • S3 Bucket (versioning: enabled; public access: blocked)
  • Cloudfront distribution

Input variables

aws_account_id - Your AWS Account ID

project_name - Custom project name (will be used as a prefix in resources)

domain - Domain name.

domain_certificate_arn - SSL Certificate issued for domain provided above.

⚠️ Certificate must be issued in the us-east-1 region!

root_object - file used as entry (default: index.html)

price_class - AWS Cloudfront price class (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PriceClass.html) (default: PriceClass_100)

allowed_methods - Allowed HTTP methods. (default: GET; HEAD)

cached_methods - Cached HTTP methods. (default: GET; HEAD)

tags - Tags passed to the resources.

Output variables:

domain_name - Hosting domain name (domain issued by CF, can be used in R53)

hosted_zone_id - Hosted zone of CF domain.

Example

module "hosting" {
  source = "https://github.com/Mich0232/aws-cloudfront-hosting.git"

  project_name           = "myProject"
  aws_account_id         = var.aws_account_id
  domain                 = "https://mydomain.com"
  domain_certificate_arn = aws_acm_certificate_validation.main.certificate_arn
}

About

Terraform module creating a AWS Cloudfront distribution from AWS S3 hosting bucket. Custom domain is required to be provided

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages