How to check whether my user data passing to EC2 instance is working
Verification Steps
- SSH into your launched EC2 instance
- 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
Source: Stack Overflow Discussion