When using Amazon EC2 for a while, you will pay attention to Userdata and Metadata. It sounds a bit similar, so you may be confused and this is also a good question in the AWS certification exam at Cloud practitioner or Associate level.
Instance Metadata:
- Help to configure or manage EC2 instance. Eg: IP Address, DNS hostname, AMI ID, Instance-ID, Instance type, public keys, security group…
- Metadata can only be viewed when logged into the EC2 instance.
- The metadata is displayed in plaintext (not encrypted) so anyone with access to the EC2 instance can see this information.
- To view EC2 instance metadata use the following command:
- Command 1: cat http://169.254.169.254/latest/meta-data
- Command 2: curl http://169.254.169.254/latest/meta-data
Instance Userdata:
- Data supplied by user when the instance is launched. Userdata is a script that is executed during instance boot.
- Userdata size limit: 16KB
- You must login to view userdata
- You need to stop the instance before making changes to Userdata.
- Userdata is not encrypted.
Userdata and Metadata are both free of charge.
Have fun!