Skip to content

Commit c2d3399

Browse files
authored
fix: Find region correctly from EC2 IMDS (#549)
When running on an EC2 instance with an instance profile / role, chamber now finds the region correctly.
1 parent e79a864 commit c2d3399

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

store/shared.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ func getConfig(ctx context.Context, numRetries int, retryMode aws.RetryMode) (aw
3131
// If region is still not set, attempt to determine it via ec2 metadata API
3232
if cfg.Region == "" {
3333
imdsConfig, err := config.LoadDefaultConfig(ctx)
34-
if err != nil {
34+
if err == nil {
3535
ec2metadataSvc := imds.NewFromConfig(imdsConfig)
3636
if regionOverride, err := ec2metadataSvc.GetRegion(ctx, &imds.GetRegionInput{}); err == nil {
3737
region = regionOverride.Region
38+
cfg.Region = region
3839
}
3940
}
4041
}

0 commit comments

Comments
 (0)