Skip to content

Marketing router lambda#64807

Merged
carl-codeorg merged 21 commits into
stagingfrom
CMS-208/router
Apr 15, 2025
Merged

Marketing router lambda#64807
carl-codeorg merged 21 commits into
stagingfrom
CMS-208/router

Conversation

@carl-codeorg

@carl-codeorg carl-codeorg commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

First PR for adding the infrastructure needed to dynamically route requests to the marketing app instead of Pegasus. This PR only includes the lambda function itself and the execution role. Once this is merged, I'll follow up with a 2nd PR adding the function association to the Cloudfront distribution.

Links

Testing story

Tested that the cloudformation is valid using adhoc:cdn:validate. Ultimately we'll have to deploy for real to test this fully.

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated

@cat5inthecradle cat5inthecradle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Parameterizing the marketing domain name is my strongest comment, the rest are stylistic suggestions to help simplify the code and use less erb wherever possible.

Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated
Role: !GetAtt MarketingRouterLambdaRole.Arn
Environment:
Variables:
MARKETING_DOMAIN: dev.marketing.dev-code.org

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Parameterize this so you can have different values for different stacks (environments).

For example, by adding a parameter at the top of the template.

Parameters:
  # ...
  MarketingOriginDomainName:
    Type: String
    Default: dev.marketing.dev-code.org
    Description: Domain name for marketing site origin.
  # ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have existing Template Parameters that we can use to construct the fully qualified domain name!

Parameters:
# ---------------------------------------------
# Domain Names - Each Stack operates 5 sites (examples are for production):
# 1) Learning Platform ("Dashboard") - https://studio.code.org
# 2) Corporate Website ("Pegasus") - https://code.org
# 3) Advocacy Website (runs on LeadPages) - https://advocacy.code.org
# 4) Hour of Code (runs on Pegasus) - https://hourofcode.com
# 5) Code Projects (host user created content) - https://codeprojects.org
# ---------------------------------------------
BaseDomainName:
Type: String
Default: <%=rack_env?(:adhoc) ? 'cdn-code.org' : "code.org" %>
Description: Base domain name for primary learning platform and corporate web site.
DashboardSubdomainName:
Type: String
Default: <%=rack_env?(:production) ? 'studio' : "#{stack_name}-studio" %>
Description: Subdomain name for learning platform ("Dashboard").
PegasusSubdomainName:
Type: String
Default: <%=rack_env?(:production) ? '\'\'' : stack_name %>
Description: Subdomain name for corporate web site ("Pegasus").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I parameterized it and for now am going with marketing for the prod subdomain and {stack_name}-marketing for others. This might change before release, however.

Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated
Comment thread lib/cdo/cloud_formation/stack_template.rb Outdated
Comment thread aws/cloudformation/lambdas/marketing-router/index.js Outdated
@carl-codeorg

Copy link
Copy Markdown
Contributor Author

adhoc:cdn:validate is now passing. Had one circular dependency issue that was easily fixable.

@cat5inthecradle cat5inthecradle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for those changes! This is looking good so far.

When we add new resources, there's always risk of the stack update failing. Fortunately this will get deployed to all environments, so we should notice the issue in Staging and Test. If the DTP this goes out in includes database migrations, then we should watch carefully so we can respond quickly with a fix in the event of failure - as that could leave production with a new database schema but old code.

Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated
@carl-codeorg carl-codeorg marked this pull request as ready for review March 27, 2025 15:37
@carl-codeorg carl-codeorg requested a review from a team as a code owner March 27, 2025 15:37
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb Outdated
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb
Comment thread aws/cloudformation/lambdas/marketing-router/index.js Outdated
Comment thread aws/cloudformation/lambdas/marketing-router/index.js
Comment thread aws/cloudformation/cloud_formation_stack.yml.erb
Comment thread aws/cloudformation/lambdas/marketing-router/index.js Outdated
@carl-codeorg carl-codeorg merged commit e4315ac into staging Apr 15, 2025
@carl-codeorg carl-codeorg deleted the CMS-208/router branch April 15, 2025 15:42
carl-codeorg added a commit that referenced this pull request Apr 16, 2025
carl-codeorg added a commit that referenced this pull request Apr 16, 2025
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.

5 participants