'Amazon.Runtime.AmazonServiceException: Unable to get IAM security credentials from EC2 Instance Metadata Service

I'm using .net6 and used docker to deploy into azure but in production, I got the error "Unable to get IAM security credentials from EC2 Instance Metadata Service"

Package I'm using "Kralizek.Extensions.Configuration.AWSSecretsManager" Version="1.6.3"

I'm adding credentials for AWS secret manager. Its works when I change the environment variable to production but does not work when I deployed

builder.Configuration.AddSecretsManager(
    credentials: new BasicAWSCredentials("xxxx", "xxx+xxx"),
    region: RegionEndpoint.APSoutheast1,
    configurator: options =>
    {
        options.SecretFilter = entry => entry.Name.StartsWith($"{env}_{appName}_");
        options.KeyGenerator = (_, s) => s.Replace($"{env}_{appName}_", string.Empty).Replace("__", ":");
    }
);

I also tried to add IAM full access to that user role -> but it is not working

I also tried editing the credentials file in .aws -> not working



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source