Create a Rule from scratch

In this section, we are going to go create a rule from scratch. In the process, you will learn about the three components of a rule.

This rule will help us periodically delete all but the last 30 snapshots matching a Tag Group. Additionally, we will set up a notification to be delivered 30 minutes before the action is scheduled to take place, which will deliver:

  1. A list of targeted resources
  2. A snooze option (defer this execution until later)
  3. A cancel option (ignore this instance of a recurring schedule)

Rule Overview

Anatomy of a Rule

There are three components in a rule:

  1. Context (Definition)
  2. Trigger (Definition)
  3. Action (Definition)

Set Context

From our glossary:

The Context is the scope of a Rule. A completed Context will specify:

  • The target Platform (AWS/Azure)
  • The appropriate scope for the selected cloud Platform, either:
  • One, many or all AWS Accounts and AWS Regions
  • One, many or all Azure Subscriptions

Setting the Context

For this Rule, we'll target all AWS Accounts and all AWS Regions.

Set Context When Creating a Rule

Set Trigger

From our glossary:

The Trigger is the observed event that will cause the Rule to run once.

Setting the Trigger

For our snapshot deletion Rule we wish to delete snapshots daily and receive notifications 30 minutes prior to each execution.

List of Available Triggers

Using the Schedule trigger is a great choice for when you you wish to perform work periodically.

Schedule Trigger Page 1

Next, we need to select the days of the week, the time at which we want to trigger this rule's execution, and the timezone within which we should interpret the schedule's definition. You can use the searchable list to find your desired timezone (no need to convert to UTC!). Use the weekly time picker to select Every Day.

Next, click on the Offsets link in the side nav.

Schedule Trigger Offsets

This is where we can configure the timing of a notification prior to the scheduled execution time. By default notifications are sent to all selected notification destinations 10 minutes before the scheduled time.

Next, click on the Notifications link in the side nav.

Schedule Trigger Page 2

In this view you can select destinations for upcoming Schedule notifications. These notifications contain a list of targeted resources and provide a timely opportunity to snooze or cancel the upcoming instance of the recurring schedule.

Set Actions

From our glossary:

An Action is an automation capability specifying how GorillaStack is to interact with targeted cloud resources in response to the observed Trigger. A Rule can support one or many Actions.

Add Action

As the Rule we are trying to create is intended to clean up old snapshots, we select the Delete Snapshots action.

List of Actions

Now, we need to determine which snapshots we want to delete. In this example, we will target all snapshots for simplicity. However, we can filter snapshots based on their existing tags. This is achieved by using a GorillaStack configuration called a Tag Group. For a user guide on creating your first Tag Group, read a guide on creating a Tag Group.

Action Snapshot Targeting

Next, click on the Snapshot Settings link in the side nav. Here, we specify the snapshot retention policy we wish to apply.

Next, let's have a look at how to target resources with Tag Groups