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

Categories: TL;DR

0 Comments

Leave a Reply

Avatar placeholder