image
Creating Periods and Schedules Demo

Contents

Course Introduction
1
Introduction
PREVIEW2m 18s
Cost Management
3
Credits
PREVIEW1m 52s
5
Reports
PREVIEW1m 30s
7
Budgets
6m 51s
Improve Planning and Cost Control with AWS Budgets
AWS Cost Management: Tagging
13
Tagging
PREVIEW6m 51s
Understanding & Optimizing Storage Costs with AWS Storage Services
16
Amazon S3 and Glacier
PREVIEW16m 56s
18
20
AWS Backup
PREVIEW3m 50s
Using Instance Scheduler to Optimize Resource Cost

The course is part of this learning path

Start course
Difficulty
Intermediate
Duration
2h 33m
Students
151
Ratings
5/5
starstarstarstarstar
Description

This section of the AWS Certified Solutions Architect - Professional learning path introduces you to cost management concepts and services relevant to the SAP-C02 exam. By the end of this section, you will know how to select and apply AWS services to optimize cost in scenarios relevant to the AWS Certified Solutions Architect - Professional exam. 

Want more? Try a Lab Playground or do a Lab Challenge

Learning Objectives

  • Learn how to improve planning and cost control with AWS Budgets
  • Understand how to optimize storage costs
  • Discover AWS services that allow you to monitor for underutilized resources
  • Learn how the AWS Instance Scheduler may be used to optimize resource costs
Transcript

After you upload the Instance Scheduler CloudFormation template, you can then view all the resources the stack created. For example, here, I am in the DynamoDB dashboard and I can see the stack created three different tables: the config table, the maintenance window table, and the state table. 

The most important of these three is the config table. This table is where schedules and periods are defined. If I click on “explore table items”, you can see there are examples of schedules and periods already propagated in the table. I can also see the attributes for each of these items. For example, periods have a “begin time” and “end time” attribute. Schedules have an attribute to define the period, and an attribute for the time zone and more. 

Let’s look at one of these Schedules in more depth. I’ll click on the Seattle-office-hours schedule. I can see the type is schedule, the name is seattle-office-hours, it has a description, the time zone is us/pacific since Seattle is on pacific time. And then it defines the period. If I click the + box next to period, I can see which period it uses. In this case, it uses the office-hours period. 

Now, I’ll click cancel and find the office-hours period to see how this schedule runs. I’ll find it in the list, and click on it. And now I can see it has a type of period, the name office-hours, and a description. It also has a begin_time of 9:00 and an end_time of 17:00, which is military time that converts to 5 pm. It also specifies the days of the week that the instance runs by using the weekdays keyword. If I click the plus next to weekdays, I can see that these instances run 9 to 5, Monday through Friday. This means these instances are in the stopped state on weekends and after 5 pm on weekdays.

I can use these examples to create my own custom periods and schedules. For example, let’s duplicate the office-hours period and customize it to stop one of my instances currently running in the next 10 minutes. To do this, I’ll click cancel. Actions. And then duplicate item. I’ll name this one stop-in-ten-minutes and then give it a quick description “shuts down an instance at 10:55 am every Tuesday”. 

I’ll then specify my begintime and endtime. This is the time period you’d like your instance to run. It’s written in the format of HH:MM using military time. In my case, I’ll say my begin_time is 10:45. Then I’ll specify my end_time, which is ten minutes from then, at 10:55 am. Then I can specify the days I want this to run. I can choose from weekdays, months, or monthdays. Each of these are a bit unique in how you operate them. 

For example, say I use the period months. You can define months using the first three letters of the month, such as Jan, Feb, Mar or you can use numbers starting at 1. January would be 1, February would be 2, and so on. To select a range of months, you can use a hyphen, such as 1-5 or Jan-May. You can also specify lists using commas, such as 1, 2, 3 to specify the number of months. You can also be more granular if needed, as you can run your schedule every nth month, using a slash. For example, I could use Jan/2, or ½, to schedule my instance to run every second month starting in January. 

You can also specify monthdays, or like normal people would refer to it, days of the month for the schedule to run. Just like months, you can specify a list of days using a comma, a range of days using a hyphen, or select the nth day of the month using a slash. With monthdays, you can also enter L to run an instance on the last day of the month, so you don’t have to programmatically account for which month ends in 30 days and which one ends in 31 days. You can also use W to run on the nearest weekday, for example, if you specify 10W, that means you want it to run on the closest weekday to the 10th of the month. 

Then, there are weekdays.  Unlike the months period that uses an index that starts at 1, weekdays inexplicably starts at 0 instead. So, Monday is 0, Tuesday is 1, Wednesday is 2, and so on. Additionally, you can use a hyphen to specify a range and a comma to specify a list. If you want to schedule an instance to run every nth weekday out of the month, you do this by using the pound key, or a hashtag as the cool people call it. So, you can run an instance the second Tuesday out of the month by specifying Tue#2, or 1#2. And you can use L to run the instance on the last occurring weekday that you specify out of that month. 

In my case, since I want to shut my instance down in the next ten minutes, I’ll say that I want my instance to run every Tuesday since today is currently Tuesday for me and I’ll specify this by using the number 1. Then I’ll click create. 

After I create a period, I can then create a schedule. To create a schedule, I’ll duplicate an existing one. I”ll click on seattle-office-hours, actions, duplicate item. Then I’ll change the name to every-tuesday-ten-minutes. Then I’ll specify the periods I’ll be using, in this case, stop-in-ten-minutes. Keep in mind you can also specify multiple periods if you wanted to. Then, I’ll specify the time zone, and in this case, I’ll just leave it as US/Pacific. From there, I’ll click save. 

Now that I have a schedule created, I can use the name of the schedule to tag my instance. I’ll copy the name of my schedule. Head over to the EC2 dashboard. Click on my instance. Then, I’ll click the tags tab for that instance. Then click manage tags. Select Add a new tag. I’ll use a key name of “Schedule” with a capital S. Remember that you chose this key name when you uploaded your CloudFormation template, and then the value will be the schedule name I just created which is every-tuesday-ten-minutes. From there, I’ll go ahead and click save. 

Then, the Lambda function will stop and start my instances on this schedule. So if I wait just a few more minutes, until 10:55, I’ll see that Lambda automated the stop.  All right, I’ll come back when my instance is stopped

Welcome back, it is officially that time, just a couple minutes after 10:55. I’m currently in my EC2 instance dashboard, and you can see that my instance is currently in the stopped state, so it looks like the instance scheduler did its job. It will remain stopped until the next Tuesday where it will run for 10 minutes and stop again for the week. That’s it for this one - see you soon! 

About the Author
Students
62340
Courses
28
Learning Paths
25

Danny has over 20 years of IT experience as a software developer, cloud engineer, and technical trainer. After attending a conference on cloud computing in 2009, he knew he wanted to build his career around what was still a very new, emerging technology at the time — and share this transformational knowledge with others. He has spoken to IT professional audiences at local, regional, and national user groups and conferences. He has delivered in-person classroom and virtual training, interactive webinars, and authored video training courses covering many different technologies, including Amazon Web Services. He currently has six active AWS certifications, including certifications at the Professional and Specialty level.