When an AWS instance starts, it can get information about itself called metadata by accessing a special IP address 169.254.169.254. This metadata includes things like the instance ID. The instance can also get user data, which is a script provided at launch time. The instance runs this script once to set itself up. For example, the instance can get its ID by requesting the metadata URL and get a setup script by requesting the user data URL. Then it runs the script to create files or install software. Metadata is fixed and does not change after launch. User data is optional and runs only once. This process helps automate instance configuration without manual steps.