Code

No RegionEndpoint or ServiceURL configured exception

No RegionEndpoint or ServiceURL configured

I recently switched to a new laptop for work and I was running into an issue when running some unit tests. I got this error message:

No RegionEndpoint or ServiceURL configured

I thought it was strange because I wasn’t actually trying to connect to AWS I was just running unit tests that covered some AWS logic. Getting this error had me digging quickly.

The issue turns out I was missing a credentials file for AWS on my local machine. Even though the unit test wasn’t actually hitting AWS it still needed some local credentials to execute the test.

How do you fix a “No RegionEndpoint or ServiceUrl configured” exception?

You need to verify if you have a credential file locally. The credential file should be located at the following folder location on your local machine (windows):

C:\Users\[yourusername]\.aws

If you are missing this .aws folder altogether you may need to install the AWS CLI.

Open your command prompt and type in the following command:

aws configure

See here for complete instructions on setting up the AWS CLI

The AWS CLI configuration will ask you for the following:

  • AWS Access Key ID
  • AWS Secret Access Key
  • Default region name
  • Default output format

After you complete this setup check your folder path above for the .aws folder location and verify you have a credentials file.

If you still get the “No RegionEndpoint or ServiceUrl configured” exception after installing the CLI double-check the .aws/credentials file and make sure a default region is set up in the file.

Here is an example of how the file should look:

[default]
aws_access_key_id = YOUR_AWS_ACCESS_KEY
aws_secret_access_key = YOU_AWS_SECRET_ACCESS_KEY
output=json
region=us-west-1

You also have the option to just create the folder and file yourself and not install the AWS CLI. But if you plan on working with AWS you might as well go through the steps of setting up the AWS CLI for future development use.

Leave a Reply

Your email address will not be published.