This content originally appeared on DEV Community and was authored by Wojciech Lepczyński
The Instance Metadata Service (IMDS) is a feature of Amazon Web Services (AWS) Elastic Compute Cloud (EC2) instances that provides a way for EC2 instances to learn about themselves and their environment. Instance Metadata Service (IMDS) allows you to access data about your ec2 instance which you can use to configure or manage a running instance:
There are two versions of IMDS: IMDSv1 and IMDSv2.
IMDSv2 is the latest version of the service and was introduced to address several security concerns with IMDSv1. Unlike IMDSv1, IMDSv2 is protected by a session token that is obtained using instance credentials, making it much more secure.
Important information about IMDSv2:
- There is no limit to the number of tokens.
- There is no limit to the number of sessions.
- The new version is still limited by normal IMDS connection and throttling limits.
- Sessions can last up to six hours, that is, up to 21600 seconds
Let's go deeper, first generate a token with the following command:
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
Now you can use the token, for example with the following command:
curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-id/
If you are interested in the topic, you will learn more about IMDS from my video:
or from my blog:
https://lepczynski.it/en/other/information-about-ec2-from-ec2-imds-imdsv2/
This content originally appeared on DEV Community and was authored by Wojciech Lepczyński
Wojciech Lepczyński | Sciencx (2023-05-13T20:34:58+00:00) Why should you use IMDSv2 and not IMDS on AWS EC2. Retrieved from https://www.scien.cx/2023/05/13/why-should-you-use-imdsv2-and-not-imds-on-aws-ec2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.