Skip to content

Fix: AWS CDK deployments now work with AWS SSO profiles - #925

Merged
hxtree merged 9 commits into
mainfrom
develop-jdi-update-packages
Dec 19, 2025
Merged

Fix: AWS CDK deployments now work with AWS SSO profiles#925
hxtree merged 9 commits into
mainfrom
develop-jdi-update-packages

Conversation

@hxtree

@hxtree hxtree commented Dec 19, 2025

Copy link
Copy Markdown
Owner

Problem
CDK deployments were failing with "Unable to resolve AWS account" and "no credentials configured" errors, even when AWS_PROFILE=DeveloperSandbox was set in the environment.

Root Cause
AWS SSO profiles use credential_process which wasn't accessible to CDK when running through npx in subprocesses, despite AWS_PROFILE being set or --profile flags being used.

Solution
Updated nx.json to add global targetDefaults for CDK commands that:

Export actual AWS credentials using aws configure export-credentials
Dynamically fetch account/region at runtime from the active AWS profile
Set CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION environment variables
Apply to all CDK projects workspace-wide
Updated CDK stack files to use environment variables for account/region configuration instead of hardcoded values.

Changes
nx.json: Added global CDK target defaults (cdk:deploy, cdk:destroy, cdk:diff, cdk:synth, cdk:bootstrap)
app.ts: Stack now uses CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION from environment
project.json: Override targets to use global nx.json configuration
Testing
✅ nx cdk:synth lambda-layers - successful
✅ nx cdk:deploy lambda-layers - credentials working (blocked on permissions, not credentials)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes AWS CDK deployment issues with AWS SSO profiles by configuring credential exports and environment variables in nx.json, while also upgrading Node.js runtimes and AWS CDK dependencies across the monorepo.

Key changes include:

  • Added global CDK target defaults in nx.json that export AWS credentials and set CDK environment variables for SSO profile support
  • Updated CDK app.ts files to read account/region from environment variables instead of hardcoded values
  • Upgraded Node.js runtimes from 18.x to 20.x/22.x across Lambda functions and development environment
  • Attempted upgrade of AWS CDK packages (contains version issues - see comments)

Reviewed changes

Copilot reviewed 50 out of 53 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
nx.json Added global CDK command targets (deploy, destroy, diff, synth, bootstrap) with AWS SSO credential export logic
platform/message-bus/bin/app.ts Updated to use CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION environment variables
platform/lambda-layers/bin/app.ts Updated to use CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION environment variables
platform/message-bus/project.json Added CDK target overrides to use global nx.json configuration
platform/lambda-layers/project.json Added CDK target overrides to use global nx.json configuration
platform/message-bus/stacks/message-bus.stack.ts Updated bucket name, removal policy, and added unused imports
platform/lambda-layers/stacks/nestjs-layer.stack.ts Updated Node.js runtime from 18.x to 20.x for bundling
platform/lambda-layers/stacks/chromium-layer.stack.ts Updated compatible runtime from nodejs18.x to nodejs20.x
platform/constructs/src/nestjs/nestjs.ts Updated Lambda runtime from nodejs18.x to nodejs20.x
services/*/package.json Upgraded aws-cdk and aws-cdk-lib versions (version 2.1034.0 appears invalid)
middleware/*/package.json Upgraded aws-cdk and aws-cdk-lib versions (version 2.1034.0 appears invalid)
clients/*/package.json Upgraded aws-cdk and aws-cdk-lib versions (version 2.1034.0 appears invalid)
platform/*/package.json Upgraded aws-cdk and aws-cdk-lib versions (version 2.1034.0 appears invalid)
.nvmrc Updated Node version from 18.18.0 to 20.9.0
.github/workflows/*.yml Updated Node.js version to 20.9.0 across all workflows
libraries/promare-gradients/src/scss/* Migrated to dart-sass using sass:math module
libraries/promare-gradients/package.json Removed node-sass, updated build command to use sass CLI
services//stacks/snapshots/ Updated snapshots reflecting runtime upgrades and CDK version changes
Comments suppressed due to low confidence (2)

platform/message-bus/stacks/message-bus.stack.ts:3

  • Unused import CustomResource.
    platform/message-bus/stacks/message-bus.stack.ts:9
  • Unused import cr.

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

Comment thread platform/message-bus/stacks/message-bus.stack.ts Outdated
Comment thread nx.json Outdated
Comment thread platform/message-bus/stacks/message-bus.stack.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 54 changed files in this pull request and generated 6 comments.


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

Comment thread libraries/promare-gradients/src/scss/_variables.scss Outdated
Comment thread tools/scripts/setup-aws-cdk-env.sh
Comment thread tools/scripts/setup-aws-cdk-env.sh Outdated
Comment thread platform/message-bus/stacks/message-bus.stack.ts Outdated
Comment thread libraries/promare-gradients/src/scss/_variables.scss Outdated
Comment thread libraries/promare-gradients/src/scss/_functions.scss
- Fix promare-gradients SCSS map formatting and phi calculation syntax
- Update RemovalPolicy from invalid RETAIN_ON_UPDATE_OR_DELETE to RETAIN
- Add error handling to setup-aws-cdk-env.sh script

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 54 changed files in this pull request and generated 1 comment.


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

Comment thread libraries/promare-gradients/src/scss/_variables.scss Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 68 out of 85 changed files in this pull request and generated 1 comment.


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

@@ -0,0 +1,33 @@
#!/bin/bash

Copilot AI Dec 19, 2025

Copy link

Choose a reason for hiding this comment

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

The shebang line includes a leading space which may cause issues on some systems. Shell scripts should start with #!/bin/bash without any leading whitespace to ensure proper execution.

Copilot uses AI. Check for mistakes.

Copilot AI commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

@hxtree I've opened a new pull request, #926, to work on those changes. Once the pull request is ready, I'll request review from you.

* fix: correct SCSS syntax by closing math.div on same line

Co-authored-by: hxtree <19890291+hxtree@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@hxtree
hxtree enabled auto-merge (squash) December 19, 2025 04:58
@hxtree
hxtree merged commit d0477e7 into main Dec 19, 2025
7 of 9 checks passed
@hxtree
hxtree deleted the develop-jdi-update-packages branch December 19, 2025 05:45
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