fix: allow AWS default credential chain for S3 storage - #3116
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughChangesS3 credential resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
controlplane/test/utils.s3storage.test.ts (1)
157-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the complete optional-credentials contract.
The tests cover both credentials being absent, but not the case where only one credential is supplied. Add username-only and password-only cases asserting that
credentialsremains omitted, plus equivalent regression coverage for the separate CDN implementation.
controlplane/test/utils.s3storage.test.ts#L157-L204: add partial-credential cases.cdn-server/src/utils.ts#L31-L43: add CDN-side tests for omitted credentials and continued region validation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@controlplane/test/utils.s3storage.test.ts` around lines 157 - 204, Add username-only and password-only test cases in controlplane/test/utils.s3storage.test.ts within the createS3ClientConfig credential coverage, asserting credentials is omitted; in cdn-server/src/utils.ts, add equivalent tests for the CDN implementation covering omitted credentials and continued missing-region validation. Preserve the existing behavior and assertions for fully absent credentials.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@controlplane/test/utils.s3storage.test.ts`:
- Around line 157-204: Add username-only and password-only test cases in
controlplane/test/utils.s3storage.test.ts within the createS3ClientConfig
credential coverage, asserting credentials is omitted; in
cdn-server/src/utils.ts, add equivalent tests for the CDN implementation
covering omitted credentials and continued missing-region validation. Preserve
the existing behavior and assertions for fully absent credentials.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 15c29707-d9ce-44e0-ba5a-a3ab93d88a60
📒 Files selected for processing (3)
cdn-server/src/utils.tscontrolplane/src/core/util.tscontrolplane/test/utils.s3storage.test.ts
|
The Controlplane CI / build_test failure is unrelated to this change. It's a pre-existing CI issue that affects PRs from forks. The workflow's redis/postgres service containers reference |
Prior to this change, createS3ClientConfig() in cdn-server and controlplane threw an error whenever an explicit access key ID and secret access key were not supplied, forcing static credentials for every S3-backed deployment. This change makes credentials optional: the S3 client config now only sets the credentials field when both accessKeyId and secretAccessKey are present, and omits it otherwise so the AWS SDK falls back to its default credential provider chain (IRSA, env vars, EC2/ECS instance metadata). Region is still required and still throws if missing.
63e75e1 to
36da5e8
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Description
Removes the hard requirement for an explicit S3 access key ID and secret access key in
createS3ClientConfig()(cdn-server/src/utils.tsandcontrolplane/src/core/util.ts), so that deployments without static credentials configured can fall back to the AWS SDK's default credential provider chain — most notably IRSA (IAM Roles for Service Accounts) on EKS, but also plain environment variables and EC2/ECS instance metadata.Closes #2159
Related to #2772 - Fix 1 scope
Related to #2769, which was closed
Why
Several users run the router/controlplane/cdn-server on EKS with IRSA and don't want to manage long-lived static S3 credentials. Because
createS3ClientConfig()always set an explicitcredentialsobject (and threw if access key/secret were blank) the AWS SDK never got the chance to use its default provider chain, even when the pod's service account already had a valid IAM role attached.What changed
cdn-server/src/utils.ts/controlplane/src/core/util.ts:createS3ClientConfig()now builds the config object and only attachescredentialswhen bothaccessKeyIdandsecretAccessKeyare non-empty. When neither is provided, the field is omitted entirely, letting the AWS SDK'sfromNodeProviderChainresolve credentials on its own (IRSA, env vars, instance metadata, etc). The existing check thatregionis required is unchanged.controlplane/test/utils.s3storage.test.ts: added coverage for the new behavior — omitting credentials when username/password are empty strings, omitting credentials when they're absent entirely from both the URL and opts, and confirming the region-required check still throws even without explicit credentials.Summary by CodeRabbit