Skip to content

Commit

Permalink
Changed the error to more understandable when the region code isn't set
Browse files Browse the repository at this point in the history
  • Loading branch information
a2ush committed Feb 2, 2024
1 parent b39bb66 commit 634321b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func newAWSProvider(spec *api.ProviderConfig, configurationLoader AWSConfigurati
}

if spec.Region == "" {
if cfg.Region == "" {
return nil, fmt.Errorf("no region code: please set the AWS region to ~/.aws/config file or environment variables")
}
spec.Region = cfg.Region
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/eks/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ var _ = Describe("eksctl API", func() {
},
err: fmt.Sprintf("cache file %s is not private", cacheFilePath),
}),
Entry("region code is not set", newAWSProviderEntry{
updateFakes: func(fal *fakes.FakeAWSConfigurationLoader) {
fal.LoadDefaultConfigReturns(aws.Config{
Region: "",
}, nil)
},
err: fmt.Sprintf("no region code: please set the AWS region to ~/.aws/config file or environment variables"),
}),
Entry("creates the AWS provider successfully", newAWSProviderEntry{}),
)

Expand Down

0 comments on commit 634321b

Please sign in to comment.