Skip to content

Commit

Permalink
Merge pull request #7523 from a2ush/fix
Browse files Browse the repository at this point in the history
Check for empty region before invoking API in AWS SDK
  • Loading branch information
yuxiang-zhang committed Feb 12, 2024
2 parents 87e12f2 + 1b84a48 commit fade871
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ func newAWSProvider(spec *api.ProviderConfig, configurationLoader AWSConfigurati
return nil, err
}

if cfg.Region == "" {
return nil, fmt.Errorf("AWS Region must be set, please set the AWS Region in AWS config file or as environment variable")
}

if spec.Region == "" {
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: "AWS Region must be set, please set the AWS Region in AWS config file or as environment variable",
}),
Entry("creates the AWS provider successfully", newAWSProviderEntry{}),
)

Expand Down

0 comments on commit fade871

Please sign in to comment.