Reputation: 862
I want to make a schedule and apply it to EC2 instances. How can I make schedule by using java sdk? for example, my schedule should contain policy that start instance at 7 am and stop instance at 6 pm.
Upvotes: 0
Views: 366
Reputation: 16599
This can be very easily achieved by using a lambda function triggered by a cron pattern. Make sure to assign a role with permissions to start/stop your instances to the lambda function.
CloudWatch Events
under the section Add Triggers
;cron(0 7,18 * * *)
;References:
1. Using AWS Lambda with Scheduled Events
2. Tutorial: Starting an EC2 Instance (Java SDK)
Upvotes: 2