-
-
Notifications
You must be signed in to change notification settings - Fork 372
feat: support standard AWS env vars and default credential chain #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { env } from "~/env"; | ||
|
|
||
| export function getAwsCredentialOptions() { | ||
| const hasKey = !!env.AWS_ACCESS_KEY_ID; | ||
| const hasSecret = !!env.AWS_SECRET_ACCESS_KEY; | ||
|
|
||
| if (hasKey !== hasSecret) { | ||
| throw new Error( | ||
| "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must both be set or both be omitted" | ||
| ); | ||
| } | ||
|
|
||
| if (hasKey) { | ||
| return { | ||
| credentials: { | ||
| accessKeyId: env.AWS_ACCESS_KEY_ID!, | ||
| secretAccessKey: env.AWS_SECRET_ACCESS_KEY!, | ||
| }, | ||
| }; | ||
|
Comment on lines
+4
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether AWS_SESSION_TOKEN is modeled and propagated in current PR surface.
# Expected: references in env schema/mapping + credentials helper + (optionally) env examples.
rg -n -C3 '\bAWS_SESSION_TOKEN\b' \
apps/web/src/env.js \
apps/web/src/server/aws/credentials.ts \
apps/web/src/server/aws/ses.ts \
apps/web/src/server/aws/sns.ts \
.env.example \
.env.selfhost.example \
apps/web/.env.test.example || trueRepository: usesend/useSend Length of output: 41 🏁 Script executed: # First, let's find the actual env schema/configuration file
fd -e js -e ts -e json apps/web/src/ | grep -i env | head -20Repository: usesend/useSend Length of output: 417 🏁 Script executed: # Let's examine the credentials.ts file in full
cat -n apps/web/src/server/aws/credentials.tsRepository: usesend/useSend Length of output: 713 🏁 Script executed: # Check the env.js or env schema structure
fd -type f -name "env*" apps/web/src/ | head -10Repository: usesend/useSend Length of output: 230 🏁 Script executed: # Find env configuration files more carefully
find apps/web/src -name "env*" -type f | head -20Repository: usesend/useSend Length of output: 79 🏁 Script executed: # Also search for where env is exported from
rg -l "export.*env" apps/web/src --type ts --type js | head -10Repository: usesend/useSend Length of output: 196 🏁 Script executed: # Look for AWS configuration in existing code
rg "AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY" apps/web/src --type ts --type js -A 2 -B 2Repository: usesend/useSend Length of output: 2484 🏁 Script executed: # Read the full env.js file
cat -n apps/web/src/env.jsRepository: usesend/useSend Length of output: 7193 🏁 Script executed: # Check AWS SDK documentation expectations for sessionToken
# Look for any existing usage or patterns of sessionToken in the codebase
rg "sessionToken|session_token" apps/web --type ts --type jsRepository: usesend/useSend Length of output: 41 🏁 Script executed: # Check how AWS SDK is being used for SES and SNS
cat -n apps/web/src/server/aws/ses.ts | head -50Repository: usesend/useSend Length of output: 1938 🏁 Script executed: # Look for any auth-related issues or comments in AWS files
rg "auth|sign|credential|temporary|session" apps/web/src/server/aws/ --type ts -iRepository: usesend/useSend Length of output: 781 🏁 Script executed: # Check AWS SDK version/package being used
rg "@aws-sdk|aws-sdk" apps/web/package.jsonRepository: usesend/useSend Length of output: 265 Add AWS SDK v3 requires Add Suggested patch export function getAwsCredentialOptions() {
const hasKey = !!env.AWS_ACCESS_KEY_ID;
const hasSecret = !!env.AWS_SECRET_ACCESS_KEY;
+ const hasSessionToken = !!env.AWS_SESSION_TOKEN;
if (hasKey !== hasSecret) {
throw new Error(
"AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must both be set or both be omitted"
);
}
if (hasKey) {
return {
credentials: {
accessKeyId: env.AWS_ACCESS_KEY_ID!,
secretAccessKey: env.AWS_SECRET_ACCESS_KEY!,
+ ...(hasSessionToken ? { sessionToken: env.AWS_SESSION_TOKEN! } : {}),
},
};
}
return {};
}🤖 Prompt for AI Agents |
||
| } | ||
| return {}; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.