Read an instance's user data

Read the cloud-init script an instance was launched with, which describing the instance never returns.

Last updated 18 November 2026View as Markdown

Describing an instance (GET /ec2/api/instances, GET /ec2/api/instances/{id}, the instances of a security group, every console page) never returns its user data: a boot script is where credentials tend to be written. It is read on its own, with its own permission.

Prerequisites

  • Permission for ec2:GetInstanceUserData. It is a sensitive read: it is not in the read-only presets, and every use, allowed or refused, is written to the audit log.

Read it

Not available in Console. The console never shows user data after launch.

Result

data.userData is the script as you wrote it, or null when the instance was launched without one. An instance that is not yours answers 404 "Instance not found"; without the permission the answer is 403. It is your script only: what the platform adds to the machine's first boot (see What runs on your machines) is not in it, nor is the instance's identity secret.

Did this page help you?