When deploying a new cloud server instance, you can set user data for an instance, which is useful for startup scripts. You can also update the user data for an instance.
To set user data on a new deployment, include Base64 encoded user data in the call to /v1/server/create
endpoint.
To update user data, use the /v1/server/set_user_data
endpoint to set Base64 encoded user data.
$ curl https://api.vultr.com/v1/server/set_user_data \
-H 'API-Key: YOUR_API_KEY' \
--data 'SUBID=YOUR_SUB_ID' \
--data 'userdata=QmUgU3VyZSBUbyBEcmluayBZb3VyIE92YWx0aW5lLgo='
To retrieve user data, use the Metadata API /latest/user-data
endpoint from the running instance. The Base64 encoded value is decoded and returned as text.
# curl http://169.254.169.254/latest/user-data
Be Sure To Drink Your Ovaltine.
If you update a running instance, the /latest/user-data
Metadata endpoint will return old values until the instance is rebooted or reinstalled.
You could earn up to $300 by adding new articles