While creating a new AWS EC2 instance using the EC2 command line API, I passed some user data to the new instance.
How can I know whether that user data executed or not?
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Instances. On the Instances page, the Status check column lists the operational status of each instance. To view the status of a specific instance, select the instance, and then choose the Status checks tab.
When a user data script is processed, it is copied to and run from /var/lib/cloud/instances/ instance-id / . The script is not deleted after it is run. Be sure to delete the user data scripts from /var/lib/cloud/instances/ instance-id / before you create an AMI from the instance.
By default, user data scripts and cloud-init directives run only during the first boot cycle when an EC2 instance is launched.
Enter the following command to redirect the user-data output console: #!/bin/bash -xe exec > >(tee /var/log/user-data.
You can verify using the following steps:
/var/log/cloud-init.log
and/var/log/cloud-init-output.log
You can see all logs of your user data script, and it will also create the /etc/cloud
folder.
Just for reference, you can check if the user data executed by taking a look at the system log from the EC2 console. Right click on your instance -
In the new interface: Monitor and Troubleshoot > Get System Log
In the old interface: Instance Settings > Get System log
This should open a modal window with the system logs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With