Skip to content

Commit

Permalink
awss3receiver: Remove use of deprecated AWS SDK v2 API (#34171)
Browse files Browse the repository at this point in the history
**Description:** Remove use of deprecated AWS SDK v2 Endpoint resolver
API

**Link to tracking Issue:** #30750

**Testing:** Tested against a locally running localstack instance.

**Documentation:** N/A
  • Loading branch information
adcharre authored Jul 25, 2024
1 parent 358ab68 commit 14923a8
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions receiver/awss3receiver/s3intf.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ func newS3Client(ctx context.Context, cfg S3DownloaderConfig) (ListObjectsAPI, G
if cfg.Region != "" {
optionsFuncs = append(optionsFuncs, config.WithRegion(cfg.Region))
}

if cfg.Endpoint != "" {
customResolver := aws.EndpointResolverWithOptionsFunc(func(_, _ string, _ ...any) (aws.Endpoint, error) {
return aws.Endpoint{
PartitionID: cfg.EndpointPartitionID,
URL: cfg.Endpoint,
SigningRegion: cfg.Region,
}, nil
})
optionsFuncs = append(optionsFuncs, config.WithEndpointResolverWithOptions(customResolver))
}
awsCfg, err := config.LoadDefaultConfig(ctx, optionsFuncs...)
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
Expand All @@ -59,6 +48,11 @@ func newS3Client(ctx context.Context, cfg S3DownloaderConfig) (ListObjectsAPI, G
o.UsePathStyle = true
})
}
if cfg.Endpoint != "" {
s3OptionFuncs = append(s3OptionFuncs, func(o *s3.Options) {
o.BaseEndpoint = aws.String(cfg.Endpoint)
})
}
client := s3.NewFromConfig(awsCfg, s3OptionFuncs...)

return &s3ListObjectsAPIImpl{client: client}, client, nil
Expand Down

0 comments on commit 14923a8

Please sign in to comment.