Skip to content

Commit 318e76e

Browse files
committed
chore: configure routing rules in s3 website configuration
1 parent 97d6492 commit 318e76e

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

terraform/website/main.tf

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ resource "aws_s3_bucket_acl" "bucket" {
2828
acl = "public-read"
2929
}
3030

31+
# Configure website settings
3132
resource "aws_s3_bucket_website_configuration" "bucket" {
3233
bucket = aws_s3_bucket.bucket.id
3334

@@ -40,23 +41,25 @@ resource "aws_s3_bucket_website_configuration" "bucket" {
4041
}
4142

4243
routing_rules = jsonencode([
43-
{
44-
Condition {
45-
KeyPrefixEquals = "colorcop/download"
44+
{
45+
Condition = {
46+
KeyPrefixEquals = "colorcop/download"
47+
}
48+
Redirect = {
49+
ReplaceKeyWith = "download"
50+
HostName = var.domain
51+
}
52+
},
53+
{
54+
Condition = {
55+
KeyPrefixEquals = "colorcop/features"
56+
}
57+
Redirect = {
58+
ReplaceKeyWith = "features"
59+
HostName = var.domain
60+
}
4661
}
47-
Redirect {
48-
ReplaceKeyWith = "download"
49-
}
50-
},
51-
{
52-
Condition {
53-
KeyPrefixEquals = "colorcop/features"
54-
}
55-
Redirect {
56-
ReplaceKeyWith = "features"
57-
}
58-
}
59-
])
62+
])
6063
}
6164

6265
resource "aws_cloudfront_distribution" "distribution" {

0 commit comments

Comments
 (0)