AutoStopping Rules for AWS RDS
Prerequisites
-
Read the following topics in Set up Cloud Cost Management for AWS:
- Access to CUR. See Cost and Usage Reports (CUR) and CCM Requirements.
- Permissions to create a cross-account role. See AWS Access Permissions.
- Permissions for AWS Resource Optimization Using AutoStopping Rules. See AWS resource optimization using AutoStopping rules.
-
The database that will be onboarded must be able to start and stop. Harness AutoStopping cannot manage certain DB instances, such as serverless ones, because they cannot be started or stopped.
Creating an AutoStopping Rule for RDS
- In Harness, navigate to Cloud Costs module -> AutoStopping Rules
- Click New AutoStopping Rule
- Select AWS as your cloud provider. Choose an existing AWS connector or click New Connector to create one.
After this, there are 3 simple steps to set up your AutoStopping rule:
- Step 1: Configuration
- Step 2: Setup Access
- Step 3: Review
- Enter a Name for your rule
- Set the Idle Time - how long an instance should be inactive before stopping
- In the Resources to be managed by the AutoStopping rules section, select "RDS".
- Click on Add RDS Instance.
- Set up Advanced Configuration:
- Hide Progress Page: This is especially useful when the service is invoked by an automation system, as it prevents misinterpretation of the progress page as the intended response from a service that is onboarded to AutoStopping.
- Dry-Run: Toggle the button if you wish to evaluate this feature without terminating your cloud resources. For more information, go to Evaluate AutoStopping rules in dry-run mode.
- Dependencies: Link your rule to other AutoStopping rules when resources depend on each other.
- Fixed Schedules: Create fixed schedules to automatically start or stop your instances at specific times.
Click to expand advanced configuration details
(Optional) Set up advanced configuration
In this step, you can configure the following settings:
Hide progress page
Toggle the button to disable the display of progress page during instances' warming up process. This option is especially useful when the service is invoked by an automation system, as it prevents misinterpretation of the progress page as the intended response from a service that is onboarded to AutoStopping. By hiding the progress page, the first response of warming up a rule after a downtime will be delayed until the intended service is up and running.
Dry Run
Toggle the button if you wish to evaluate this feature without terminating your cloud resources.
Add Dependency
Set dependencies between two or more AutoStopping Rules when you want one Rule to make one or more Rules to be active based on the traffic that it receives. For example for an application server dependent on a database server, create two AutoStopping Rules managing both the servers. Add a dependency on the Rule managing the application server to be dependent on the Rule managing the database server.
- Click add dependency to add a dependency on any existing rule.
- Select the rule from the RULES drop-down list.
- In DELAY IN SECS, enter the number of seconds that rule should wait after warming up the dependent rule. For example, you have Rule 1 dependent on Rule 2 and you have set 5 seconds delay. In that case, when the request is received to warm up Rule 1, then first Rule 2 (dependent rule) is warmed up, and then there is a delay of 5 seconds before warming up Rule 1.
- Once you're done with all the configurations, click Next.
Fixed Schedule
Create fixed uptime or downtime schedules for the resources managed by this AutoStopping Rule. When a resource is configured to go up or down on a fixed schedule, it is unaffected by activity or idleness during that time period.
In certain scenarios, you would not want your resources to go down or up. For example, every Friday at 5 p.m. you want your ABC
resource to go down. You can schedule downtime for your ABC
resource. During this window, the resource is forced to go down regardless of the defined rule. You can choose to specify uptime for your resources in the same way.
The fixed schedule takes precedence over the defined AutoStopping Rule.
Harness executes scheduled rules using Dkron, an open-source workload automation service.
To create a fixed schedule for your rule, do the following:
- In Fixed Schedules, click Add Fixed Schedule.
- In New Fixed Schedule, enter a Name for your schedule.
- In Type, select the type for your schedule. You can schedule an Uptime or Downtime for your rule. As per your schedule, the resources go up or down.
- Select the Time Zone from the drop-down list.
- In Set schedule period, use the date picker to set the start and end time for your schedule.
- In Begins on, select the start date and time for your schedule. You can select a date and specify the time.
- In Ends on, select the end date and time for your schedule. You can select a date and specify the time. Ensure that Never ends checkbox is unselected to set the end time.
- Select the checbox Never ends if you do not want to set end time for your schedule.
- You can also set a recurring schedule for the rule. If you want to set a recurring schedule, in Uptime/Downtime in the selected period, in Repeats, select the repeat frequency.
- Select which days of the week you'd like your schedule to repeat. You can choose any day between Sunday and Saturday.
- Select Everyday, to set the schedule for all seven days of the week.
- Set your repeat schedule's beginning and ending time. In the Time field, specify the start and end time for the fixed schedule.
- Select All Day, if you wish to set your schedule for the entire day. If you choose All Day for your schedule, you won't be able to choose a start and end time.
- In Setup Access, select Proxy from drop-down list or create a new one.
- Select Source Port and Target Port.
- Click on Next.
In Review, verify all the configuration details and click Save Rule. To edit any of the configuration settings, click EDIT and modify the settings.
Your AutoStopping rule is listed under the AutoStopping Rules dashboard.
Use Harness AutoStopping CLI to Keep the RDS Instance(s) Running
You can also use Harness AutoStopping CLI to query the archived database using your own database client. Basically you're leveraging Harness CLI to keep the RDS instance(s) running.
-
From the AutoStopping dashboard, click on the RDS rule.
-
In Download CLI, select your operating system to download the Harness CLI for your system.
-
Click Download CLI.
-
Run the following command to connect to an RDS database.
harness connect --host hostname --port 5432
The above command will start the RDS database if it is not running and set up a secure tunnel to it. This command will output the connection details to which you can connect your database client. 5. As an example, in the case of Postgres, the following command can be used to connect to the database.
psql -h localhost -p port-received-from-above -u postgres
As soon as your database client is disconnected, AutoStopping will consider it as idleness and shut down the database after the configured idle time.