From 7e738094a92de82bd54937799fd556579b00db78 Mon Sep 17 00:00:00 2001 From: neda1985 Date: Tue, 7 Jan 2025 18:29:58 +0100 Subject: [PATCH] make sure use correct endpoint for China cluster --- util/pkg/vfs/s3fs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/pkg/vfs/s3fs.go b/util/pkg/vfs/s3fs.go index 4af7362530f7d..829b8d1ed2291 100644 --- a/util/pkg/vfs/s3fs.go +++ b/util/pkg/vfs/s3fs.go @@ -575,8 +575,14 @@ func (p *S3Path) GetHTTPsUrl(dualstack bool) (string, error) { var url string if dualstack { url = fmt.Sprintf("https://s3.dualstack.%s.amazonaws.com/%s/%s", bucketDetails.region, bucketDetails.name, p.Key()) + if strings.Contains(bucketDetails.region, "cn-") { + url = fmt.Sprintf("https://s3.dualstack.%s.amazonaws.com.cn/%s/%s", bucketDetails.region, bucketDetails.name, p.Key()) + } } else { url = fmt.Sprintf("https://%s.s3.%s.amazonaws.com/%s", bucketDetails.name, bucketDetails.region, p.Key()) + if strings.Contains(bucketDetails.region, "cn-") { + url = fmt.Sprintf("https://%s.s3.%s.amazonaws.com.cn/%s", bucketDetails.name, bucketDetails.region, p.Key()) + } } return strings.TrimSuffix(url, "/"), nil } @@ -773,7 +779,6 @@ func (p *S3Path) RenderTerraform(w *terraformWriter.TerraformWriter, name string } return w.RenderResource("aws_s3_object", name, tf) } - } // AWSErrorCode returns the aws error code, if it is an smity.APIError, otherwise ""