Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #3097] Adds configuration for S3 CDN #3477

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

coilysiren
Copy link
Collaborator

@coilysiren coilysiren commented Jan 9, 2025

Summary

Probably finishes #3097

Time to review: 5 mins

Changes proposed

Adds configuration to the CDN that allows it to operate in 4 modes:

  1. With no fronting domain name, and an ALB origin (eg. frontend dev)
  2. With a fronting domain name, and an ALB origin (eg. frontend prod)
  3. With no fronting domain name, and a S3 origin (eg. API dev)
  4. With a fronting domain name, and a S3 origin (eg. API prod)

Context for reviewers

It's complicated in here 😅

Testing

I tested by deploying to API dev and frontend dev

@coilysiren coilysiren marked this pull request as ready for review January 9, 2025 18:53
Comment on lines +225 to +230
variable "s3_cdn_domain_name" {
description = "The domain name of the S3 bucket to use for the S3 CDN"
type = string
default = null
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be in this PR, but we'll want this value to be an env var the API gets.

The plan I had for this was just to swap out the s3 bucket for the CDN domain name on the fly in the API (eg. s3://public-bucket-1234/path/to/file.txt becomes https://the-cdn-name/path/to/file.txt)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can build that into this PR!

@mdragon
Copy link
Collaborator

mdragon commented Jan 9, 2025

@coilysiren, just to make sure I'm clear.

  1. The references to API in the PR itself (not the code) are about CDN->S3 because our "API" is the service that owns the S3 buckets for files that we're looking to front with Cloudfront? So we have CDN to ALB to CDN to S3 support following this change.
  2. In the scenario where frontend turns on ALB CDN, and API turns on S3 CDN, do we have 2 CDNs? Or is this able to apply both sets of configuration into a single CDN instance?

@coilysiren coilysiren changed the title Adds configuration for S3 CDN [Issue #3097] Adds configuration for S3 CDN Jan 9, 2025
@coilysiren
Copy link
Collaborator Author

In the scenario where frontend turns on ALB CDN, and API turns on S3 CDN, do we have 2 CDNs? Or is this able to apply both sets of configuration into a single CDN instance?

2 CDNs, which is my preference.

@coilysiren
Copy link
Collaborator Author

coilysiren commented Jan 9, 2025

The references to API in the PR itself (not the code) are about CDN->S3 because our "API" is the service that owns the S3 buckets for files that we're looking to front with Cloudfront? So we have frontend CDN to ALB and API CDN to S3 to support following this change.

Comment edited for clarity, and yes.

@mdragon
Copy link
Collaborator

mdragon commented Jan 10, 2025

2 CDNs, which is my preference.

Ok, great, that's what I was hoping, but just couldn't put all the terraform together in my head to be sure. I think that's going to be very beneficial as we look to do mass-invalidation on deploy (which wouldn't need to touch the S3 CDN at all for example).

@coilysiren coilysiren requested a review from chouinar January 10, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants