diff --git a/pkg/eks/api.go b/pkg/eks/api.go index 24aeeb8588..f1c0551bb1 100644 --- a/pkg/eks/api.go +++ b/pkg/eks/api.go @@ -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 } diff --git a/pkg/eks/api_test.go b/pkg/eks/api_test.go index e477ecc1e7..43dc6cc662 100644 --- a/pkg/eks/api_test.go +++ b/pkg/eks/api_test.go @@ -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{}), )