Provides details about a specific S3 bucket.
This resource may prove useful when setting up a Route53 record, or an origin for a CloudFront Distribution.
data "aws_s3_bucket" "selected" {
bucket = "bucket.test.com"
}
data "aws_route53_zone" "test_zone" {
name = "test.com."
}
resource "aws_route53_record" "example" {
zone_id = data.aws_route53_zone.test_zone.id
name = "bucket"
type = "A"
alias {
name = data.aws_s3_bucket.selected.website_domain
zone_id = data.aws_s3_bucket.selected.hosted_zone_id
}
}
data "aws_s3_bucket" "selected" {
bucket = "a-test-bucket"
}
resource "aws_cloudfront_distribution" "test" {
origin {
domain_name = data.aws_s3_bucket.selected.bucket_domain_name
origin_id = "s3-selected-bucket"
}
}
This data source supports the following arguments:
bucket
- (Required) Name of the bucketThis data source exports the following attributes in addition to the arguments above:
id
- Name of the bucket.arn
- ARN of the bucket. Will be of format arn:aws:s3:::bucketname
.bucket_domain_name
- Bucket domain name. Will be of format bucketname.s3.amazonaws.com
.bucket_regional_domain_name
- The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.hosted_zone_id
- The Route 53 Hosted Zone ID for this bucket's region.region
- AWS region this bucket resides in.website_endpoint
- Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.website_domain
- Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.