mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-17 00:23:52 +00:00
bugfix s3 bucket name
This commit is contained in:
@@ -113,6 +113,7 @@ func (a *AwsS3Client) PutObjectPublic(ctx context.Context, input ObjectInput) er
|
||||
// CreateBucketPublic creates a new S3 bucket with public access settings in the specified region.
|
||||
// The function configures the bucket to have its ownership controlled by the bucket creator.
|
||||
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,
|
||||
|
||||
@@ -3,8 +3,11 @@ package client
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
|
||||
"github.com/aws/aws-sdk-go-v2/service/iam"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sts"
|
||||
@@ -35,6 +38,12 @@ func NewAwsClientFactory(ctx context.Context) (*AwsClientFactory, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load SDK config, %w", err)
|
||||
}
|
||||
roleArn := os.Getenv("AWS_ROLE_ARN")
|
||||
if roleArn != "" {
|
||||
stsSvc := sts.NewFromConfig(cfg)
|
||||
creds := stscreds.NewAssumeRoleProvider(stsSvc, roleArn)
|
||||
cfg.Credentials = aws.NewCredentialsCache(creds)
|
||||
}
|
||||
return &AwsClientFactory{config: cfg}, nil
|
||||
}
|
||||
|
||||
@@ -50,10 +59,10 @@ func (a *AwsClientFactory) StsClient() *AwsStsClient {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AwsClientFactory) S3Client(bucketName, region string) *AwsS3Client {
|
||||
func (a *AwsClientFactory) S3Client(region, bucketName string) *AwsS3Client {
|
||||
return &AwsS3Client{
|
||||
s3.NewFromConfig(a.config),
|
||||
region,
|
||||
bucketName,
|
||||
Client: s3.NewFromConfig(a.config),
|
||||
region: region,
|
||||
bucketName: bucketName,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user