bucket_id
ID (name) of the S3 bucket. Use this for SDK calls, CLI commands, and resource references that require the bucket name.
The unique identifier of the S3 bucket, which is the bucket name itself. Use this for SDK calls, CLI commands, and resource references that require the bucket name.
Example Value
my-app-data
Common Use Cases
S3 Object Resource
resource "aws_s3_object" "config" {
bucket = module.data_bucket.bucket_id
key = "config/settings.json"
source = "settings.json"
}
Lambda S3 Trigger
resource "aws_s3_bucket_notification" "lambda_trigger" {
bucket = module.data_bucket.bucket_id
lambda_function {
lambda_function_arn = module.processor.function_arn
events = ["s3:ObjectCreated:*"]
filter_prefix = "uploads/"
}
}
AWS CLI Reference
aws s3 ls s3://${module.data_bucket.bucket_id}
aws s3 cp file.txt s3://${module.data_bucket.bucket_id}/
CloudFront Origin
resource "aws_cloudfront_distribution" "cdn" {
origin {
origin_id = "s3-origin"
domain_name = "${module.data_bucket.bucket_id}.s3.amazonaws.com"
}
}
Usage
module "s3_bucket" {
source = "registry.patterneddesigns.ca/essentials/s3-bucket/aws"
version = "0.1.0"
# ... inputs
}
# Access this output
output "bucket_id" {
value = module.s3_bucket.bucket_id
}