This module creates and manages Static Site hosting on AWS, mainly using S3 and Cloudfront.
Example module usage:
# Because this module _might_ utilise CloudFront resources,
# which are required to be launched in the us-east-1 region,
# an AWS provider with the 'us-east-1' region must be provided
#
# It's not yet possible to conditionally require a regional AWS provider
provider "aws" {
region = "us-east-1"
alias = "useast1"
}
module "static_site_hosting" {
source = "github.com/chris-qa-org/terraform-aws-static-site-hosting?ref=v0.1.0"
project_name = "my-project"
# site_host_name = ""
# providers = {
# aws.useast1 = aws.useast1
# }
# static_site_s3_acl = "private"
# static_site_s3_enable_encryption = true
# enable_s3_access_logs = false
# s3_static_site_force_destroy = false
# s3_logs_force_destroy = false
# enable_cloudfront = true
# cloudfront_static_site_web_acl_id = null
# cloudfront_static_site_tls_certificate_arn = ""
# cloudfront_static_site_default_cache_behaviour = {}
# cloudfront_static_site_custom_error_responses = {
# "404" = {
# response_code = "404",
# response_page_path = "/404.html"
# }
# }
# cloudfront_static_site_default_root_object = "index.html"
# cloudfront_static_site_price_class = "PriceClass_100"
# cloudfront_static_site_restrictions = {
# geo_restriction = {
# restriction_type = "none"
# locations = []
# }
# }
# cloudfront_static_site_is_ipv6_enabled = true
# cloudfront_static_site_http_version = "http2"
# enable_cloudfront_static_site_logs = true
}
Name | Version |
---|---|
terraform | >= 1.4.4 |
aws | >= 4.64.0 |
Name | Version |
---|---|
aws | 4.64.0 |
aws.useast1 | 4.64.0 |
Name | Description | Type | Default | Required |
---|---|---|---|---|
cloudfront_static_site_custom_error_responses | CloudFront Static Site custom error responses | map(object({ |
{ |
no |
cloudfront_static_site_default_cache_behaviour | Default cache behaviour block for the Static Site CloudFront Distribution | object({ |
{} |
no |
cloudfront_static_site_default_root_object | CloudFront Static Site default root object | string |
"index.html" |
no |
cloudfront_static_site_http_version | CloudFront Static Site http version | string |
"http2" |
no |
cloudfront_static_site_is_ipv6_enabled | CloudFront Static Site enable ipv6 | bool |
true |
no |
cloudfront_static_site_price_class | CloudFront Static Site price class | string |
"PriceClass_100" |
no |
cloudfront_static_site_restrictions | Cloudfront Static Site restrictions block | object({ |
{ |
no |
cloudfront_static_site_tls_certificate_arn | CloudFront static site TLS Certificate ARN. This is not required, as one will be created based on the site_url . Use this only if the created certificate is not sufficient. |
string |
"" |
no |
cloudfront_static_site_web_acl_id | CloudFront static site Web ACL id | string |
null |
no |
enable_cloudfront | Enable creation of CloudFront Distribution | bool |
true |
no |
enable_cloudfront_static_site_logs | Enable CloudFront Staci Site logging to the logs bucket | bool |
true |
no |
enable_s3_access_logs | Enable S3 access logs | bool |
true |
no |
project_name | Project Name | string |
n/a | yes |
route53_zone_id | Route53 zone id. If provided, the certificate validation records and site records will be created in that zone | string |
"" |
no |
s3_logs_force_destroy | Force destroy Logs S3 bucket | bool |
false |
no |
s3_static_site_force_destroy | Force destroy Static Site S3 bucket | bool |
false |
no |
site_host_name | Site Host Name. This will be used for Certificate generation and CloudFront aliases | string |
"" |
no |
site_redirect_to_www | Conditionally redirect to www.<site_host_name> | bool |
false |
no |
static_site_s3_acl | Static Site S3 ACL | string |
"private" |
no |
static_site_s3_enable_encryption | Static Site S3 Enable Encyption | bool |
true |
no |
Name | Description |
---|---|
aws_s3_bucket_logs | The Logs S3 resource |
aws_s3_bucket_static_site | The Static Site S3 resource |