How to check whether my user data passing to EC2 instance is working

January 26, 2024

Verification Steps

  1. SSH into your launched EC2 instance
  2. Check the following log files:
    cat /var/log/cloud-init.log
    cat /var/log/cloud-init-output.log

What to Look For

  • Complete script execution logs in cloud-init.log
  • Script output and errors in cloud-init-output.log
  • Creation of /etc/cloud directory

Additional Verification Methods

Command Purpose
cloud-init status Check cloud-init service status
ls -l /etc/cloud Verify cloud directory creation
grep cloud-init /var/log/syslog Search system logs for cloud-init entries

Best Practices

  • Include logging statements in your user data script
  • Check logs immediately after instance launch
  • Monitor script execution time
  • Verify expected file/directory creation
  • Test scripts locally when possible
#AWS #EC2 #CloudInit #DevOps