Add Time based Auto Scaling and Power On/Off operations to OCI in under 5 minutes!

By | August 23, 2020

Would you like the schedule (based on time) Power On/Off and/or Scaling operations for your OCI resources? Well that is very easily possible with my Auto Scaling Script!

The Script supports:

  • Compute VMs: On/Off
  • Instance Pools: On/Off and Scaling (# of instances)
  • Database VMs: On/Off
  • Database Baremetal Servers: Scaling (# of CPUs)
  • Autonomous Databases: On/Off and Scaling (# of CPUs)
  • Oracle Digital Assistant: On/Off
  • Oracle Analytics Cloud: On/Off and Scaling (between 2-8 oCPU and 10-12 oCPU)
  • Oracle Integration Service: On/Off

If you want to implement this in your OCI environment, I have made a very simple instruction video:

You can also find full instructions on the github repository:

16 thoughts on “Add Time based Auto Scaling and Power On/Off operations to OCI in under 5 minutes!

  1. Tushar

    Have created dynamic group and policy as per the video but still I am facing issue while creating name space:-
    [opc@tushar-autostart OCI-AutoScale]$ python3
    Logged in as: Instance Principle/comvivamfs3 @ ap-mumbai-1
    Creating Namespace Schedule
    Traceback (most recent call last):
    File “”, line 58, in
    response = identity.create_tag_namespace(create_tag_namespace_details=details).data
    File “/usr/local/lib/python3.6/site-packages/oci/identity/”, line 2388, in create_tag_namespace
    File “/usr/local/lib/python3.6/site-packages/oci/”, line 256, in call_api
    return self.request(request)
    File “/usr/local/lib/python3.6/site-packages/oci/”, line 377, in request
    self.raise_service_error(request, response)
    File “/usr/local/lib/python3.6/site-packages/oci/”, line 547, in raise_service_error
    oci.exceptions.ServiceError: {‘opc-request-id’: ‘8EA34C5766EF405A9E260C392069C631/B08B839C3B22E31CDAA023F3533C81C0/42F259C26D6D9C93E51A5D4F31E8F967’, ‘code’: ‘NotAllowed’, ‘message’: ‘Please go to your home region fra to execute CREATE, UPDATE and DELETE operations.’, ‘status’: 403}

    1. richard Post author

      Hi, is ap-mumbai your home region? The CreateNameSpaces calls can only be made to the home region. I will try to fix this week to automatically select the home region, no matter where you run the script from, but for now, run the script in an instance in your home region, or manually create the tag namespace and keys.

      1. Tushar

        Hi Sir,

        No, Frankfurt is the home region. I have configured on Frankfurt. Its configured on Home region successfully. Thanks.
        But the thing is, scale up/down is not working other than the home region.
        How I can manage the scale up/down other than the home region?

        1. richard Post author

          The script should find all resources across all enabled regions. Just keep in mind from a hour-of-the-day perspective, it is looking at the time of day of where the script is running, not where the resource is located.

          If you have created a resource in an other region with the schedule tag, do you see it in the output of the script come by?

          1. Tushar

            Yes, I have configured the python script in Frankfurt and Tag the resource of Mumbai & Frankfurt both region. But Its working for Frankfurt only.
            Even when I am running it manually using “paython3”. Its not considering the Mumbai related resources in the output of script and resource are not scaling down.

  2. Paul

    Hello Richard,

    [opc@compins01 OCI-AutoScale]$ python3
    Traceback (most recent call last):
    File “”, line 11, in
    import oci
    ModuleNotFoundError: No module named ‘oci’

    Did I forget a step? Do I need to make a copy of config_example with my own OCIDs?

    1. richard Post author

      did you run the “pip3 install oci” command?
      You are missing the OCI library

      1. Paul

        Got it working on a fresh new Compute Instance. I re-used an old one – my mistake.

  3. Pete

    Richard, thank you for this great gift to the community; I plan to make very good use of it and save lots of $$$.
    I’ve been using it successfully for “AnyDay/Weekday” tags, but I’m having trouble getting the specific day of the week tag (i.e. Monday, Tuesday, etc.) to work. Is it a known issue, or am I mis-configured somehow ?

    When used alone, I get “not correct amount of hours”
    When used with more general WeekDay/AnyDay tags, it seems to not be overruling as expected.



    Checking: ccca – Instance
    Error with schedule of ccca – , not correct amount of hours


    Checking: ccca – Instance (on a Tuesday)
    – Active schedule for ccca : 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,[0],0,0,1,0,0

    “A specific day of the week tag (ie. Monday) overrules all other tags.”

    1. richard Post author

      Hi, if I look at both WeekDay and Tuesday schedule, they have the same number for the current hour. The last 6th number are both a 0.

      Maybe you clock is running in a different timezone then you expect it to be?

      You can see, based on the [ ] which element is being used.

      1. Pete

        ok, I will double check on the timezone for the double schedule, but why do I get
        “not correct amount of hours” with any of the named weekdays when used by themselves ?
        I’m pretty sure I have 24 numbers (have recounted, and have cut/paste from a working AnyDay string.

        1. Pete

          This is the schedule I’m trying now to shutdown at 5pm Friday and startup first thing on Monday
          (does it look reasonable?)

          Schedule.WeekDay: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
          Schedule.Friday: 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0
          Schedule.Weekend: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

          1. richard Post author

            I think the problem has been fixed, the specific day check was one tab to much indented. Please refresh the code and all should be good. If not, let me know 🙂

        2. richard Post author

          I count 24 as well 🙂 I will check. I am working on the script any way this weekend, as I am also adding support for load balancer scaling and exadata. Finally convinced oracle to provide me with exadata 🙂


Leave a Reply to richard Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.