Here are the deprecation warnings:
aws.EndpointResolverWithOptionsFunc is deprecated: The global endpoint resolution interface is deprecated. See deprecation docs on [EndpointResolver].
aws.Endpoint is deprecated: This structure was used with the global [EndpointResolver] interface, which has been deprecated in favor of service-specific endpoint resolution. See the deprecation docs on that interface for more information.
This is the config I'm using, instead of the deprecated method in your doc:
cfg, err := config.LoadDefaultConfig(context.Background(),
config.WithCredentialsProvider(credentials.StaticCredentialsProvider{
Value: aws.Credentials{
AccessKeyID: "N/A",
SecretAccessKey: "N/A",
},
}),
)
if err != nil {
return nil, fmt.Errorf("unable to load SDK config for local endpoint, %v", err)
}
svc = s3.NewFromConfig(cfg,
s3.WithEndpointResolverV2(&S3LocalResolver{hostAndPort: "localhost:4566"}),
func(o *s3.Options) { o.UsePathStyle = true },
)
However, a putObject operation does not work with this config:
s3-1 | 2024-06-09T19:08:32.476 ERROR --- [et.reactor-0] l.aws.handlers.logging : exception during call chain: Unable to parse request (syntax error: line 1, column 0), invalid XML received:
s3-1 | b'hello'
s3-1 | 2024-06-09T19:08:32.478 INFO --- [et.reactor-0] localstack.request.http : PUT /upload-test => 500
s3-1 | 2024-06-09T19:08:33.995 ERROR --- [et.reactor-0] l.aws.handlers.logging : exception during call chain: Unable to parse request (syntax error: line 1, column 0), invalid XML received:
s3-1 | b'hello'
s3-1 | 2024-06-09T19:08:33.996 INFO --- [et.reactor-0] localstack.request.http : PUT /upload-test => 500
s3-1 | 2024-06-09T19:08:37.592 ERROR --- [et.reactor-0] l.aws.handlers.logging : exception during call chain: Unable to parse request (syntax error: line 1, column 0), invalid XML received:
s3-1 | b'hello'
s3-1 | 2024-06-09T19:08:37.594 INFO --- [et.reactor-0] localstack.request.http : PUT /upload-test => 500
this works using the aws cli:
aws s3api create-bucket --endpoint-url http://localhost:4566 --bucket test
aws s3 cp --endpoint-url http://localhost:4566 ./test-file s3://test
I'm not sure why the golang sdk is attempting to upload the file "directly" (or something?) whereas aws s3 cp uses the PutObject op.
Here are the deprecation warnings:
This is the config I'm using, instead of the deprecated method in your doc:
However, a
putObjectoperation does not work with this config:this works using the aws cli:
I'm not sure why the golang sdk is attempting to upload the file "directly" (or something?) whereas
aws s3 cpuses thePutObjectop.