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-*'"
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:
| Schedule | Cron Expression | Use Case |
|---|---|---|
| Mon-Fri 8:00 AM | 0 12 * * 1-5 | Start dev clusters before work |
| Mon-Fri 6:00 PM | 0 22 * * 1-5 | Stop dev clusters after hours (💰 saves money) |
| Sun-Thu 8:00 AM | 0 12 * * 2-6 | Middle East work week |
| Every day 8:00 AM | 0 12 * * * | Daily startup routine |
| Every day 6:00 PM | 0 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 Friday0 0 * * 0Midnight every Sunday*/30 * * * *Every 30 minutes0 9,17 * * 1-59 AM and 5 PM, weekdays only0 2 1 * *2 AM on 1st of every monthTip: 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-"
.*-test$
Matches: All resources ending with "-test"
^(dev|test|staging)-.*
Matches: Resources starting with dev, test, OR staging
^(?!prod).*
Matches: Everything EXCEPT resources starting with "prod"
.*feature.*
Matches: Resources containing "feature" anywhere
💡 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:
Clusters (cls)
Kubernetes clusters including all running workloads.
Supported Actions:
⚠️ 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
^dev-.*Rule 2: Start Dev Clusters Before Work
^dev-.*💰 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
.*-feature-.*|.*-fb-.*✨ 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
^(dev|test|staging)-.*Rule 2: Monday Morning Startup
^(dev|test|staging)-.*💰 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
- Order 1: Send Slack notification "Dev cluster stopping in 5 minutes"
- Order 2: Wait 5 minutes (delay action)
- Order 3: Stop cluster
- 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.