Skip to content

OJ-3625: OAuthCommon Migration Guide#773

Draft
mikebeeby wants to merge 1 commit into
mainfrom
OJ-3625
Draft

OJ-3625: OAuthCommon Migration Guide#773
mikebeeby wants to merge 1 commit into
mainfrom
OJ-3625

Conversation

@mikebeeby
Copy link
Copy Markdown
Contributor

@mikebeeby mikebeeby commented May 21, 2026

OAuth Migration Guide

This PR is only a guide and should not be merged

Step Overview

Although some of the steps are included in this single PR, this is only an example. Each step below requires a deploy to either common-lambdas or the CRI API stack.

Step 1 - Ensure Common Lambdas is up-to-date

Ensure you have the most recent common-lambdas deployed, with this PR in particular: govuk-one-login/ipv-cri-common-lambdas#645

At this point, the EnableDynamoDbStream mapping should be set to false for your CRI. The stream lambda will not be deployed at this point.

Step 2 - Add OAuthCommon to the CRI API stack

Add OAuthCommon to your CRI API stack, but do not yet use. This is to ensure the new tables are created so we can migrate to them.

You also need to output the Session table name, Person Identity table name and CMK key ID to the SSM parameter paths below.
/common-cri/oauth-common/OAuthSessionTableName
/common-cri/oauth-common/OAuthPersonIdentityTableName
/common-cri/oauth-common/OAuthCustomerManagedKeyId*

Important: The SSM parameters have hardcoded paths so they can only be deployed once per account, hence the IsNotLocalDevEnvironment condition. Unfortunately common-lambdas does not know much about the application stack using it, so configuring it to look for dynamic parameters was not possible.

Changes will need to be made to the action that deploys pre-merge stacks also:

  • Update the SHAs of the govuk-one-login/github-actions/sam to 4c76410195b5fcb1804fc7c183ed20704252830f (or more recent).
  • The build action will now also need AWS creds.
  • stack-name-prefix: may also need shortening, due to the OAuth lambda names getting too long.

Pipelines - At time of writing, deploying through the pipelines is currently not working. The tickets below are tracking this, there may be additional work prior to completing this step to ensure the pipelines deploy
https://govukverify.atlassian.net/browse/PSREDEV-3425 & https://govukverify.atlassian.net/browse/LIME-2144

Example: See the first commit on this PR for this step in practice: 56ba3b6

*If you do not want to use a CustomerManagedKey for the OAuthCommon databases, and are going to overwrite the parameter DbCustomerManagedKey to false. You'll need to make a slight change to the Stream lambda in common-lambdas to wrap the KMSDecryptPolicy in a if condition. (This has been done for the existing common-lambdas CMK so can be easily copied)

Before proceeding to Step 3, ensure the nested OAuthCommon stack exists in all accounts, and the SSM parameters are populated with the correct names and ID.

Step 3 - Enable the DynamoDB stream in Common Lambdas (lower envs only)

We now want to enable the stream from the common-lambdas tables to the OAuthCommon tables. To do so, set EnableDynamoDbStream to true in common-lambdas

I would recommend only doing this is dev & build initially. We can then conduct some testing in build.

Validate this is working correctly, by running a through journeys and checking the OAuthCommon tables mirror the common-lambdas tables.

Step 4 - Migrate CRI API stack to use OAuthCommon (lower envs only)

WIP
Start perf tests -> Wait TTL (optional) -> Migrate OAuthCommon -> Check no errors

Migrate the CRI API stack to using OAuthCommon. See the second commit on this repo:

Step 5 - Enable the DynamoDB stream in Common Lambdas (all envs)

Set EnableDynamoDbStream to true in common-lambdas in all environments.

As this now includes prod we need to ensure all sessions are in the OAuthCommon tables. This time we need to wait longer than the TTL before proceeding to the next step (usually 2 hrs, some CRIs may differ).

Then, validate the OAuthCommon tables mirror the common-lambdas tables.

Step 6 - Migrate CRI API stack to use OAuthCommon (all envs)

WIP

Step 7 - Remove Common Lambdas

WIP

Issue tracking

We need to add OAuthCommon and the suppport OAuthCommon SSM parameters to ready us migrating from common-lambdas.

This will ensure the tables exist, and the table names and CMK ID can be retrieved by common-lambdas so we can then enable the stream.

Note: The SSM parameters have hardcoded paths so they can only be deployed once per account, hence the IsNotLocalDevEnvironment condition.
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant