Skip to content

Commit

Permalink
fix region check for s3 bucket create
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Vlasic committed Jul 8, 2021
1 parent 46791ed commit ede59c4
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions internal/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ func (s *SDK) DefaultRegion() string {
func (s *SDK) CreateS3Bucket(name, region string) error {
client := s3.NewFromConfig(s.config)

lc := s.BucketLocationConstraintForRegion(region)
if lc == "" {
return fmt.Errorf("region is not one of the known values - %s", region)
}

cbi := &s3.CreateBucketInput{
Bucket: aws.String(name),
CreateBucketConfiguration: &types.CreateBucketConfiguration{
LocationConstraint: lc,
LocationConstraint: types.BucketLocationConstraint(region),
},
}

Expand All @@ -64,12 +59,3 @@ func (s *SDK) DeleteS3Bucket(name string) error {
}
return nil
}

func (s *SDK) BucketLocationConstraintForRegion(region string) types.BucketLocationConstraint {
for _, blc := range types.BucketLocationConstraint.Values() {
if blc == region {
return blc
}
}
return ""
}

0 comments on commit ede59c4

Please sign in to comment.