Skip to content

Commit

Permalink
fix: kkb0318#2 us-east-1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kkb0318 authored and brianr2600 committed Sep 11, 2024
1 parent 3b9e632 commit bdb64af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions internal/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/irsasetup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func (r *IRSASetupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
}

defer func() {
if err := r.Get(ctx, req.NamespacedName, &irsav1alpha1.IRSASetup{}); err != nil {
if e := r.Get(ctx, req.NamespacedName, &irsav1alpha1.IRSASetup{}); e != nil {
return
}
statusHandler := handler.NewStatusHandler(kubeClient)
if err := statusHandler.Patch(ctx, obj); err != nil {
if e := statusHandler.Patch(ctx, obj); e != nil {
return
}
}()
Expand Down

0 comments on commit bdb64af

Please sign in to comment.