Skip to content

Commit 0f78f1f

Browse files
authored
✨ feature: Add SPA error handling and upgrade to AWS provider 6.x (#63)
1 parent 862f7f3 commit 0f78f1f

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

aws-cloudfront.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ resource "aws_cloudfront_distribution" "site" {
3434
}
3535
}
3636

37+
dynamic "custom_error_response" {
38+
for_each = var.enable_spa_error_handling ? toset(["403", "404"]) : []
39+
content {
40+
error_code = each.value
41+
response_code = 200
42+
response_page_path = format("/%s", coalesce(var.default_root_object, "index.html"))
43+
}
44+
}
45+
3746
restrictions {
3847
geo_restriction {
3948
restriction_type = "none"

aws-route53.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_route53_record" "alias" {
2-
for_each = toset(flatten([[module.label_site.dns_name], var.extra_domain_prefixes]))
2+
for_each = toset(flatten([[local.default_alias], var.extra_domain_prefixes]))
33
name = each.key
44
type = "A"
55
zone_id = var.domain_zone_id

examples/simple/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
aws = {
55
source = "hashicorp/aws"
6-
version = "~> 5.0"
6+
version = "~> 6.0"
77
}
88
}
99
}

test/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ require (
103103
github.com/spf13/pflag v1.0.6 // indirect
104104
github.com/stretchr/testify v1.10.0 // indirect
105105
github.com/tmccombs/hcl2json v0.6.7 // indirect
106-
github.com/ulikunitz/xz v0.5.12 // indirect
106+
github.com/ulikunitz/xz v0.5.15 // indirect
107107
github.com/urfave/cli/v2 v2.27.6 // indirect
108108
github.com/x448/float16 v0.8.4 // indirect
109109
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect

test/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ github.com/tmccombs/hcl2json v0.6.7 h1:RYKTs4kd/gzRsEiv7J3M2WQ7TYRYZVc+0H0pZdERk
218218
github.com/tmccombs/hcl2json v0.6.7/go.mod h1:lJgBOOGDpbhjvdG2dLaWsqB4KBzul2HytfDTS3H465o=
219219
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
220220
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
221+
github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
222+
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
221223
github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g=
222224
github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
223225
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ variable "function_associations" {
6565
description = "A config block that triggers a lambda function with specific actions (maximum 4)."
6666
nullable = false
6767
}
68+
69+
variable "enable_spa_error_handling" {
70+
type = bool
71+
default = false
72+
description = "Enable SPA error handling by redirecting 403 errors to / with 200 status code."
73+
nullable = false
74+
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
aws = {
55
source = "hashicorp/aws"
6-
version = "~> 5.0"
6+
version = "~> 6.0"
77
configuration_aliases = [aws.route53]
88
}
99
}

0 commit comments

Comments
 (0)