Create AutoStopping Rules for AWS

Updated 1 week ago by Archana Singh

AutoStopping Rules make sure that your non-production resources run only when used, and never when idle. It also allows you to run your workloads on fully orchestrated spot instances without any worry of spot interruptions.

In this topic:

Before You Begin

Prerequisites

Visual Summary

This section provides an overview of AutoStopping Rules.

AutoStopping Architecture

Here is an AutoStopping architecture for EC2 VMs and ASGs:

Step 1: Add a Cloud Provider

Perform the following steps to link your AWS cloud account to Harness.

  1. In Cloud Costs, click New AutoStopping Rule.
  2. In AutoStopping Rules, select AWS. It is the cloud account in which your workloads are running that you want to manage using AutoStopping rules.
  3. If you have already linked your AWS account and want to use that account, then select the AWS account from the Connect to your AWS account drop-down list.
  4. If you have not added your cloud account, click Connect to your AWS account drop-down list and then click New Connector. For the detailed steps, see Connect to an AWS Connector.

Step 2: Add a New AutoStopping Rule

Perform the following steps to add a new AWS AutoStopping rule:

Step 1: Define an AutoStopping Rule

Perform the following steps to get started with AutoStopping Rule.

  1. In Cloud Costs, in AutoStopping Rules, click New AutoStopping Rule.
  2. In the cloud account type, select AWS. It is the cloud account in which your workloads are running that you want to manage using AutoStopping rules.
  3. Select your AWS account from the Connect to your AWS account drop-down list and click Next. If you have not added an AWS cloud account, see Connect to an AWS Connector.
  4. In Define your AutoStopping rule, in Name your Rule, enter a name for your rule. This is the name of your AutoStopping rule.
  5. In Idle time, enter the idle time in minutes. This is the time that the AutoStopping rule will wait before stopping the idle instances.

    Once the idle time has elapsed:

    - For Spot Instances, a snapshot is taken and then the instances are terminated.

    - On-Demand Instances are shut down without a snapshot.

Step 2: Select the Resources to be Managed by the AutoStopping Rule

Select the cloud resources that you want to manage using this rule. AutoStopping Rule will monitor the selected resources and stop them when they are idle beyond the configured idle time. You can select Instances, Auto Scaling Groups, or Kubernetes Cluster.

Option 1: Select Instances

Add instance/s to be managed by your AutoStopping rule.

You can add multiple instances to a single Rule. However, all the VMs should be part of the same region.
  1. Select Instances and click Add an Instance.
  2. Select the instances that you want to manage using the AutoStopping rules. You can use the search option to search the instances.
  3. Once you have finished selecting the instances, click Add selected.
Option 2: Select Auto Scaling Groups

Add an Auto Scaling Group to be managed by the AutoStopping rule.

You can add only one Auto Scaling Group to a rule.
  1. Select Auto scaling groups and click Add a auto-scaling group.
  2. Select the Auto Scaling Group that you want to manage using the AutoStopping rule. You can also use the search option to find the Auto Scaling Group.
  3. Once you have finished selecting the Auto Scaling Group, click Add selected.
Option 3: Select Kubernetes Clusters

Add a cluster to be managed by the AutoStopping Rule.

  1. Select Kubernetes Cluster and then click Add a cluster.
  2. Select the Kubernetes cluster that you want to manage using the AutoStopping rules. If you wish to create a new connector for the Kubernetes cluster, see Create a Kubernetes Connector for AutoStopping Rules.
  3. Once you have finished selecting the Kubernetes cluster, click Add selected.
    If you select a Kubernetes cluster, follow the steps in Create AutoStopping Rules for Kubernetes Cluster.

Step 3: Select the Instance Fulfillment Type

This step allows you to convert or distribute the fulfillment type for your instances.

  • Instances: Select Spot or On-Demand. You can convert the fulfillment type of your selected instances.

    For example, you have selected On-Demand instances in step 2. If you select Spot in this step, all your instances will get converted to Spot from On-Demand.
  • Auto Scaling Groups: Enter the number of instances for Spot and On-Demand. Depending on the size of your Auto Scaling group, you can specify the values for each fulfillment type. The total number of Spot and On-Demand instances should always be equal to or less than the maximum capacity of the group.

    If the maximum capacity of your group is 3, then you can enter the ratio of your instances like the following:

    On-Demand

    Spot

    1

    2

    2

    1

    0

    3

    3

    0


    In this example, all the instances are of On-Demand type.

(Optional) Step 4: Set Up Advanced Configuration

In this step, you can configure the following settings:

Hide Progress Page

Toggle the button to enable or disable the instances warming up progress status. If you turn this ON, the progress status will not be displayed.

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 dependant on a database server, create two AutoStopping Rules managing both the servers. Add a dependency on the Rule managing the application server to be dependant on the Rule managing the database server.

  1. Click add dependency to add a dependency on any existing rule.
  2. Select the rule from the RULES drop-down list.
  3. 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 will be a delay of 5 seconds before warming up Rule 1.
  4. Once you're done with all the configurations, click Next.

Now that you have the AutoStopping rule configured, define how you would want to access the underlying application running on the resources managed by this Rule. You can use any of the following methods:

  • DNS Link: If the underlying applications running on the resources managed by the AutoStopping Rule are accessed by an HTTP or HTTPS URL.
  • SSH/RDP: If the underlying applications running on the resources managed by AutoStopping Rule are accessed via SSH or RDP.

A DNS link allows you to access the resources managed by the AutoStopping rule using an HTTP or HTTPS URL.

  1. In Setup Access, select DNS Link.
  2. Select a Load Balancer from the drop-down list. If your Load Balancer is not added, click +New Load Balancer. For detailed steps, see Create an Application Load Balancer for AWS.
    Multiple instances and rules can use a single Load balancer. It identifies instances based on hostnames and directs the HTTP traffic appropriately.
  3. Verify listeners information under the Routing tab. If the security groups are configured for the selected instances, then the routing information is auto-populated for those instances.

    You can edit or delete the routing information. However, it is mandatory to have at least one port listed. For more information, see Listeners.
    1. Click add port if you wish to add more ports.
  4. Toggle the Health check button to configure the health check. Health check makes sure that the specified parameters are met before stopping the instances. Health check status should be successful for the AutoStopping rules to come into effect.
    1. In PROTOCOL, select http or https.
    2. Enter Path, port, and timeout details. For example, you have configured port 80 and the timeout as 30 seconds for your instance, then the AutoStopping rule will check these specified parameters before stopping the instance.
  5. (Optional) Specify the URL used to access the resources. You can select either of the following options:
    1. Select the auto-generated URL to access the resources managed by this AutoStopping Rule.
    2. Enter the URL currently used to access the instances
      The domain name should be entered without prefixing the scheme. A rule can have multiple URLs. You can enter comma-separated values into the Custom URL to support multiple URLs.
    3. Select the checkbox This url is publicly accessible, if the URL is publicly accessible.
  6. Once you're done, click Next.

Setup Access Using SSH/RDP

SSH/RDP allows you to access the resources managed by the AutoStopping rule via SSH or RDP HTTPS URL. Select this option if the underlying applications running on the resources managed by AutoStopping Rule are accessed via SSH or RDP.

  1. In Setup Access, select SSH/RDP.
  2. Select your operating system to download the Harness CLI for your system.
  3. Click Download CLI.
  4. You can connect using SSH or RDP.
SSH Commands

Run the following commands for SSH:

harness ssh --host default-test-ssh-1.abc1000test.lightwingtest.com --user ubuntu --config lwc.toml -- -i ~/.ssh/ry-jupyter.pem

Run the connect command to open a proxy connection in your machine which can be used from other applications.

harness connect --host default-test-ssh-1.abc1000test.lightwingtest.com --port 22 -- -i ~/.ssh/ry-jupyter.pem

Here is the output:

Proxy listening details:
Rule name: Test SSH 1
Listen address: 127.0.0.1
Port forwarding: 14527 => 22
Protocol: tcp
Started at: 2021-05-19 21:53:38.320943 +0530 IST m=+48.950643931

RDP Commands

For RDP run the following command:

harness rdp --host default-test-rdp-1.abc1000test.lightwingtest.com

Run the following command to connect via private IP:

harness rdp --host default-test-rdp-1.abc1000test.lightwingtest.com --internal-ip

  1. Click Next.

Review

  1. 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.

Next Step


Please Provide Feedback