Get the role name
wget http://169.254.169.254/latest/meta-data/iam/info
will get something like:
{ "Code" : "Success", "LastUpdated" : "2020-03-06T20:34:08Z", "InstanceProfileArn" : "arn:aws:iam::3940394039403:instance-profile/ProfileName", "InstanceProfileId" : "kasdjaksjakjsa" }
or better yet, get the role name from:
wget http://169.254.169.254/latest/meta-data/iam/security-credentials
It will be the name of the only entry returned.
then get credentials with:
wget http://169.254.169.254/latest/meta-data/iam/security-credentials/ProfileName
will get something like:
{ "Code" : "Success", "LastUpdated" : "2020-03-06T20:33:39Z", "Type" : "AWS-HMAC", "AccessKeyId" : "SDFDFSDFSDFSDFS....", "SecretAccessKey" : "salkdfsldfklsdkf....", "Token" : "sdfksldkfldksfldskflksdfsd...", "Expiration" : "2020-03-07T02:37:16Z" }
References
- https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-creds.html
- https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-hosm.html#net-dg-roles
- https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/Credentials/_bcl+netstandard/InstanceProfileAWSCredentials.cs
0 Comments