Tuesday, March 5, 2019

HowTo Check the logs for EC2 user_data

HowTo Check the logs for EC2 user_data



Recently, I have created Terraform project to launch EC2 with IAM users, security groups and other configuration parameters as required and along with this, I have rendered a script file to be executed as part of EC2 user_data

There were some errors and during unit testing, the EC2 were launched but the actions listed in the script file weren't performed on the EC2 and this lead to the analysis and search for where & how of EC2 logs for user_data

Firstly, we can see the logs in the /var/log/ folder of the EC2 just launched



Next, check in the 'cloud-init-output.log' for analysing why the commands/steps in the user_data script were not executed or failed

A quick glimpse of the error I encountered was this


Basically, I had commands to copy certain files into the target directory but those werent present in the source directory, as required. Post checking this logs, I have arranged files/folders in expected locations and Voila, all set !!!

No comments:

Post a Comment