Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EC2 Instance Remotely Start

Can someone elaborate more on the details of how to remotely start a EC2 instance remotely?

I have a Linux box set up locally, and would like to set up a cronjob on it to start an instance in Amazon EC2. How do I do that?

I've never worked with API's, if there are ways to use API's, can someone please explain how to do so...

like image 697
user1480718 Avatar asked Sep 09 '26 17:09

user1480718


1 Answers

Pretty Simple.

  1. Download EC2 API. There is a CLI with it.
  2. keep EC2_PRIVATE_KEY and EC2_CERT in as your envt variables, where they are private key and certificate files that you generate from EC2 console.
  3. then call ec2-reboot-instances instance_id [instance_id ...]

Done.

Refer: http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RebootInstances.html


Edit 1

Do I download this directly onto my Linux box? And how do I access the CLI on the linux box of the EC2 API? Sorry to ask so many questions, just need to know detailed steps of how to do this.

  1. Yes. Download it from here

  2. If you have unzipped the API in /home/naishe/ec2api, you can call /home/naishe/ec2api/bin/ec2-reboot-instance <instance_id>. Or event better set unzipped location as your envt variable EC2_API_HOME and append $EC2_API_HOME/bin to your system's PATH.

Also, try investing some time on Getting Started Doc which is amazingly simple.

like image 157
Nishant Avatar answered Sep 11 '26 18:09

Nishant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!