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 (
3838 "sigs.k8s.io/cluster-api-provider-aws/v2/util/system"
3939)
4040
41+ // AWSDefaultRegion is the default AWS region.
42+ const AWSDefaultRegion string = "us-east-1"
43+
4144// Service holds a collection of interfaces.
4245// The interfaces are broken down like this to group functions together.
4346// 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 {
223226}
224227
225228func (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 {
229234 LocationConstraint : aws .String (s .scope .Region ()),
230- },
235+ }
231236 }
232237
233238 _ , err := s .S3Client .CreateBucket (input )
You can’t perform that action at this time.
0 commit comments