AWS DotNet SDK Error: Unable to get IAM security credentials from EC2 Instance Metadata Service

I had the same issue, here is how I fixed it on my development environment

  1. I created an AWS profile using the AWS extension for Visual studio
  2. Once the profile is set up the credentials are passed using the profile and it worked fine for me

Point to note here, the user profile accessing the key manager should have a valid security group assigned for the Secrets manager.

Try it out let me know, how it went.


Same issue and resolved by deleting $HOME/.aws/config and credentials files and recreating with AWS CLI.

In my case I was switching laptops from Windows to a new MBP. I had setup my new environment by copying the .aws directory files and confirmed that AWS CLI worked correctly. Confusingly the dotnet SDK failed with same errors.