-
Notifications
You must be signed in to change notification settings - Fork 31
Allow the AWS SDK to get auth from the environment (fixes #28) #88
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ddb231c
fix(s3): support s3 auth via env
Makeshift 07e852b
chore(docs): remove uneeded env vars
Makeshift c005a8b
chore(s3): remove unneeded optional
Makeshift 6aa22ab
Merge branch 'dev' into dev
DrJume 166a548
feat: remove custom env var validation for s3 driver
Makeshift dcb5fdb
Merge remote-tracking branch 'upstream/dev' into dev
Makeshift dc6de04
fix: re-add accidentally-removed key
Makeshift 8328de8
fix(s3): update test env vars
Makeshift File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,24 +17,36 @@ import { streamToBuffer } from '~/lib/utils' | |
| export const s3Driver = defineStorageDriver({ | ||
| envSchema: z.object({ | ||
| STORAGE_S3_BUCKET: z.string().min(1), | ||
| STORAGE_S3_ENDPOINT: z.string().min(1), | ||
| STORAGE_S3_REGION: z.string().min(1).default('us-east-1'), | ||
| STORAGE_S3_PORT: z.coerce.number().positive(), | ||
| STORAGE_S3_USE_SSL: z.string().transform((v) => v === 'true'), | ||
| STORAGE_S3_ACCESS_KEY: z.string().min(1), | ||
| STORAGE_S3_SECRET_KEY: z.string().min(1), | ||
| STORAGE_S3_ENDPOINT: z.string().optional(), | ||
| STORAGE_S3_REGION: z.string().min(1).default('us-east-1').optional(), | ||
| STORAGE_S3_PORT: z.coerce.number().positive().optional(), | ||
| STORAGE_S3_USE_SSL: z | ||
| .string() | ||
| .transform((v) => v === 'true') | ||
| .optional(), | ||
| STORAGE_S3_ACCESS_KEY: z.string().optional(), | ||
| STORAGE_S3_SECRET_KEY: z.string().optional(), | ||
| AWS_REGION: z.string().optional(), | ||
| AWS_DEFAULT_REGION: z.string().optional(), | ||
| }), | ||
| async setup(options) { | ||
| const protocol = options.STORAGE_S3_USE_SSL ? 'https' : 'http' | ||
| const port = options.STORAGE_S3_PORT ? `:${options.STORAGE_S3_PORT}` : '' | ||
| let credentials | ||
|
|
||
| const s3 = new S3Client({ | ||
| credentials: { | ||
| if (options.STORAGE_S3_ACCESS_KEY && options.STORAGE_S3_SECRET_KEY) { | ||
|
||
| credentials = { | ||
| secretAccessKey: options.STORAGE_S3_SECRET_KEY, | ||
| accessKeyId: options.STORAGE_S3_ACCESS_KEY, | ||
| }, | ||
| endpoint: `${protocol}://${options.STORAGE_S3_ENDPOINT}${port}`, | ||
| region: options.STORAGE_S3_REGION, | ||
| } | ||
| } | ||
|
|
||
| const s3 = new S3Client({ | ||
| credentials, | ||
| endpoint: options.STORAGE_S3_ENDPOINT | ||
| ? `${protocol}://${options.STORAGE_S3_ENDPOINT}${port}` | ||
| : undefined, | ||
| region: options.AWS_REGION ?? options.AWS_DEFAULT_REGION ?? options.STORAGE_S3_REGION, | ||
| forcePathStyle: true, | ||
| }) | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.