0 votes
1 view
in AWS by (16.7k points)

Is there a straightforward way to access AWS instance metadata from within a Docker container?

For example, when trying to fetch credentials for an IAM role on an EC2 instance, this would work on the instance itself:

...but not from within a Docker container running on that EC2 instance.

1 Answer

0 votes
by (39.6k points)

This container can be used to access EC2 metadata directly:

root@f1e5646e23:/# curl


  "Code" : "Success",

  "LastUpdated" : "2019-07-14T15:04:12Z",

  "Type" : "AWS-HMAC",

  "AccessKeyId" : "accesskey",

  "SecretAccessKey" : "secretkey",

  "Token" : "mytoken",

  "Expiration" : "2019-04-14T21:08:29Z"