User-data script¶
Example¶
#!/bin/sh
echo "Hello World" > /var/tmp/output.txt
Explanation¶
A user-data script is a single script to be executed once per instance. User-data scripts are run relatively late in the boot process, during cloud-init’s final stage as part of the cc_scripts_user module.
Note
To execute scripts on every boot or only once per machine lifetime,
use a MIME multi-part archive
with the frequency-specific MIME types (text/x-shellscript-per-boot
or text/x-shellscript-per-once).
Warning
Use of INSTANCE_ID variable within user-data scripts is deprecated.
Use jinja templates with
v1.instance_id instead.