Reputation: 1399
I am launching an EC2 through a cloudformation template but it keeps shutting down after a few minutes, possibly some restrictions my company may have in place. I don't have any indication why it is shutting down though, are there logs anywhere I can look at to find out? Thanks
Upvotes: 2
Views: 3424
Reputation: 905
You can easily find the reason in the cloudformation console itself.
In the console select the stack for your EC2. In the bottom check you can see a tab called EVENTS
. Click on that. You will find every information there.
Upvotes: 1
Reputation: 627
First, have you verified that it's not a startup error in your own stack? Check the stack status, and if it says "rollback complete" the error is yours. Generally this is caused by a bad cloud-init script, and they can be a pain to diagnose, because the logs go away when the instance terminate (another answer tells you how to retrieve the system log, but it's only one of the logs used during startup).
To verify whether it's an automated process that shuts down the log, you can use CloudTrail (assuming that you have access). You're looking for a TerminateInstances
event that references your instance; the event details will show the name of the user that took the action.
Upvotes: 3
Reputation: 1638
For ec2 instance logs :- Select your EC2 instance go to Actions under action go to Instance settings and then select Get system logs . Here you will get logs of ec2 instance.
for cloudformation logs :- Select you cloudformation stack and under Events you will get all logs of cloudformation.
to solve this check you access rights of IAM user .
Upvotes: 3
Reputation: 7407
You can have a look at the StateReason
using this command with aws-cli
:
aws ec2 describe-instances --instance-id i-xxxxxxx --query "Reservations[*].Instances[*].StateReason"
It's also available from the console:
Upvotes: 1