Metadata is an important concept in the IT world. In short, it simply is data about your data. For EC2, metadata is the information about your EC2 instance, such as the public ip address, or the security groups it belongs to.
How do we access the EC2 metadata, or info about our instance once we logged in? Let’s do that now.
- Firstly, Launch and Connect to an EC2 instance. Click on the link to learn how to do that. I’ll probably do a post on it, since it is a fundamental skill to know how to do. I’ve done it a bunch of times already, so it’s become second nature.
- Secondly, give yourself administrator rights once you’ve logged into the instance. The command is: “SUDO SU“
- Now, we access the metadata of the instance at the URL: http://169.254.169.254/latest/meta-data. Use the curl command.
- Next, we store some metadata on your EC2 instance using the write command “>” . I circled it up top.
- After you see the download finished, open the file to verify the metadata has been written. I’m using the VI editor to view the file. You can use other editors, like nano if you wish.
And there you have it. We logged onto our EC2 instance, then we fetched the metadata of the instance, and wrote it to a file.