Skip to content

Commit

Permalink
Merge pull request #147 from fujiwara/fix/s3-region
Browse files Browse the repository at this point in the history
Fix bucket region configuration issue
  • Loading branch information
fujiwara authored Dec 25, 2023
2 parents 24f9805 + d19f224 commit affdb0d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tfstate/remote_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ func readS3(ctx context.Context, bucket, key string, opt s3Option) (io.ReadClose
if err != nil {
return nil, err
}
if opt.region == "" {
opt.region, err = getBucketRegion(ctx, cfg, bucket)
region, err := getBucketRegion(ctx, cfg, bucket)
if err != nil {
return nil, err
}
if region != opt.region {
// reload config with bucket region
cfg, err = config.LoadDefaultConfig(ctx,
config.WithRegion(region),
)
if err != nil {
return nil, err
}
}

if opt.role_arn != "" {
arn, err := arn.Parse(opt.role_arn)
if err != nil {
Expand Down

0 comments on commit affdb0d

Please sign in to comment.