Bilgin Ibryam
Bilgin Ibryam

Reputation: 3385

AWS - How to reboot or restart EC2 instance from CloudWatch Alarm?

Sometimes my application dies without any reason and I can detect that using CloudWatch and CPU usage metric going down.

At this moment I want to restart the java application or the whole EC2 instance.

Any suggestions how can I achive that?

Thanks.

Upvotes: 3

Views: 3569

Answers (4)

Jerry Chong
Jerry Chong

Reputation: 9220

You can configure in Cloudwatch Alarm EC2 Action for reboot the instance.

Screenshot: enter image description here

References:

Upvotes: 0

Weiwu
Weiwu

Reputation: 41

AWS CloudWatch now provides a reboot EC2 instance action.

Upvotes: 4

Tom
Tom

Reputation: 257

You can let CloudWatch terminate your EC2 instance and let AutoScaling bring up another "fresh" instance with your application configured.

Upvotes: 2

Dan
Dan

Reputation: 108

If only your application halt but EC2 instance works.

You could write a shell monitor the app using CloudWatch API and shoot the app when necessary,then make it a task in cron. Or you can using a shell right in your EC2 instance.

To restart your EC2 instance automatically is way too dangerous ,you can try Autoscaling, which automatically starts a new instance when your instance frozen and keep your SLA.

Upvotes: 0

Related Questions