Skip to content

Build: [AEA-6258] - Use the new SSM parameter CDK construct#2518

Closed
wildjames wants to merge 33 commits intomainfrom
aea-6258-ssm-params
Closed

Build: [AEA-6258] - Use the new SSM parameter CDK construct#2518
wildjames wants to merge 33 commits intomainfrom
aea-6258-ssm-params

Conversation

@wildjames
Copy link
Copy Markdown
Contributor

@wildjames wildjames commented Mar 24, 2026

Summary

  • 🤖 Operational or Infrastructure Change

Details

Based on #2494

Copilot AI review requested due to automatic review settings March 24, 2026 15:57
@github-actions
Copy link
Copy Markdown
Contributor

This PR is linked to a ticket in an NHS Digital JIRA Project. Here's a handy link to the ticket:

AEA-6258

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new packages/cdk workspace to the monorepo and scaffolds CDK apps/stacks/resources, while refactoring runtime config SSM lookups to be more resilient when parameters are missing/unreadable.

Changes:

  • Refactor PfPConfig SSM test-case lookups into a shared helper with warning+fallback behavior.
  • Introduce a new packages/cdk workspace with CDK apps, stacks, resources, scripts, and synth smoke tests.
  • Wire repository tooling to include the new workspace (Make targets, gitignore, VS Code workspace, lockfile updates).

Reviewed changes

Copilot reviewed 18 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/common/utilities/src/config.ts Refactors TC00x SSM param reads via a shared helper and adds logging on failure.
packages/cdk/vitest.config.ts Adds Vitest configuration for the new CDK package.
packages/cdk/tsconfig.json Adds TypeScript config for the CDK workspace.
packages/cdk/tests/synth.test.ts Adds smoke tests that type-check and synth both CDK apps.
packages/cdk/stacks/PfPApiStack.ts Defines the main stack and introduces the new SSM parameters construct usage.
packages/cdk/stacks/PfPApiSandboxStack.ts Adds a sandbox stack placeholder.
packages/cdk/scripts/deletePrStacks.ts Adds script to delete unused PR stacks.
packages/cdk/scripts/deleteMainStacks.ts Adds script to delete unused main stacks.
packages/cdk/resources/StateMachines.ts Adds Step Functions state machine wiring and IAM policies.
packages/cdk/resources/StateMachineDefinitions/GetMyPrescriptions.ts Adds the GetMyPrescriptions state machine definition.
packages/cdk/resources/Functions.ts Defines Lambda functions via shared constructs and policy wiring.
packages/cdk/resources/Apis.ts Defines API Gateway + endpoints for the stack.
packages/cdk/package.json Adds CDK workspace package definition and dependencies/scripts.
packages/cdk/nagSuppressions.ts Adds cdk-nag suppression helpers for the stack resources.
packages/cdk/cdk.json Adds CDK context and watch configuration.
packages/cdk/bin/PfPApiSandboxApp.ts Adds CDK sandbox app entrypoint.
packages/cdk/bin/PfPApiApp.ts Adds CDK main app entrypoint + env-driven config.
package.json Adds packages/cdk to workspaces.
package-lock.json Updates lockfile for the new workspace and dependencies.
Makefile Adds CDK deploy/synth/diff/watch targets and includes cdk lint/test/clean.
.vscode/prescriptionsforpatients.code-workspace Adds packages/cdk folder to the VS Code workspace.
.gitignore Ignores cdk.out/ and .env.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6 to +15
"outDir": "lib",
"noEmit": true,
"strict": false,
"lib": [
"es2020"
],
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This tsconfig disables strict even though the repo default (tsconfig.defaults.json) enables it and other packages inherit that setting. Setting strict: false turns off several strictness checks (unless individually re-enabled) and can allow type issues to slip into the CDK code. If there's no strong reason to diverge, consider removing the override so the package stays aligned with the monorepo defaults.

Copilot uses AI. Check for mistakes.
private readonly logger: Logger

constructor(ssmProvider?: SSMProvider) {
this.logger = new Logger()
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Logger is instantiated without a serviceName, which is inconsistent with other Powertools logger usage in this repo and makes logs harder to attribute/filter. Consider passing a serviceName (and optionally logLevel) when constructing the logger (e.g., aligned to how other packages set it).

Suggested change
this.logger = new Logger()
this.logger = new Logger({serviceName: "pfp-config"})

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +46
reason: "Suppress error for not implementing authorization. Token endpoint should not have an authorizer"
},
{
id: "AwsSolutions-COG4",
reason: "Suppress error for not implementing a Cognito user pool authorizer. Token endpoint should not have an authorizer"
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The suppression reasons mention a "Token endpoint", but this stack only defines Bundle and _status API resources. This looks like a copy/paste and makes the audit trail for the suppression misleading; please update the reason text to accurately describe why these endpoints intentionally have no authorization.

Suggested change
reason: "Suppress error for not implementing authorization. Token endpoint should not have an authorizer"
},
{
id: "AwsSolutions-COG4",
reason: "Suppress error for not implementing a Cognito user pool authorizer. Token endpoint should not have an authorizer"
reason: "Suppress error for not implementing authorization on the Bundle and _status GET endpoints, which are intentionally unauthenticated read-only/public endpoints"
},
{
id: "AwsSolutions-COG4",
reason: "Suppress error for not implementing a Cognito user pool authorizer on the Bundle and _status GET endpoints, which are intentionally unauthenticated read-only/public endpoints"

Copilot uses AI. Check for mistakes.
[
{
id: "AwsSolutions-IAM5",
reason: "Suppress error for not having wildcards in permissions. This is a fine as we need to have permissions on all log streams under path"
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Spelling/grammar in the suppression reason: "This is a fine" should be "This is fine".

Suggested change
reason: "Suppress error for not having wildcards in permissions. This is a fine as we need to have permissions on all log streams under path"
reason: "Suppress error for not having wildcards in permissions. This is fine as we need to have permissions on all log streams under path"

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +7
const awsEnvironment = getConfigFromEnvVar("AWS_ENVIRONMENT", "")
deleteUnusedMainStacks(
"pfp-api",
() => getActiveApiVersions("prescriptions-for-patients"),
`${awsEnvironment}.eps.national.nhs.uk.`
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

getConfigFromEnvVar("AWS_ENVIRONMENT", "") makes AWS_ENVIRONMENT effectively optional, but this script deletes stacks and uses the value to build the DNS zone string. If the env var is missing/empty, the computed zone becomes .eps.national.nhs.uk., which is risky. Prefer requiring AWS_ENVIRONMENT (no default) or validating it is non-empty before calling deleteUnusedMainStacks.

Copilot uses AI. Check for mistakes.
@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.

3 participants