Skip to main content
This page documents every output value exported by the terraform-aws-s3-bucket module. Use these outputs to reference bucket attributes in other Terraform resources and modules.

Bucket Identity

s3_bucket_id
string
The name of the bucket. For directory buckets, this returns the directory bucket name.
s3_bucket_arn
string
The ARN of the bucket. Will be of format arn:aws:s3:::bucketname.
s3_bucket_region
string
The AWS region this bucket resides in.
s3_bucket_tags
map(string)
Tags assigned to the bucket.

Domain Names

s3_bucket_bucket_domain_name
string
The bucket domain name. Will be of format bucketname.s3.amazonaws.com.
s3_bucket_bucket_regional_domain_name
string
The bucket region-specific domain name, including the region name in the URL. Use this with AWS CloudFront to avoid redirect issues when specifying an S3 region-specific endpoint as a CloudFront origin.
s3_bucket_hosted_zone_id
string
The Route 53 Hosted Zone ID for this bucket’s region. Useful for creating Route 53 alias records pointing to the bucket.

Configuration State

s3_bucket_lifecycle_configuration_rules
any
The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. Returns an empty string if no lifecycle configuration is present.
s3_bucket_policy
string
The policy of the bucket, if the bucket is configured with a policy. Returns an empty string if no policy is attached.
aws_s3_bucket_versioning_status
string
The versioning status of the bucket. Will be Enabled, Suspended, or Disabled.

Website

s3_bucket_website_endpoint
string
The website endpoint, if the bucket is configured with a website. Returns an empty string if the bucket is not configured for static website hosting.
s3_bucket_website_domain
string
The domain of the website endpoint, if the bucket is configured with a website. Returns an empty string if not configured. Used to create Route 53 alias records.

Directory Bucket

The following outputs are only populated when is_directory_bucket = true.
s3_directory_bucket_name
string
Name of the directory bucket. Returns null if no directory bucket was created.
s3_directory_bucket_arn
string
ARN of the directory bucket. Returns null if no directory bucket was created.

Usage Example

Reference outputs from this module in other resources:
module "s3_bucket" {
  source = "terraform-aws-modules/s3-bucket/aws"

  bucket = "my-app-bucket"

  versioning = {
    enabled = true
  }
}

# Reference the bucket ID in another resource
resource "aws_cloudfront_distribution" "this" {
  origin {
    domain_name = module.s3_bucket.s3_bucket_bucket_regional_domain_name
    origin_id   = module.s3_bucket.s3_bucket_id
  }
  # ...
}

# Reference the hosted zone ID for Route 53 alias records
resource "aws_route53_record" "website" {
  zone_id = data.aws_route53_zone.this.zone_id
  name    = "www"
  type    = "A"

  alias {
    name                   = module.s3_bucket.s3_bucket_website_endpoint
    zone_id                = module.s3_bucket.s3_bucket_hosted_zone_id
    evaluate_target_health = false
  }
}

Build docs developers (and LLMs) love