Skip to content

Terraform module that creates a CloudFront distribution and S3 bucket. Optionally, the website can be protected by OpenID Connect.

Notifications You must be signed in to change notification settings

chatloop/terraform-aws-static-site

Repository files navigation

Terraform AWS Static Site

This module provisions a static website using CloudFront+S3. Optionally, the website can be protected with OpenID Connect.

Usage

module "static_site" {
  source = "github.com/chatloop/terraform-aws-static-site?ref=v0.3.0"

  providers = {
    aws.us-east-1 = aws.us-east-1
  }

  acm_certificate_name = "example.com"
  domain_name          = "static-site-test.example.com"
  name                 = "terraform-aws-static-site"
  route53_zone_name    = "example.com"
}

Requirements

Name Version
terraform ~> 1.0
aws ~> 5.0
random ~> 3.0

Providers

Name Version
aws 5.69.0
aws.us-east-1 5.69.0
random 3.6.3

Modules

Name Source Version
authorizer github.com/chatloop/terraform-aws-cloudfront-auth 695c3eb440a90e2441a006f9d091e6f73218fb0d
cloudfront github.com/terraform-aws-modules/terraform-aws-cloudfront a0f0506106a4c8815c1c32596e327763acbef2c2
s3_bucket github.com/terraform-aws-modules/terraform-aws-s3-bucket 8a0b697adfbc673e6135c70246cff7f8052ad95a

Resources

Name Type
aws_route53_record.this resource
random_string.refer_secret resource
aws_acm_certificate.this data source
aws_iam_policy_document.s3_policy data source
aws_iam_policy_document.s3_policy_cloudfront_oac data source
aws_iam_policy_document.s3_policy_website_endpoint data source
aws_route53_zone.this data source

Inputs

Name Description Type Default Required
acm_certificate_name n/a string n/a yes
authorizer n/a
object({
function_name = optional(string)
tenant = string
client_id = string
client_secret = string
redirect_uri = optional(string)

session_duration = optional(number)

trailing_slash_redirects_enabled = optional(bool)

simple_urls_enabled = optional(bool)
})
null no
bucket_name n/a string null no
comment n/a string null no
custom_error_response n/a
list(object({
error_code = number
response_code = number
response_page_path = optional(string)
error_caching_min_ttl = optional(number)
}))
[] no
default_cache_behavior n/a
object({
allowed_methods = optional(list(string), ["GET", "HEAD", "OPTIONS"])
cached_methods = optional(list(string), ["GET", "HEAD", "OPTIONS"])
compress = optional(bool, true)
cache_policy_id = optional(string)
cache_policy_name = optional(string, "Managed-CachingOptimized")
origin_request_policy_id = optional(string)
origin_request_policy_name = optional(string, "Managed-CORS-S3Origin")
response_headers_policy_id = optional(string)
response_headers_policy_name = optional(string, "Managed-SecurityHeadersPolicy")
target_origin_id = optional(string)
use_authorizer = optional(bool, true)
viewer_protocol_policy = optional(string, "redirect-to-https")
})
{} no
default_root_object n/a string "index.html" no
domain_name n/a string n/a yes
name n/a string n/a yes
ordered_cache_behavior n/a
list(object({
allowed_methods = optional(list(string), ["GET", "HEAD", "OPTIONS"])
cached_methods = optional(list(string), ["GET", "HEAD", "OPTIONS"])
compress = optional(bool, true)
cache_policy_id = optional(string)
cache_policy_name = optional(string, "Managed-CachingOptimized")
origin_request_policy_id = optional(string)
origin_request_policy_name = optional(string, "Managed-CORS-S3Origin")
path_pattern = string
response_headers_policy_id = optional(string)
response_headers_policy_name = optional(string, "Managed-SecurityHeadersPolicy")
target_origin_id = optional(string)
use_authorizer = optional(bool, true)
viewer_protocol_policy = optional(string, "redirect-to-https")
}))
[] no
route53_zone_name n/a string n/a yes
website_configuration n/a
object({
index_document = string
})
null no

Outputs

No outputs.

About

Terraform module that creates a CloudFront distribution and S3 bucket. Optionally, the website can be protected by OpenID Connect.

Resources

Stars

Watchers

Forks

Packages

No packages published