DEV Community

Faris Durrani
Faris Durrani

Posted on

Save money for OCI Instances by auto-shutting down outside of business hours

Using Oracle Cloud's Resource Scheduler to auto-shut down compute instances outside of business hours

The Oracle Cloud Infrastructure Resource Scheduler is a fairly new resource available on Oracle Cloud to schedule start/stop of compute instances, autonomous databases, and now serverless Functions. In this tutorial, we will learn how to use the Resource Scheduler to schedule instances to stop at the end of business day every day to save on compute costs.

Policies needed

Add these policies to allow the Resource Scheduler to start or shut down instances in the tenancy (or compartment)

allow any-user to use instances in tenancy where request.principal.type='resourceschedule'
Enter fullscreen mode Exit fullscreen mode

To make the policy more restrictive, you can use dynamic groups containing a Resource Scheduler of a certain OCID and use specific policy permissions instead of the broad "use".

Optionally, add this policy to allow the Scheduler to start or shut down autonomous databases as well.

allow any-user to use autonomous-databases in tenancy where request.principal.type='resourceschedule'
Enter fullscreen mode Exit fullscreen mode

Create Resource Scheduler schedule

1. Go to Resource Scheduler

Go to ☰ Main Menu > Governance & Administration > Resource Scheduler. Or simply search for scheduler

2. Click Create a schedule

Click Create a schedule screenshot

3. Add a name and set Action to Stop

Schedule basic information

4. Select instances to auto-stop

You can also dynamically apply the schedule to instances based on resource types, compartment, tags, and status.

Selecting instances

5. Set the schedule

Using the simpler Form interface, you can set the schedule to run Daily at 22:00 UTC (5:00 pm Eastern Standard Time).

Form interface option to run Daily at 22:00 UTC

Alternatively, use the more standardized Cron expression to run at the same schedule using the expression 0 22 * * *. See https://crontab.guru to learn Cron expressions.

Cron expression option to run Daily at 22:00 UTC

6. Review and Create Schedule

See built schedule

Now, the instances you chose will shut down every day at 5:00 pm EST, saving you money by cutting down compute time. You can also make another schedule to start the instances during business hours opening.

References

  1. Getting Started with Resource Scheduler

Safe harbor statement

The information provided on this channel/article/story is solely intended for informational purposes and cannot be used as a part of any contractual agreement. The content does not guarantee the delivery of any material, code, or functionality, and should not be the sole basis for making purchasing decisions. The postings on this site are my own and do not necessarily reflect the views or work of Oracle or Mythics, LLC.

Top comments (0)