Skip to content
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

[AWS] Fix s3.NewFromConfig panic when running on AWS. #429

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions storage/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ func New(ctx context.Context, cfg Config, opts ...func(*options.StorageOptions))
}

if cfg.SDKConfig == nil {
// We're running on AWS so use the SDK's default config which will will handle credentials etc.
sdkConfig, err := config.LoadDefaultConfig(ctx)
if err != nil {
return nil, fmt.Errorf("failed to load default AWS configuration: %v", err)
}
cfg.SDKConfig = &sdkConfig
// We need a non-nil options func to pass in to s3.NewFromConfig below or it'll panic, so
// we'll use a "do nothing" placeholder.
cfg.S3Options = func(_ *s3.Options) {}
} else {
printDragonsWarning()
}
Expand Down
Loading