temper-tv/infra/s3.tf

57 lines
1.3 KiB
Terraform
Raw Normal View History

2023-10-02 02:17:38 +00:00
resource "aws_s3_bucket" "website" {
bucket = "temper.tv"
tags = {
Name = "temper.tv"
Description = "Static content for temper.tv"
}
}
###############################################################
# Below are the acl components for the bucket to make it public
###############################################################
# Enables website configuration
resource "aws_s3_bucket_website_configuration" "site" {
bucket = aws_s3_bucket.website.bucket
index_document {
suffix = "index.html"
}
error_document {
key = "404.html"
}
}
# Set block public access to false
resource "aws_s3_bucket_public_access_block" "site" {
bucket = aws_s3_bucket.website.bucket
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
# Set a policy on the bucket to allow reads from anywhere
resource "aws_s3_bucket_policy" "site" {
bucket = aws_s3_bucket.website.bucket
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "PublicReadGetObject"
Effect = "Allow"
Principal = "*"
Action = "s3:GetObject"
Resource = [
"arn:aws:s3:::${aws_s3_bucket.website.bucket}",
"arn:aws:s3:::${aws_s3_bucket.website.bucket}/*",
]
}
]
})
}