Improving dependency chaingin slightly however more will stablize the race condition problem here in this folder

This commit is contained in:
shockrah 2023-10-05 23:12:39 -07:00
parent b6aebf06b1
commit df2406720f
3 changed files with 11 additions and 10 deletions

View File

@ -2,7 +2,7 @@ plan=out.plan
SHELL := /bin/bash SHELL := /bin/bash
$(plan): *.tf $(plan):
source ../secrets/set-env.sh && terraform plan -input=false -out $(plan) source ../secrets/set-env.sh && terraform plan -input=false -out $(plan)
push: build push: build

View File

@ -1,7 +1,8 @@
locals { locals {
buckets = [ buckets = [
"shockrah.xyz", "shockrah.xyz",
"resume.shockrah.xyz" "resume.shockrah.xyz",
"temper.tv"
] ]
} }

View File

@ -7,8 +7,8 @@
# Enables website configuration # Enables website configuration
resource "aws_s3_bucket_website_configuration" "site" { resource "aws_s3_bucket_website_configuration" "site" {
for_each = toset(local.buckets) for_each = aws_s3_bucket.static-content
bucket = each.value bucket = each.value.bucket
index_document { index_document {
suffix = "index.html" suffix = "index.html"
} }
@ -20,8 +20,8 @@ resource "aws_s3_bucket_website_configuration" "site" {
# Set block public access to false # Set block public access to false
resource "aws_s3_bucket_public_access_block" "site" { resource "aws_s3_bucket_public_access_block" "site" {
for_each = toset(local.buckets) for_each = aws_s3_bucket.static-content
bucket = each.value bucket = each.value.bucket
block_public_acls = false block_public_acls = false
block_public_policy = false block_public_policy = false
@ -30,8 +30,8 @@ resource "aws_s3_bucket_public_access_block" "site" {
} }
# Set a policy on the bucket to allow reads from anywhere # Set a policy on the bucket to allow reads from anywhere
resource "aws_s3_bucket_policy" "site" { resource "aws_s3_bucket_policy" "site" {
for_each = toset(local.buckets) for_each = aws_s3_bucket.static-content
bucket = each.value bucket = each.value.bucket
policy = jsonencode({ policy = jsonencode({
Version = "2012-10-17" Version = "2012-10-17"
Statement = [ Statement = [
@ -41,8 +41,8 @@ resource "aws_s3_bucket_policy" "site" {
Principal = "*" Principal = "*"
Action = "s3:GetObject" Action = "s3:GetObject"
Resource = [ Resource = [
"arn:aws:s3:::${each.value}", "arn:aws:s3:::${each.value.bucket}",
"arn:aws:s3:::${each.value}/*", "arn:aws:s3:::${each.value.bucket}/*",
] ]
} }
] ]