Vibin Guevara
Vibin Guevara

Reputation: 826

Automate AWS instance start and stop

I'm running a instance in amazon AWS and it runs non-stop everyday. I'm using ubuntu ec2 instance which is running Apache, Mirthconnect tool and LAMP server. I want to run this instance only on particular time duration of a day. I prefer not use any additional AWS services such as cloud-watch . Is there a way we could acheive this?.

The major purpose is for using Mirthconnect fetching data from mysql database

Upvotes: 1

Views: 1388

Answers (2)

helloV
helloV

Reputation: 52393

There are 3 solutions.

AWS Data Pipeline - You can schedule the instance start/stop just like cron. It will cost you one hour of t1.micro instance for every start/stop

AWS Lambda - Define a lambda function that gets triggered at a pre defined time. Your lambda function can start/stop instances. Your cost will be very minimal or $0

Write a shell script and run it as a cron job or run it on demand. The script will have AWS CLI command to start and stop the instance.

I used Data Pipeline for a long time before moving to Lambda. Data Pipeline is very trivial. Just paste the AWS CLI commands to stop and start instances. Lambda is more involved.

Upvotes: 1

Sanket Patel
Sanket Patel

Reputation: 386

I guess for that you'll need another machine which is on 24x7. On which you can write cron job in python using boto or any other language like bash.

I don't see how you start a instance in stopped state without using any other machine.

Or you can have a simple raspberry pi on at your home which does the ON-OFF work for you using AWS CLI or simple Python. How about that? ;)

Upvotes: 0

Related Questions