Skip to content

Commit

Permalink
fix: Find region correctly from EC2 IMDS (#549)
Browse files Browse the repository at this point in the history
When running on an EC2 instance with an instance profile / role, chamber
now finds the region correctly.
  • Loading branch information
bhavanki authored Aug 13, 2024
1 parent e79a864 commit c2d3399
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion store/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ func getConfig(ctx context.Context, numRetries int, retryMode aws.RetryMode) (aw
// If region is still not set, attempt to determine it via ec2 metadata API
if cfg.Region == "" {
imdsConfig, err := config.LoadDefaultConfig(ctx)
if err != nil {
if err == nil {
ec2metadataSvc := imds.NewFromConfig(imdsConfig)
if regionOverride, err := ec2metadataSvc.GetRegion(ctx, &imds.GetRegionInput{}); err == nil {
region = regionOverride.Region
cfg.Region = region
}
}
}
Expand Down

0 comments on commit c2d3399

Please sign in to comment.