TerraShelf

Catalog · Web · v1.1.0

s3-static-site

Private S3 origin, CloudFront origin access control, and optional access logs.

Tests passed 6 of 6. Failed 0.

Inputs

NameTypeRequiredDescription
access_log_expiration_daysnumbernoDays to keep objects in the module-managed access log bucket.
access_logs_bucket_namestringnoExisting bucket name that receives CloudFront access logs. Null creates a bucket when enable_access_logs is true.
aliaseslist(string)noAlternate domain names on the distribution. Must be empty unless certificate_arn is set.
certificate_arnstringnoOptional ACM certificate ARN. Required when aliases is not empty. CloudFront accepts that certificate only from its global control-plane region.
commentstringnoComment stored on the CloudFront distribution.
default_root_objectstringnoObject CloudFront returns when a viewer requests the root of the distribution.
domain_namestringnoDNS name for the optional Route 53 alias. Null skips the record. When set, it must also be one of aliases.
enable_access_logsboolnoWrite CloudFront standard access logs. Added in 1.1.0. Off by default.
geo_restriction_locationslist(string)noTwo-letter country codes used when geo_restriction_type is not none.
geo_restriction_typestringnoCloudFront geographic restriction type.
kms_key_arnstringnoOptional customer managed key ARN for site bucket encryption. Null uses SSE-S3.
name_prefixstringyesLowercase prefix for the bucket, origin access control, and response headers policy. The module appends a short suffix. Do not encode an environment name here.
price_classstringnoCloudFront price class name. This selects an edge set. It is not a currency amount.
route53_zone_idstringnoHosted zone id for the optional alias record. Set this together with domain_name. Null skips the record.
tagsmap(string)noExtra tags merged onto every taggable resource. ManagedBy and Module are always set by the module.
versioning_enabledboolnoEnable versioning on the site bucket.
web_acl_idstringnoOptional WAFv2 web ACL ARN attached to the distribution. Null leaves WAF off.

Outputs

NameDescription
access_logs_enabledWhether CloudFront standard logging is configured.
alias_record_countNumber of Route 53 alias records managed by this module.
bucket_arnARN of the private site bucket.
bucket_nameName of the private site bucket.
bucket_policy_actionsActions allowed by the site bucket policy. The policy document uses this list and no other actions.
bucket_policy_condition_keysCondition keys on the site bucket policy. AWS:SourceArn is set to this distribution's ARN.
bucket_policy_principal_serviceService principal allowed by the site bucket policy.
bucket_policy_statement_countNumber of statements written into the site bucket policy.
caller_contextAccount, partition, and region resolved from data sources. Nothing in the module hardcodes them.
default_root_objectDefault root object configured on the distribution.
distribution_arnCloudFront distribution ARN.
distribution_domain_nameDomain name assigned to the CloudFront distribution.
distribution_idCloudFront distribution id.
log_bucket_createdTrue when this module creates the access log bucket.
oac_origin_typeOrigin type on the CloudFront origin access control. s3 means the distribution is not using a legacy origin access identity.
oac_signing_behaviorSigning behavior on the origin access control.
oac_signing_protocolSigning protocol on the origin access control.
origin_access_control_idOrigin access control id attached to the S3 origin.
origin_idsOrigin ids on the distribution. The S3 origin is s3-site and references the origin access control.
public_access_blockFour public access block flags on the site bucket.
tag_auditTags on every taggable resource this module creates.
versioning_statusVersioning status of the site bucket.
viewer_protocol_policyViewer protocol policy on the default cache behavior.

Example

The caller supplies the region. This example does not embed an account id.

module "site" {
  source = "../.."

  name_prefix = "demo-site"
  tags = {
    Example = "basic"
  }
}

Tests

Mock plan excerpt

mocked provider: ARNs and IDs are simulated. This excerpt is from terraform test with a mocked provider, not a live plan.

mocked provider: ARNs and IDs are simulated. This is terraform test -verbose, not a live plan.

tests\s3-static-site.tftest.hcl... in progress
  run "private_oac"... pass

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_cloudfront_distribution.site will be created
  + resource "aws_cloudfront_distribution" "site" {
      + aliases                         = []
      + arn                             = (known after apply)
      + caller_reference                = (known after apply)
      + comment                         = "Private S3 origin behind CloudFront origin access control."
      + continuous_deployment_policy_id = (known after apply)
      + default_root_object             = "index.html"
      + domain_name                     = (known after apply)
      + enabled                         = true
      + etag                            = (known after apply)
      + hosted_zone_id                  = (known after apply)
      + id                              = (known after apply)
      + in_progress_validation_batches  = (known after apply)
      + is_ipv6_enabled                 = true
      + last_modified_time              = (known after apply)
      + price_class                     = "PriceClass_100"
      + status                          = (known after apply)
      + tags                            = {
          + "ManagedBy" = "terraform"
          + "Module"    = "s3-static-site"
          + "Owner"     = "platform"
        }
      + tags_all                        = (known after apply)
      + trusted_key_groups              = (known after apply)
      + trusted_signers                 = (known after apply)

      + default_cache_behavior {
          + allowed_methods            = [

Resources

graphviz dot was not installed. The figure is a python-hcl2 resource list.

Resource list for s3-static-site

Changelog

Changelog

All notable changes to this module are documented in this file.

The format is based on Keep a Changelog, and this module uses Semantic Versioning.

[1.1.0] - 2026-10-03

Added

[1.0.0] - 2026-10-03

Added

Billable item names

Names only. This page does not quote a price. Example amounts, including a budget limit, are placeholders and are not recommendations. GuardDuty and Security Hub stay off unless a module switch is set, because those services are billable.