From f136c4cfb66f3cb8dcc3669d4a4669b7844b81e5 Mon Sep 17 00:00:00 2001 From: j4y <36337+j4y@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:00:14 -0500 Subject: [PATCH] chore: configure routing rules in s3 website configuration --- terraform/website/main.tf | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/terraform/website/main.tf b/terraform/website/main.tf index 815ea0d..0a21402 100644 --- a/terraform/website/main.tf +++ b/terraform/website/main.tf @@ -28,6 +28,7 @@ resource "aws_s3_bucket_acl" "bucket" { acl = "public-read" } +# Configure website settings resource "aws_s3_bucket_website_configuration" "bucket" { bucket = aws_s3_bucket.bucket.id @@ -40,23 +41,25 @@ resource "aws_s3_bucket_website_configuration" "bucket" { } routing_rules = jsonencode([ - { - Condition { - KeyPrefixEquals = "colorcop/download" + { + Condition = { + KeyPrefixEquals = "colorcop/download" + } + Redirect = { + ReplaceKeyWith = "download" + HostName = var.domain + } + }, + { + Condition = { + KeyPrefixEquals = "colorcop/features" + } + Redirect = { + ReplaceKeyWith = "features" + HostName = var.domain + } } - Redirect { - ReplaceKeyWith = "download" - } - }, - { - Condition { - KeyPrefixEquals = "colorcop/features" - } - Redirect { - ReplaceKeyWith = "features" - } - } -]) + ]) } resource "aws_cloudfront_distribution" "distribution" {