The AWS Instance Scheduler is a simple AWS-provided solution that enables customers to easily configure custom start and stop schedules for their Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Relational Database Service (Amazon RDS) instances. The solution is very easy to implement and One can save up to 70% compared to running those instances 24 hours a day.

You can deploy This method for EC2 or for RDS or For Both at the same time

AWS Solution Implementation overview?

List of services 

  • Amazon DynamoDB
  • Amazon CloudWatch
  • AWS Lambda
  • Amazon Ec2
  • Amazon RDS
  • CloudFormation

Prerequisites: 

Launched Ec2 server 

RDS Database 

Steps 

  1. Launch CloudFormation Template  

You can Directly Launch the template from Given link or You can Download the Link and Then You can Upload It Directly. So, the Best method is to launch it directly by clicking Here

https://aws.amazon.com/solutions/implementations/instance-scheduler/

After Clicking on Above button, it will Redirect to creation of Stack in Your AWS Console. Proceed Next with S3 URL

2. Step Specify template

3. Step Specify Stack Detail

 In the specified stack Details Step, you have to mention the Name of stack Choose the Service You want to schedule it may b EC2, RDS or Both. We will not do anything in the Region column which means we are Moving with the Default Region.

In the default Time zone column, you can Just select Your timeZone like Asia/Karachi. There is a Frequency Column which determines the time of Invoke in minutes for Lambda Function. You can choose 1 2 5 10 15 …

SELECT memory size and SELECT yes for CloudWatch Logs .in Retention select the days you want to keep the Schedule logs.

The Most important Part is Stopping Tags and starting Tags.

4. Configure stack options You can Add tags but these are optional and You can move Next 5. Review  On the Review page, review and confirm the settings. Be sure to check the box acknowledging that the template will create AWS Identity and Access Management (IAM) resources.

After Creating the Stack 

You will See all the resources will be created. You can check this in the Resource tab.

It will create DynamoDB Tables as well.

In DynamoDB You can check like 

   In Lambda

In DynamoDB we can change Time accordingly

 After clicking On Period Here You Can Put start time and End Time according to     Office Hours. Even You duplicate This in action.

Similarly, with the same Method  can Duplicate The period by selecting Duplicate

we will duplicate the Schedule and Period in configuration file in DynamoDB where we will put our time zone and will set Time of stopping and starting Instance.

We have launched the instance in the same Regions we Go into Ec2 Section where we will select the Instance which we want to be scheduled.

go into Tag Option there and put the tag and value we have set in DynamoDB. The Tag and Value we can choose from DynamoDB Config File.

After a time period we have selected to stop and Start for our instance has been stopped Automatically. Now you can see this there is another tag which means instance has been stopped by scheduler

Conclusion 

Tagging is Most important Because AWS instance scheduling Works on the Basis of Tagging Concept. it will Automatically stop and start the instance According to the time period we fix.customers can control their resource capacity and pay only for what they use When resources are stopped.