S3 Express
Tradeoffs and How We Mitigate Them
Configuration
locals {
# S3 Express may not be available in every zone in a region. This
# is fine though because we don't get billed for inter-zone networking
# between EC2 and S3 Express buckets. You can see the list of available
# zone IDs here: https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Endpoints.html
s3_express_zones_ids = ["use1-az4", "use1-az5", "use1-az6"]
}
resource "aws_s3_directory_bucket" "warpstream_s3_express_buckets" {
count = length(local.s3_express_zones_ids)
# AZ has to be encoded in this exact format, see docs:
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_directory_bucket
bucket = "warpstream_s3_express--${local.s3_express_zones_ids[count.index]}--x-s3"
data_redundancy = "SingleAvailabilityZone"
type = "Directory"
location {
name = local.s3_express_zones_ids[count.index]
type = "AvailabilityZone"
}
}
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}
data "aws_iam_policy_document" "warpstream_s3_express_buckets" {
statement {
effect = "Allow"
actions = [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3express:CreateSession"
]
resources = concat([
for bucket in aws_s3_directory_bucket.warpstream_s3_express_buckets[*].bucket :
"arn:aws:s3express:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:bucket/${bucket}"
],
[
for bucket in aws_s3_directory_bucket.warpstream_s3_express_buckets[*].bucket :
"arn:aws:s3express:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:bucket/${bucket}/*"
]
)
}
}
resource "aws_iam_role_policy" "warpstream_s3_express_buckets" {
name = "warpstream-s3express"
role = "YOUR ROLE ID"
policy = data.aws_iam_policy_document.warpstream_s3_express_buckets.json
}Last updated
Was this helpful?