Reputation: 1811
I am trying to switch profiles in code using appsettings.json for a .net core web service. If I new up an instance of the client in code eg:
using var client = new AmazonSecretsManagerClient();
client.ListSecretsAsync(listRequest, default)
.GetAwaiter()
.GetResult();
this takes the default profile that was set up and works fine.
Instead of using the default profile, I want to control the profile from json file. I am trying to follow this:
https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/net-dg-config-netcore.html
Instead of newing up the client, I am using dependency injection
public SecretsService(IAmazonSecretsManager secretsManagerClient)
{
_secretsManagerClient = secretsManagerClient;
}
Here is the config:
"AWS": {
"Profile": "default",
"Region": "us-east-2"
}
When I make a call using,
_secretsManagerClient.ListSecretsAsync(listRequest, default)
.GetAwaiter()
.GetResult();
it gives an exception
No such host is known. (secretsmanager.defaultregion.amazonaws.com:443)
What am I missing?
Upvotes: 0
Views: 863
Reputation: 223
Check your appsettings.Development.json file. Some templates have the region set as DefaultRegion and so you have to either update it or remove it to let appsettings.json take precedence.
Upvotes: 0