.Net Core AWS - No RegionEnpoint or ServiceURL confifgured

Viewed 97

I have a .NET Core MVC application, and when starting up the project to run locally, I get the Amazon.Runtime.AmazonClientException: 'No RegionEndpoint or ServiceURL configured' error. I've followed the AWS walkthroughs to troubleshoot the issue, but to no avail. No other dev on my team is seeing this issue. I have the proper profile setup and everything is identical to the other devs on my team. Here are the things I've attempted thus far:

  • Uninstall and reinstall AWS Toolkit and CLI
  • Delete the .aws directory and recreate profile in CLI
  • Delete the .aws directory and recreate profile in AWS Explorer
  • Delete the "region" option in the credential file
  • Revert all changes on existing project
  • Delete entire repo and re-clone

The 3rd line (the singleton addition) is where the code chokes:

            var awsOptions = Configuration.GetAWSOptions();
            services.AddDefaultAWSOptions(awsOptions);
            services.AddSingleton<IAmazonS3>(new AmazonS3Client()); //breaks

When I put a watch on the awsOptions variable, it shows the region is being picked up by my profile. The appsettings.json and debug profile specific appsettings.json both have the same region set.

1 Answers

Turns out the reason why it worked for some and not all was a race condition, in that the extension in which this code resided ran after the startup already established that service, hence the error. While not descriptive to that end, that was the fix.

Related