AWS – You can now use Instance Scheduler to configure automatic start and stop of your EC2 instances

As you know, running workloads on cloud services requires to implement cost management and optimization to not get nasty surprises with your consumption bills.

One of the solution applicable to your virtual machines is to automatically start and stop them to match your business need.

To start using AWS Instance Scheduler with your EC2 instances, get the templates for your CloudFormation:

  • instance-scheduler.template to launch the Instance Scheduler and all associated components. The default configuration deploys an AWS Lambda function, an Amazon DynamoDB table, an Amazon CloudWatch event, and CloudWatch custom metrics, but you can also customize the template based on your needs
  • instance-scheduler-remote.template if you want to configure permissions for secondary accounts. The default configuration creates the AWS Identity and Access Management (IAM) roles necessary to start and stop instances in a secondary account.

Then connect to your AWS console (https://console.aws.amazon.com/) to access your CloudFormation stack.

image_thumb

Then create (or edit) a stack by either uploading your templates (from above links) or providing link to the S3 URL

image_thumb[1]

Then define the various stack parameters; you may have to update the default time zone.

The stack creation process will create few new resources, such as 2 new IAM roles (SchedulerRole and instanceschedulerlambdaLambdaFunctionServiceRole<id>), a new IAM policy (EC2DynamoDBPolicy) or a new DynamoDB table (ConfigTable).

Then you can edit the Config table of the DynamoDB database to edit the period and schedule items to match your requirements (starting time, timezone…)

image_thumb[2]

Your CloudFormation stack is now ready to be used for resource deployment.