diff --git a/aws/resource_aws_s3_bucket.go b/aws/resource_aws_s3_bucket.go index 9fe56005699..b554d3d1b34 100644 --- a/aws/resource_aws_s3_bucket.go +++ b/aws/resource_aws_s3_bucket.go @@ -1589,11 +1589,15 @@ func WebsiteEndpoint(bucket string, region string) *S3Website { func WebsiteDomainUrl(region string) string { region = normalizeRegion(region) - // New regions uses different syntax for website endpoints - // http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html + // Different regions have different syntax for website endpoints + // https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html + // https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints if isOldRegion(region) { return fmt.Sprintf("s3-website-%s.amazonaws.com", region) } + if partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region); ok && partition.ID() == endpoints.AwsCnPartitionID { + return fmt.Sprintf("s3-website.%s.amazonaws.com.cn", region) + } return fmt.Sprintf("s3-website.%s.amazonaws.com", region) } diff --git a/aws/website_endpoint_url_test.go b/aws/website_endpoint_url_test.go index 24d2137b0e0..06cfd3a58b1 100644 --- a/aws/website_endpoint_url_test.go +++ b/aws/website_endpoint_url_test.go @@ -19,6 +19,8 @@ var websiteEndpoints = []struct { {"ap-southeast-2", "bucket-name.s3-website-ap-southeast-2.amazonaws.com"}, {"ap-northeast-2", "bucket-name.s3-website.ap-northeast-2.amazonaws.com"}, {"sa-east-1", "bucket-name.s3-website-sa-east-1.amazonaws.com"}, + {"cn-northwest-1", "bucket-name.s3-website.cn-northwest-1.amazonaws.com.cn"}, + {"cn-north-1", "bucket-name.s3-website.cn-north-1.amazonaws.com.cn"}, } func TestWebsiteEndpointUrl(t *testing.T) {