SEAGIT DOCS
Action Rules

Action Rules - Complete Guide

Master automated resource lifecycle management with SeaGit Action Rules. Schedule start/stop operations, automate cleanup, and reduce cloud costs by up to 75% with intelligent automation.

What You'll Learn

📋 Fundamentals

  • • What Action Rules are and how they work
  • • Resource types and action types
  • • Scheduling with cron expressions
  • • Resource filtering with regex patterns

💰 Real-World Use Cases

  • • Cost optimization strategies
  • • Development environment automation
  • • Production safeguards
  • • Resource cleanup workflows

Understanding Action Rules

What Are Action Rules?

Action Rules are cron-based automation policies that execute scheduled actions on your infrastructure resources. Think of them as "if-this-then-that" rules that run on a time-based schedule:

Rule: "Every weekday at 6 PM, stop all clusters matching 'dev-*'"

WHEN: Mon-Fri 6PMFILTER: dev-*ACTION: Stop Cluster

Core Components

Every Action Rule consists of four essential components:

1. Schedule (When)

Cron expression defining when the rule executes

0 18 * * 1-5

(6 PM Monday-Friday EST)

2. Resource Filter (What)

Regex pattern to match resource names

^dev-.*

(All resources starting with "dev-")

3. Resource Type (Scope)

Type of resources to target

clusters | app_instances

(What kind of resource)

4. Actions (Do)

Operations to perform on matched resources

start | stop | terminate

(What to do with them)

Scheduling: Cron Expressions

Action Rules use cron syntax to define when they execute. All times are in EST/EDT timezone.

Predefined Schedules

SeaGit provides common schedules ready to use - perfect for typical work hours automation:

ScheduleCron ExpressionUse Case
Mon-Fri 8:00 AM0 12 * * 1-5Start dev clusters before work
Mon-Fri 6:00 PM0 22 * * 1-5Stop dev clusters after hours (💰 saves money)
Sun-Thu 8:00 AM0 12 * * 2-6Middle East work week
Every day 8:00 AM0 12 * * *Daily startup routine
Every day 6:00 PM0 22 * * *Daily shutdown (maximum savings)

⏰ Important: EST/EDT Timezone

All schedules use Eastern Standard Time. The cron expressions shown are in UTC (EST = UTC-5, EDT = UTC-4), but SeaGit automatically handles daylight saving time conversions.

Custom Cron Expressions

For advanced scheduling needs, use custom cron syntax:

Format: minute hour day month day-of-week

0 18 * * 1-56 PM, Monday through Friday
0 0 * * 0Midnight every Sunday
*/30 * * * *Every 30 minutes
0 9,17 * * 1-59 AM and 5 PM, weekdays only
0 2 1 * *2 AM on 1st of every month

Tip: Use crontab.guru to build and test cron expressions before using them in Action Rules.

Resource Filtering

Resource filters use regex patterns to match resource names. Filters are case-insensitive and powerful enough to handle complex matching scenarios.

Common Filter Patterns

^dev-.*

Matches: All resources starting with "dev-"

✓ dev-cluster-1✓ dev-api-service✗ prod-cluster

.*-test$

Matches: All resources ending with "-test"

✓ api-test✓ cluster-test✗ test-cluster

^(dev|test|staging)-.*

Matches: Resources starting with dev, test, OR staging

✓ dev-api✓ test-cluster✓ staging-web✗ prod-api

^(?!prod).*

Matches: Everything EXCEPT resources starting with "prod"

✓ dev-cluster✓ staging-api✗ prod-cluster

.*feature.*

Matches: Resources containing "feature" anywhere

✓ app-feature-123✓ feature-branch✗ main-branch

💡 Pro Tip: Test Your Filters First

Always test filters in a development environment before applying to production. Use the "Preview Matched Resources" feature in SeaGit to see what will be affected before enabling a rule.

Resource Types & Actions

Action Rules can target different resource types, each supporting specific actions:

Application Instances (appins)

Individual deployments of your applications.

Supported Actions:

STARTScale deployment back to configured replica count
STOPScale deployment to zero (preserves configuration)
TERMINATEPermanently delete deployment and all resources

Clusters (cls)

Kubernetes clusters including all running workloads.

Supported Actions:

STARTPower on cluster nodes and restore all workloads
STOPScale all node groups to zero (💰 huge cost savings)

⚠️ Production Safety Warning

Never create stop/terminate rules that could affect production resources. Always use filters that explicitly exclude production (e.g., ^(?!prod).*).

Real-World Examples

Example 1: Development Environment Cost Optimization

Goal: Save 70% on dev cluster costs

Rule 1: Stop Dev Clusters After Hours

Name:Stop Dev Clusters 6 PM
Filter:^dev-.*
Type:Clusters
Schedule:Mon-Fri 6:00 PM EST
Action:STOP

Rule 2: Start Dev Clusters Before Work

Name:Start Dev Clusters 8 AM
Filter:^dev-.*
Type:Clusters
Schedule:Mon-Fri 8:00 AM EST
Action:START

💰 Cost Savings Calculation:

Before: 168 hours/week × 3 nodes × $0.10/hr = $50.40/week

After: 50 hours/week × 3 nodes × $0.10/hr = $15/week

Annual Savings: $1,840 per dev cluster (70% reduction!)

Example 2: Feature Branch Cleanup

Goal: Auto-cleanup old feature deployments

Rule: Weekly Feature Branch Cleanup

Name:Cleanup Old Feature Branches
Filter:.*-feature-.*|.*-fb-.*
Type:Application Instances
Schedule:Every Sunday at 2:00 AM EST
Condition:Older than 7 days
Action:TERMINATE

✨ Benefits:

  • • Prevents cluster congestion
  • • Reduces costs from forgotten deployments
  • • Keeps environments clean and organized
  • • Eliminates manual cleanup tasks

Example 3: Weekend Shutdown

Goal: Zero non-production costs on weekends

Rule 1: Friday Evening Shutdown

Filter:^(dev|test|staging)-.*
Schedule:Friday 6:00 PM EST
Action:STOP

Rule 2: Monday Morning Startup

Filter:^(dev|test|staging)-.*
Schedule:Monday 7:00 AM EST
Action:START

💰 Weekend Savings:

48 hours × 6 nodes × $0.10/hr = $28.80 per weekend
Annual savings: $1,497 per cluster

Best Practices

Testing & Validation

Always test in development first

Create and validate rules on dev resources before applying to staging or production.

Use the preview feature

Before enabling a rule, preview which resources it will affect to avoid surprises.

Start conservative

Begin with narrow filters that match fewer resources, then expand as you gain confidence.

Naming Conventions

Use descriptive rule names

Good: "Stop Dev Clusters After Hours" | Bad: "Rule 1"

Add descriptions

Document the purpose, expected resources affected, and cost savings for future reference.

Safety Guidelines

Never target production implicitly

Use negative lookahead patterns to explicitly exclude production: ^(?!prod).*

Don't use terminate without stop first

Always stop resources first for 24-48 hours before creating terminate rules. This provides a safety buffer.

Avoid overlapping schedules

Don't create conflicting rules (e.g., start and stop at the same time) for the same resources.

Monitoring & Troubleshooting

Execution History

SeaGit maintains a complete audit trail of all Action Rule executions:

  • Timestamp of execution
  • Resources affected (with names and IDs)
  • Success/failure status
  • Error messages if applicable
  • Duration of execution

Common Issues

Rule not matching expected resources

Solution: Use the preview feature to test your regex filter. Check for case sensitivity issues or incorrect regex syntax.

Rule execution failed

Common causes: Resource already in target state, insufficient permissions, resource locked by another operation.

Solution: Check execution logs for specific error messages. Verify IAM permissions and resource status.

Rule didn't run at scheduled time

Checks: Verify rule is enabled, cron syntax is correct, and timezone is EST (not your local timezone).

Advanced Topics

Multi-Action Rules

You can chain multiple actions together in a single rule for complex workflows:

Example: Graceful Shutdown with Notification

  1. Order 1: Send Slack notification "Dev cluster stopping in 5 minutes"
  2. Order 2: Wait 5 minutes (delay action)
  3. Order 3: Stop cluster
  4. Order 4: Send confirmation "Dev cluster stopped"

Conditional Execution

Some actions support additional conditions beyond the basic filter:

  • Age-based: Only affect resources older than X days
  • Status-based: Only affect running/stopped resources
  • Tag-based: Filter by custom tags or labels

API Reference

Manage Action Rules programmatically using the SeaGit API:

List Action Rules

GET /api/accounts/{accountId}/arules

Response:
{
  "data": [
    {
      "id": "rule123",
      "rule_name": "Stop Dev Clusters After Hours",
      "resource_filter": "^dev-.*",
      "cron": "0 22 * * 1-5",
      "actions": { ... }
    }
  ]
}

Create Action Rule

POST /api/accounts/{accountId}/arules

{
  "rule_name": "Stop Dev Clusters 6 PM",
  "resource_filter": "^dev-.*",
  "cron": "0 22 * * 1-5",
  "resource_type": "cls",
  "actions": {
    "action1": {
      "order": 1,
      "resource_type": "cls",
      "action": "stop"
    }
  }
}

Preview Matches

POST /api/accounts/{accountId}/arules/preview

{
  "resource_filter": "^dev-.*",
  "resource_type": "cls"
}

Response:
{
  "matched": [
    { "id": "cls-123", "name": "dev-cluster-1" },
    { "id": "cls-456", "name": "dev-cluster-2" }
  ],
  "count": 2
}

Frequently Asked Questions

What happens if a cluster is already stopped when a stop rule runs?

The rule executes successfully but performs no action. SeaGit is idempotent - running the same action multiple times produces the same result.

Can I temporarily disable a rule without deleting it?

Yes! Edit the rule and uncheck the "Enabled" checkbox. The rule configuration is preserved but won't execute on schedule.

How accurate are the cost savings estimates?

Estimates are based on actual compute hours saved. Actual savings depend on instance types, data transfer, and other AWS charges. Most customers see 60-75% reduction in non-production costs.

What if I need to work outside normal hours?

You can manually start any stopped cluster at any time through the SeaGit UI or API. Action Rules won't prevent manual operations.

Can Action Rules work across multiple organizations?

Rules are scoped to a single organization. To apply similar automation across organizations, create identical rules in each organization.

Ready to Start Saving?

Action Rules are one of the most impactful features in SeaGit. Customers typically see ROI within the first month through reduced cloud costs and eliminated manual operations.