File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ import (
38
38
"sigs.k8s.io/cluster-api-provider-aws/v2/util/system"
39
39
)
40
40
41
+ // AWSDefaultRegion is the default AWS region.
42
+ const AWSDefaultRegion string = "us-east-1"
43
+
41
44
// Service holds a collection of interfaces.
42
45
// The interfaces are broken down like this to group functions together.
43
46
// One alternative is to have a large list of functions from the ec2 client.
@@ -223,11 +226,13 @@ func (s *Service) Delete(m *scope.MachineScope) error {
223
226
}
224
227
225
228
func (s * Service ) createBucketIfNotExist (bucketName string ) error {
226
- input := & s3.CreateBucketInput {
227
- Bucket : aws .String (bucketName ),
228
- CreateBucketConfiguration : & s3.CreateBucketConfiguration {
229
+ input := & s3.CreateBucketInput {Bucket : aws .String (bucketName )}
230
+
231
+ // See https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html#AmazonS3-CreateBucket-request-LocationConstraint.
232
+ if s .scope .Region () != AWSDefaultRegion {
233
+ input .CreateBucketConfiguration = & s3.CreateBucketConfiguration {
229
234
LocationConstraint : aws .String (s .scope .Region ()),
230
- },
235
+ }
231
236
}
232
237
233
238
_ , err := s .S3Client .CreateBucket (input )
You can’t perform that action at this time.
0 commit comments