Skip to content

Modern Docker Management, Designed for Everyone

fix: default S3 signing region to us-east-1 for rustic (#4478)

Kyle Mendella0edb5bb4b09
diff --git a/backend/pkg/utils/s3/s3.go b/backend/pkg/utils/s3/s3.go
index ce8c6470a..76d1955c8 100644
--- a/backend/pkg/utils/s3/s3.go
+++ b/backend/pkg/utils/s3/s3.go
@@ -143,7 +143,7 @@ func (c Configuration) EndpointURL() string {
func (c Configuration) RusticEnvironment(rootParts ...string) []string {
c = c.Normalized()
repositoryParts := append([]string{"/", c.Prefix}, rootParts...)
- region := cmp.Or(c.Region, "auto")
+ region := cmp.Or(c.Region, "us-east-1")
environment := []string{
"RUSTIC_REPOSITORY=opendal:s3",
"RUSTIC_REPO_OPT_BUCKET=" + c.Bucket,
@@ -306,10 +306,9 @@ func (s *gcsHttpSigner) SignHTTP(ctx context.Context, creds aws.Credentials, req
}
func newClientInternal(ctx context.Context, configuration Configuration) (*awss3.Client, error) {
- region := cmp.Or(configuration.Region, "us-east-1")
awsConfiguration, err := awsconfig.LoadDefaultConfig(
ctx,
- awsconfig.WithRegion(region),
+ awsconfig.WithRegion(cmp.Or(configuration.Region, "us-east-1")),
awsconfig.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(configuration.AccessKeyID, configuration.SecretAccessKey, "")),
)
if err != nil {
diff --git a/backend/pkg/utils/s3/s3_test.go b/backend/pkg/utils/s3/s3_test.go
index 4b459c440..3c79a6a61 100644
--- a/backend/pkg/utils/s3/s3_test.go
+++ b/backend/pkg/utils/s3/s3_test.go
@@ -46,8 +46,30 @@ func TestConfigurationRusticEnvironment(t *testing.T) {
"AWS_SECRET_ACCESS_KEY=secret-key",
"AWS_EC2_METADATA_DISABLED=true",
"RUSTIC_REPO_OPT_ENDPOINT=https://s3.example.com",
- "RUSTIC_REPO_OPT_REGION=auto",
- "AWS_REGION=auto",
+ "RUSTIC_REPO_OPT_REGION=us-east-1",
+ "AWS_REGION=us-east-1",
"RUSTIC_REPO_OPT_ENABLE_VIRTUAL_HOST_STYLE=true",
}, configuration.RusticEnvironment("arcane-volume-backups", "instance-1"))
+
+ regional := Configuration{
+ Endpoint: "https://eu-005.example.com",
+ Bucket: "backups",
+ Region: "eu-005",
+ AccessKeyID: "access-key",
+ SecretAccessKey: "secret-key",
+ UseSSL: true,
+ ForcePathStyle: true,
+ }
+
+ require.Equal(t, []string{
+ "RUSTIC_REPOSITORY=opendal:s3",
+ "RUSTIC_REPO_OPT_BUCKET=backups",
+ "RUSTIC_REPO_OPT_ROOT=/arcane-volume-backups",
+ "AWS_ACCESS_KEY_ID=access-key",
+ "AWS_SECRET_ACCESS_KEY=secret-key",
+ "AWS_EC2_METADATA_DISABLED=true",
+ "RUSTIC_REPO_OPT_ENDPOINT=https://eu-005.example.com",
+ "RUSTIC_REPO_OPT_REGION=eu-005",
+ "AWS_REGION=eu-005",
+ }, regional.RusticEnvironment("arcane-volume-backups"))
}