I have a .Net Core application that runs on an EC2 instance. I am looking this application to get the secrets I have stored on the Secrets Manager.
I have created a IAM Role that allows the Ec2 instance to access the secrets manager. However this is where I am stuck I don't know how to make use of that in my application nor can I find any tutorials online. Could some one explain how my application should access this the instance profile so I can retrieve the from secrets manager through their API.
Thank you.
You don't need to access the instance profile, the SDK does that for you. You just need to create a new instance of the client, and then use it.
var client = new Amazon.SecretsManager.AmazonSecretsManagerClient(Amazon.RegionEndpoint.USEast1);
var response = await client.GetSecretValueAsync(new Amazon.SecretsManager.Model.GetSecretValueRequest
{
SecretId = "mySecretIdOrArn"
});
var secretString = response.SecretString;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With