Automation
Maintaining a sound cloud infrastructure includes tasks that need to be performed regularly. Fix Inventory can help you automate many of these tasks by defining jobs.
Examples of these tasks include:
- enforcing company policies (e.g., tagging),
- sending notifications about critical infrastructure changes (e.g., to Slack, Discord, or PagerDuty), and
- cleaning up unused resources in your development accounts.
Jobs
A job is a sequence of commands executed by Fix Inventory at a specific time interval or when a specific event is emitted.
Jobs in Fix Inventory are similar to Unix cron jobs. However, while cron jobs run only on a specific schedule, Fix Inventory jobs can also be triggered based by events.
The typical structure of a job has three parts: a trigger, an optional filter, and an action.
Job Trigger
The job trigger defines when a job is executed.
There are three types of job triggers: schedule triggers, event triggers, and combined triggers.
Schedule Trigger
A schedule trigger executes a job at a specific time interval described by a cron expression.
Examples
See How to Create a Scheduled Job for step-by-step instructions describing how to create a job with a schedule trigger.
Event Trigger
An event trigger executes a job when a specific event is emitted by Fix Inventory.
Fix Inventory updates the state of resources in the four steps of the collect_and_cleanup
workflow: collect
, cleanup_plan
, cleanup
, and generate_metrics
.
Each of these steps emits events that can be used to trigger jobs.
Examples
See Events for a list of events emitted by Fix Inventory.
See How to Create an Event-Based Job for step-by-step instructions describing how to create a job with an event trigger.
Combined Trigger
A combined trigger combines a schedule trigger with an event trigger, and executes a job when a specific event is emitted after a schedule trigger is fired.
Combined triggers are useful if you want to perform an action on a specific schedule, but only after a specific event is fired.
Example
See How to Create a Scheduled Event-Based Job for step-by-step instructions describing how to create a job with a combined trigger.
Job Filters & Actions
The scope and functionality of a job is defined by filters and actions, respectively.
To perform more complex automations, it is possible to define multiple sets of filters and actions delimited by a semicolon. Each set of filters and actions is executed sequentially when the job is triggered.
Job Filters
A job filter is an optional search that returns the resources of interest. Only resources matching the filter will be processed by the job.
Example
The result of a job filter is a list of resources that is piped as input to job actions.
Job Actions
A job action is an action command performed on resources matching the optional filter.
Examples
Job Management
Jobs are persisted in the Fix Inventory database. The job
command allows you to add, update, delete, and list jobs.
See Related How-To Guides below for step-by-step instructions to create jobs.
Examples
Related How-To Guides
- How to Create a Scheduled Event-Based Job
- How to Create a Scheduled Job
- How to Create an Event-Based Job