Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether my user data passing to EC2 instance working or not?

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?

like image 685
Pravin Avatar asked Apr 09 '13 14:04

Pravin


People also ask

How do I know if my EC2 instance is working?

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.

Where is user data on EC2 instance?

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.

Does EC2 user data run on reboot?

By default, user data scripts and cloud-init directives run only during the first boot cycle when an EC2 instance is launched.

How can I send user data output to the console logs on an EC2 instance running Ubuntu?

Enter the following command to redirect the user-data output console: #!/bin/bash -xe exec > >(tee /var/log/user-data.


2 Answers

You can verify using the following steps:

  1. SSH on launch EC2 instance.
  2. Check the log of your user data script in:
    • /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.

like image 104
Ravi Prajapati Avatar answered Oct 14 '22 18:10

Ravi Prajapati


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

enter image description here

In the old interface: Instance Settings > Get System log

enter image description here

This should open a modal window with the system logs

enter image description here

like image 27
Shankar ARUL Avatar answered Oct 14 '22 20:10

Shankar ARUL