fix: #2 us-east-1 support

This commit is contained in:
kkb0318
2024-08-25 12:33:10 +09:00
committed by Brian Ristuccia
parent 3b9e63251b
commit bdb64afe5c
2 changed files with 16 additions and 8 deletions
+14 -6
View File
@@ -122,12 +122,20 @@ func (a *AwsS3Client) PutObjectPublic(ctx context.Context, input ObjectInput) er
func (a *AwsS3Client) CreateBucketPublic(ctx context.Context) error {
log.Printf("creating S3 bucket... Name: %s, Region: %s \n", a.bucketName, a.Region())
bucket := aws.String(a.bucketName)
_, err := a.Client.CreateBucket(ctx, &s3.CreateBucketInput{
Bucket: bucket,
CreateBucketConfiguration: &s3types.CreateBucketConfiguration{
LocationConstraint: s3types.BucketLocationConstraint(a.Region()),
},
})
var input *s3.CreateBucketInput
if a.Region() == "us-east-1" {
input = &s3.CreateBucketInput{
Bucket: bucket,
}
} else {
input = &s3.CreateBucketInput{
Bucket: bucket,
CreateBucketConfiguration: &s3types.CreateBucketConfiguration{
LocationConstraint: s3types.BucketLocationConstraint(a.Region()),
},
}
}
_, err := a.Client.CreateBucket(ctx, input)
if err != nil {
var bucketAlreadyOwnedByYou *s3types.BucketAlreadyOwnedByYou
if errors.As(err, &bucketAlreadyOwnedByYou) {