Description
Acknowledgements
- I have searched (https://github.com/aws/aws-sdk/issues?q=is%3Aissue) for past instances of this issue
- I have verified all of my SDK modules are up-to-date (you can perform a bulk update with
go get -u github.com/aws/aws-sdk-go-v2/...
)
Describe the bug
Create a proxy or local S3-compatible server. Run it at localhost:8080
. You would expect that the endpoint is not part of the name. Then try to do activities against the bucket named bucket1
. The Host
header in the request always includes the bucket name and the endpoint.
For example, PutObject
for myfile
against bucket bucket1.mydomain.com
with endpoint localhost:9000
should have headers:
PUT /myfile?x-id=PutObject HTTP/1.1
Host: bucket1.mydomain.com
Yet it actually has
PUT /myfile?x-id=PutObject HTTP/1.1
Host: bucket1.mydomain.com.localhost:9000
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
The endpoint would not be part of the Host
, since that is a pointer as to where to find the fully named bucket.
Current Behavior
Includes it in the host. See the bug description
Reproduction Steps
var (
opts []func(*config.LoadOptions) error // global client options
s3opts []func(*s3.Options) // s3 client options
)
s3opts = append(s3opts,
// I tried with each of the following options, both had more or less same result
//s3.WithEndpointResolverV2(&staticResolver{endpoint: "localhost:9000"}),
func(o *s3.Options) {
o.BaseEndpoint = "localhost:9000"
},
)
}
opts = append(opts, config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponse))
opts = append(opts, config.WithRegion(region))
opts = append(opts, config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
"myaccesskey"
"mysecreykey",
"",
)))
cfg, err := config.LoadDefaultConfig(context.TODO(),
opts...,
)
if err != nil {
return nil, fmt.Errorf("failed to load AWS config: %v", err)
}
// Create a new S3 service client
client := s3.NewFromConfig(cfg, s3opts...)
uploader := manager.NewUploader(client)
// Create a file to write the S3 Object contents to.
f, err := os.Open("source file")
if err != nil {
return 0, fmt.Errorf("failed to read input file %q, %v", source, err)
}
defer f.Close()
// Write the contents of the file to the S3 object
_, err = uploader.Upload(context.TODO(), &s3.PutObjectInput{
Bucket: aws.String("bucket1.mydomain.com"),
Key: aws.String("my file"),
Body: f,
})
Possible Solution
No response
Additional Information/Context
I did try various combinations of BaseEndpoint
and EndpointResolverV2
as described in this doc, to no avail.
I suspect there is some combination of which I am not aware, in which case feel free to call this a "docs error report" as opposed to a bug report.
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2 v1.32.3
github.com/aws/aws-sdk-go-v2/config v1.28.1
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.35
github.com/aws/aws-sdk-go-v2/service/s3 v1.66.2
github.com/aws/aws-sdk-go-v2/credentials v1.17.42
github.com/aws/aws-sdk-go v1.44.256 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.18 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.22 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.24.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.32.3 // indirect
github.com/aws/smithy-go v1.22.0
Compiler and Version used
go version go1.23.0
Operating System and version
linux/amd64