Published 1月 08, 2020 by with 0 comment

Amazon EC2 - Labs - 03 - Metadata



AWS > Compute > Amazon Elastic Compute Cloud (EC2):
Instance metadata is data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into categories, for example, host name, events, and security groups.

Because your instance metadata is available from your running instance, you do not need to use the Amazon EC2 console or the AWS CLI. This can be helpful when you're writing scripts to run from your instance. For example, you can access the local IP address of your instance from instance metadata to manage a connection to an external application.

To view all categories of instance metadata from within a running instance, use the following URL.
http://169.254.169.254/latest/meta-data/

Lab Configuration:
# Get instance Metadata
[root@ip-172-31-22-213 ec2-user]# curl http://169.254.169.254/latest/meta-data/

# Get instance public IPv4 address
[root@ip-172-31-22-213 ec2-user]# curl http://169.254.169.254/latest/meta-data/public-ipv4

# Get instance public IPv4 address and output to file
[root@ip-172-31-22-213 ec2-user]# curl http://169.254.169.254/latest/meta-data/public-ipv4 > public-ipv4.txt

# Get instance user data
[root@ip-172-31-22-213 ec2-user]# curl http://169.254.169.254/latest/user-data



Reference:
1. AWS Documentation - Configuring the Instance Metadata Service:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html

2. Udemy - AWS Solutions Architect - Associate:
https://www.udemy.com/aws-certified-solutions-architect-associate/


最初發表 / 最後更新: 2020.01.08 / 2020.06.08

0 comments:

張貼留言