From cd0e3a71b09a5a356c7500468c17fece16348f61 Mon Sep 17 00:00:00 2001 From: Robert Fairhead Date: Thu, 23 May 2019 08:19:56 -0500 Subject: [PATCH] Saber (#36) * Fix static db parameters * Fix underscore to hyphen typo * Direct to index.html on errors to support react router --- database/main.tf | 10 ++++++---- static_site/main.tf | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/database/main.tf b/database/main.tf index f63288f..3cd448a 100644 --- a/database/main.tf +++ b/database/main.tf @@ -111,8 +111,9 @@ resource "aws_db_parameter_group" "postgres" { # Enable pg_stat_statements for extra analytics parameter { - name = "shared_preload_libraries" - value = "pg_stat_statements" + name = "shared_preload_libraries" + value = "pg_stat_statements" + apply_method = "pending-reboot" } parameter { @@ -121,8 +122,9 @@ resource "aws_db_parameter_group" "postgres" { } parameter { - name = "track_activity_query_size" - value = "2048" + name = "track_activity_query_size" + value = "2048" + apply_method = "pending-reboot" } } diff --git a/static_site/main.tf b/static_site/main.tf index a31c669..db0fbc5 100644 --- a/static_site/main.tf +++ b/static_site/main.tf @@ -52,9 +52,10 @@ resource "aws_s3_bucket" "site_content_bucket" { } POLICY + # Serve index.html on errors to support client side routing, e.g. React Router website { index_document = "index.html" - error_document = "error.html" + error_document = "index.html" } tags { @@ -77,6 +78,19 @@ resource "aws_cloudfront_distribution" "s3_distribution" { aliases = ["${var.subdomain}.${var.domain_name}"] + # Serve index.html on errors to support client side routing, e.g. React Router + custom_error_response { + error_code = 403 + response_code = 200 + response_page_path = "/index.html" + } + + custom_error_response { + error_code = 404 + response_code = 200 + response_page_path = "/index.html" + } + default_cache_behavior { allowed_methods = ["GET", "HEAD", "OPTIONS"] cached_methods = ["GET", "HEAD"] @@ -155,9 +169,10 @@ resource "aws_s3_bucket" "preview" { } POLICY + # Serve index.html on errors to support client side routing, e.g. React Router website { index_document = "index.html" - error_document = "error.html" + error_document = "index.html" } tags {