Skip to content

Instantly share code, notes, and snippets.

@abuxton
Last active August 15, 2024 14:00
Show Gist options
  • Save abuxton/ba10f31ecaa100f2ccaa75c10f251f9b to your computer and use it in GitHub Desktop.
Save abuxton/ba10f31ecaa100f2ccaa75c10f251f9b to your computer and use it in GitHub Desktop.
debugging cloud-init and user_data on cloud platforms

Debugging cloud-init and user_data

cloud init

generic cloud init help and docs

AWS

treats user data and cloud init as cloud-init

  • logs to
    • /var/log/cloud-init.log
    • /var/log/cloud-init-output.log

Azure

** There is a known bug with support of cloud-init on ertain distrubutions of linux**

GCP

**GCP DOES NOT support CLOUD-INIT (even under RHEL) without help generally if your setting CLOUD init you need a custom image **

VMWARE

Gists

user_data

AWS

# If you add the -v --verbose flag
# Or the -i --include flag
curl -v  http://169.254.169.254/latest/
curl -i  http://169.254.169.254/latest/
# You'll see HTTP/1.1 401 Unauthorized
export TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")

echo $TOKEN

curl -H "X-aws-ec2-metadata-token: $TOKEN" -i http://169.254.169.254/latest/
# ^-- now says HTTP/1.1 200 OK

# A nice shorthand hack to make v2 feel like v1
# (that's probably best done in the active shell only)
# and not in a .bashrc or .zshrc file
alias curl='curl -H "X-aws-ec2-metadata-token: $TOKEN"'
curl -i http://169.254.169.254/latest/
# ^-- now says HTTP/1.1 200 OK

linux

Windows

Azure

GCP

GCP uses a go app called google_metadata_scrpt_runner **GCP DOES NOT support CLOUD-INIT (even under RHEL) without help generally if your setting CLOUD init you need a custom image **

The script can be run locally from the instance

VMWare

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment