wellcomecollection / wellcomecollection.org

🪟 Wellcome Collection's website and services that support it
https://wellcomecollection.org
MIT License
39 stars 5 forks source link

Add CloudFront distro to front requests to rss.wellcomecollection.org #10988

Closed kenoir closed 2 months ago

kenoir commented 3 months ago

What does this change?

This change adds a CloudFront distribution for rss.wellcomecollection.org so that we can continue to serve content from that URL. We are using a CloudFront Function to rewrite URLs.

Requests come to https://rss.wellcomecollection.org/stories, the CloudFront distribution described in this PR will direct them to a behaviour which points them at the content app ALB origin, but rewrites requests for /stories to /rss and returns 404s for all other requests to rss.wellcomecollection.org.

Follows: https://github.com/wellcomecollection/wellcomecollection.org/pull/10982, which implements the RSS endpoint on the content app.

terraform plan

# aws_cloudfront_distribution.wc_org will be created
  + resource "aws_cloudfront_distribution" "wc_org" {
      + aliases                         = [
          + "rss.wellcomecollection.org",
        ]
      + arn                             = (known after apply)
      + caller_reference                = (known after apply)
      + continuous_deployment_policy_id = (known after apply)
      + domain_name                     = (known after apply)
      + enabled                         = true
      + etag                            = (known after apply)
      + hosted_zone_id                  = (known after apply)
      + http_version                    = "http2"
      + id                              = (known after apply)
      + in_progress_validation_batches  = (known after apply)
      + is_ipv6_enabled                 = true
      + last_modified_time              = (known after apply)
      + price_class                     = "PriceClass_All"
      + retain_on_delete                = false
      + staging                         = false
      + status                          = (known after apply)
      + tags_all                        = {
          + "Department"                = "Digital Platform"
          + "Division"                  = "Culture and Society"
          + "TerraformConfigurationURL" = "https://github.com/wellcomecollection/wellcomecollection.org/tree/main/cache"
          + "Use"                       = "Front-end CloudFront distributions"
        }
      + trusted_key_groups              = (known after apply)
      + trusted_signers                 = (known after apply)
      + wait_for_deployment             = true

      + default_cache_behavior {
          + allowed_methods            = [
              + "GET",
              + "HEAD",
            ]
          + cache_policy_id            = "b2c915f6-c889-4d69-84c1-0986bcf82901"
          + cached_methods             = [
              + "GET",
              + "HEAD",
            ]
          + compress                   = false
          + default_ttl                = (known after apply)
          + max_ttl                    = (known after apply)
          + min_ttl                    = 0
          + origin_request_policy_id   = "7d466a9a-b53c-43ab-babb-6f3e66ca5caf"
          + response_headers_policy_id = "6a3b328f-7d56-48ed-872d-6616b7dc7a71"
          + target_origin_id           = "origin"
          + trusted_key_groups         = (known after apply)
          + trusted_signers            = (known after apply)
          + viewer_protocol_policy     = "redirect-to-https"

          + function_association {
              + event_type   = "viewer-request"
              + function_arn = (known after apply)
            }
        }

      + logging_config {
          + bucket          = "wellcomecollection-experience-cloudfront-logs.s3.amazonaws.com"
          + include_cookies = false
          + prefix          = "rss.wellcomecollection.org/"
        }

      + origin {
          # At least one attribute in this block is (or was) sensitive,
          # so its contents will not be displayed.
        }

      + restrictions {
          + geo_restriction {
              + locations        = (known after apply)
              + restriction_type = "none"
            }
        }

      + viewer_certificate {
          + acm_certificate_arn      = "arn:aws:acm:us-east-1:130871440101:certificate/bb840c52-56bb-4bf8-86f8-59e7deaf9c98"
          + minimum_protocol_version = "TLSv1.2_2018"
          + ssl_support_method       = "sni-only"
        }
    }

  # aws_cloudfront_function.rss_url_rewrite will be created
  + resource "aws_cloudfront_function" "rss_url_rewrite" {
      + arn             = (known after apply)
      + code            = <<-EOT
            // eslint-disable-next-line no-unused-vars
            function handler(event) {
              const request = event.request;
              const uri = request.uri;

              if (uri === '/stories') {
                request.uri = '/visit-us';
                return request;
              } else {
                return {
                  statusCode: 404,
                };
              }
            }
        EOT
      + comment         = "Rewrites /stories to /rss for rss.wellcomecollection.org"
      + etag            = (known after apply)
      + id              = (known after apply)
      + live_stage_etag = (known after apply)
      + name            = "rss-url-rewrite"
      + publish         = true
      + runtime         = "cloudfront-js-2.0"
      + status          = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

How to test

Terraform this change, and manually configure to test with rss-stage.wellcomecollection.org. If this succeeds we can update the CNAME record for rss.wellcomecollection.org.

How can we measure success?

No more infrastructure on Vercel.

Have we considered potential risks?

We could break the existing RSS implementation during deployment, but this is not a high priority feature.

github-actions[bot] commented 3 months ago

Size Change: 0 B

Total Size: 978 kB

ℹ️ View Unchanged | Filename | Size | | :--- | :---: | | `content/webapp/.next/static/chunks/00a8a139.d1615490c6d9d990.js` | 59 kB | | `content/webapp/.next/static/chunks/1002-b2721e6482c83a94.js` | 4.34 kB | | `content/webapp/.next/static/chunks/1170.ad28feca2086d231.js` | 2.38 kB | | `content/webapp/.next/static/chunks/1187.3e587b771f4e596e.js` | 4.76 kB | | `content/webapp/.next/static/chunks/1349.d7fa638a45bd746d.js` | 3.18 kB | | `content/webapp/.next/static/chunks/1624.36ee3a10cb481879.js` | 270 B | | `content/webapp/.next/static/chunks/1747-7bd8bb2f4039b859.js` | 4.86 kB | | `content/webapp/.next/static/chunks/2224.c3d36692d71659d1.js` | 409 B | | `content/webapp/.next/static/chunks/2545.81b263fdea971f46.js` | 3.48 kB | | `content/webapp/.next/static/chunks/2568.ba2e160d2178193a.js` | 2.81 kB | | `content/webapp/.next/static/chunks/2630-5557119f622d72e9.js` | 4.45 kB | | `content/webapp/.next/static/chunks/267-cccc1b14a343a87b.js` | 3.66 kB | | `content/webapp/.next/static/chunks/2889.a2ffc850cd6682c4.js` | 1.83 kB | | `content/webapp/.next/static/chunks/3.b502c0af4bf6d3fa.js` | 2.78 kB | | `content/webapp/.next/static/chunks/3199.59646cfe68c708a6.js` | 2.58 kB | | `content/webapp/.next/static/chunks/3250-f50f8ea6fa9daefd.js` | 3.45 kB | | `content/webapp/.next/static/chunks/3419.8302d48bf43d69c3.js` | 419 B | | `content/webapp/.next/static/chunks/3420-400c17b2f7077e31.js` | 3.91 kB | | `content/webapp/.next/static/chunks/3627.cf9886fda60a7d8f.js` | 1.68 kB | | `content/webapp/.next/static/chunks/382-6c2bd3fb8a532e32.js` | 3.07 kB | | `content/webapp/.next/static/chunks/4133-dec44a56dbcade59.js` | 3.67 kB | | `content/webapp/.next/static/chunks/4468.b40b56238d215042.js` | 6.47 kB | | `content/webapp/.next/static/chunks/4621-d854f758923784b3.js` | 5.11 kB | | `content/webapp/.next/static/chunks/4825-0da3332c92191dfb.js` | 7.76 kB | | `content/webapp/.next/static/chunks/4962-a0a4531c5d6065ae.js` | 12.3 kB | | `content/webapp/.next/static/chunks/5048.e1e927ce200b8df3.js` | 4.9 kB | | `content/webapp/.next/static/chunks/5068.3ed1c6c988c72cde.js` | 3.23 kB | | `content/webapp/.next/static/chunks/5292-e5922c085480a271.js` | 2.91 kB | | `content/webapp/.next/static/chunks/5389.b37ba3f51bbce583.js` | 1.62 kB | | `content/webapp/.next/static/chunks/5637-b81d956dc1d5b56b.js` | 20.6 kB | | `content/webapp/.next/static/chunks/5768-4bb2fee1a42ccb79.js` | 3.17 kB | | `content/webapp/.next/static/chunks/583-ee31e85b0ded79ac.js` | 2.64 kB | | `content/webapp/.next/static/chunks/6207.210a73c1d1dacf3e.js` | 268 B | | `content/webapp/.next/static/chunks/6318.dafc8c5d0817c779.js` | 2.29 kB | | `content/webapp/.next/static/chunks/6501.28ce8d42744c59bf.js` | 281 B | | `content/webapp/.next/static/chunks/6577-effbaab7dae5448b.js` | 3.52 kB | | `content/webapp/.next/static/chunks/6614-60abee75d4d9e05b.js` | 5.09 kB | | `content/webapp/.next/static/chunks/6677.859ea72e9d7bdd12.js` | 19.9 kB | | `content/webapp/.next/static/chunks/6862-2b879b8cbc40506f.js` | 4.4 kB | | `content/webapp/.next/static/chunks/6879.5c504ae7600be437.js` | 2.6 kB | | `content/webapp/.next/static/chunks/7107-690d46121f0c6582.js` | 26.8 kB | | `content/webapp/.next/static/chunks/722-eca537339d9eff69.js` | 3.32 kB | | `content/webapp/.next/static/chunks/7414-4903f8bb8bb5d311.js` | 5.87 kB | | `content/webapp/.next/static/chunks/7888.122c0ef22c1a365a.js` | 5.36 kB | | `content/webapp/.next/static/chunks/8189-9bc510b8427ee840.js` | 3.43 kB | | `content/webapp/.next/static/chunks/8348.df2c1f1e661ae6bf.js` | 3.2 kB | | `content/webapp/.next/static/chunks/8476-9d264c37ea1f9a35.js` | 3.96 kB | | `content/webapp/.next/static/chunks/9049-9c1a7cfd68dd6a27.js` | 3.76 kB | | `content/webapp/.next/static/chunks/9065-20422656e905f45d.js` | 5.31 kB | | `content/webapp/.next/static/chunks/908.972937269334aa39.js` | 3.94 kB | | `content/webapp/.next/static/chunks/9519-9db5e2ee0c074bad.js` | 7.65 kB | | `content/webapp/.next/static/chunks/9590.808eeadf61368e35.js` | 2.65 kB | | `content/webapp/.next/static/chunks/9680-793248017be348e0.js` | 3.09 kB | | `content/webapp/.next/static/chunks/9704-cabf3fa83d4504e4.js` | 4.54 kB | | `content/webapp/.next/static/chunks/9778-705fe03826f54617.js` | 3.07 kB | | `content/webapp/.next/static/chunks/9950.91d7ab667432c53b.js` | 3.16 kB | | `content/webapp/.next/static/chunks/framework-f29e48ae95cae5a3.js` | 45.2 kB | | `content/webapp/.next/static/chunks/main-978dba4ddde48128.js` | 30.7 kB | | `content/webapp/.next/static/chunks/pages/_app-8e21d3b65185ab02.js` | 107 kB | | `content/webapp/.next/static/chunks/pages/_error-54ad671c1257cec3.js` | 335 B | | `content/webapp/.next/static/chunks/pages/404-9e69cf17ffb062d5.js` | 260 B | | `content/webapp/.next/static/chunks/pages/500-889eb9240c0e2c83.js` | 261 B | | `content/webapp/.next/static/chunks/pages/articles-4b7444af0e24f4b2.js` | 2.34 kB | | `content/webapp/.next/static/chunks/pages/articles/[articleId]-a0b7bf55228feb4d.js` | 6.75 kB | | `content/webapp/.next/static/chunks/pages/books-fef6bcf298982ec9.js` | 2.34 kB | | `content/webapp/.next/static/chunks/pages/books/[bookId]-69504423494ce32d.js` | 4.22 kB | | `content/webapp/.next/static/chunks/pages/collections-2ca9a866b9740be6.js` | 2.06 kB | | `content/webapp/.next/static/chunks/pages/concepts/[conceptId]-febc5367f39cf469.js` | 3.89 kB | | `content/webapp/.next/static/chunks/pages/cookie-policy-24ac3435bb4afa50.js` | 6.36 kB | | `content/webapp/.next/static/chunks/pages/covid-welcome-back-e0fb84a565a15c7e.js` | 11.2 kB | | `content/webapp/.next/static/chunks/pages/event-series/[eventSeriesId]-47457159f328dadc.js` | 3.33 kB | | `content/webapp/.next/static/chunks/pages/events-909a6966d4f582a2.js` | 2.46 kB | | `content/webapp/.next/static/chunks/pages/events/[eventId]-ddec01a834ff4628.js` | 8.92 kB | | `content/webapp/.next/static/chunks/pages/events/[eventId]/visual-stories-a983536c3e5e28a8.js` | 302 B | | `content/webapp/.next/static/chunks/pages/exhibitions-669c0fd08fc7f1f4.js` | 2.64 kB | | `content/webapp/.next/static/chunks/pages/exhibitions/[exhibitionId]-80500c31f62fcc2b.js` | 4.02 kB | | `content/webapp/.next/static/chunks/pages/exhibitions/[exhibitionId]/visual-stories-d1aeb46e8e916d28.js` | 303 B | | `content/webapp/.next/static/chunks/pages/guides/[pageId]-da8a3a9313b74f97.js` | 1.95 kB | | `content/webapp/.next/static/chunks/pages/guides/exhibitions-6a275816368c8abf.js` | 2.95 kB | | `content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]-42e7d9e9b15c6bd5.js` | 3.9 kB | | `content/webapp/.next/static/chunks/pages/guides/exhibitions/[id]/[type]-3f6a16642eb01cd4.js` | 5.73 kB | | `content/webapp/.next/static/chunks/pages/index-09e25e0db70e76bc.js` | 3.63 kB | | `content/webapp/.next/static/chunks/pages/newsletter-98605a779ca17771.js` | 2.4 kB | | `content/webapp/.next/static/chunks/pages/pages/[pageId]-a5d41c786e9f3307.js` | 1.93 kB | | `content/webapp/.next/static/chunks/pages/projects/[pageId]-9716ea56b80546b7.js` | 1.96 kB | | `content/webapp/.next/static/chunks/pages/search-2dd1ef17754eecb2.js` | 5.38 kB | | `content/webapp/.next/static/chunks/pages/search/events-7e0463aaa02201a0.js` | 2.05 kB | | `content/webapp/.next/static/chunks/pages/search/images-b06e3bea4b012994.js` | 1.61 kB | | `content/webapp/.next/static/chunks/pages/search/stories-9e6f72fa59d378c7.js` | 3.24 kB | | `content/webapp/.next/static/chunks/pages/search/works-709d146b869c6197.js` | 4.4 kB | | `content/webapp/.next/static/chunks/pages/seasons/[seasonId]-83d5dff4bdac5b7d.js` | 3.92 kB | | `content/webapp/.next/static/chunks/pages/series/[seriesId]-a54f1ff70fb3e79f.js` | 5.56 kB | | `content/webapp/.next/static/chunks/pages/slice-simulator-f30eba1fff249b02.js` | 8.48 kB | | `content/webapp/.next/static/chunks/pages/stories-e97be60d8eca10f1.js` | 1.76 kB | | `content/webapp/.next/static/chunks/pages/stories/[contentType]-d2f96d313bd42e31.js` | 2.38 kB | | `content/webapp/.next/static/chunks/pages/visit-us-335908532f352971.js` | 2.45 kB | | `content/webapp/.next/static/chunks/pages/visual-stories/[visualStoryId]-0e090de4ea368053.js` | 237 B | | `content/webapp/.next/static/chunks/pages/whats-on-d3f1b7279bb5142e.js` | 213 B | | `content/webapp/.next/static/chunks/pages/whats-on/[period]-9d135cd2564e60da.js` | 285 B | | `content/webapp/.next/static/chunks/pages/works/[workId]-2e14acd5d9b3dd82.js` | 25.9 kB | | `content/webapp/.next/static/chunks/pages/works/[workId]/download-2f4fafaebbec9ad2.js` | 3.1 kB | | `content/webapp/.next/static/chunks/pages/works/[workId]/images-6549881d746d6384.js` | 678 B | | `content/webapp/.next/static/chunks/pages/works/[workId]/items-a9385cdd3a82576b.js` | 2.1 kB | | `content/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js` | 31.1 kB | | `content/webapp/.next/static/chunks/webpack-deff53f7207a7155.js` | 2.33 kB | | `identity/webapp/.next/static/chunks/374.94537fd117195c86.js` | 2.47 kB | | `identity/webapp/.next/static/chunks/432.fa29da5acdb8e0b1.js` | 744 B | | `identity/webapp/.next/static/chunks/442-29780463d96993ea.js` | 8.34 kB | | `identity/webapp/.next/static/chunks/644-a3420a6bbc15048b.js` | 15.1 kB | | `identity/webapp/.next/static/chunks/677.a0884a27fb537187.js` | 19.9 kB | | `identity/webapp/.next/static/chunks/framework-19f3649580393c10.js` | 45.2 kB | | `identity/webapp/.next/static/chunks/main-d973a3979032d64a.js` | 32.2 kB | | `identity/webapp/.next/static/chunks/pages/_app-e26dcba7e8ba6935.js` | 100 kB | | `identity/webapp/.next/static/chunks/pages/_error-8e82953fa241027d.js` | 1.42 kB | | `identity/webapp/.next/static/chunks/pages/delete-requested-36dbb378188484a0.js` | 3.22 kB | | `identity/webapp/.next/static/chunks/pages/error-8117ccec5d62785a.js` | 1.7 kB | | `identity/webapp/.next/static/chunks/pages/index-744b70e8931f1e55.js` | 12.1 kB | | `identity/webapp/.next/static/chunks/pages/registration-d07114234ef485c5.js` | 4.11 kB | | `identity/webapp/.next/static/chunks/pages/success-babc5c74ab7f7620.js` | 3.29 kB | | `identity/webapp/.next/static/chunks/pages/validated-2ef62657092669ba.js` | 3.36 kB | | `identity/webapp/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js` | 31.1 kB | | `identity/webapp/.next/static/chunks/webpack-2e2c0b3078f78fb0.js` | 1.82 kB |

compressed-size-action