Set Up Firehose
The Guardrails Firehose generates an event stream of notifications sent to an AWS SNS topic. It's designed for streaming change events to downstream systems: data lakes, ticketing systems, and custom notification pipelines.
The Firehose answers the question "Can I get a stream of change events flowing through Guardrails?" It can't answer "How many controls are in ok?" or "How many storage buckets are in the environment?" For snapshots of environment state or bulk data extracts, use GraphQL or Steampipe.
[!NOTE] Only notifications created after Firehose configuration will be processed. There is no way to replay or resend historical notifications.
How It Works
Notification generated → Watch filter selects → Render template → Publish to AWS SNS → Downstream integrations
- As resources, controls, and policy settings change inside Guardrails, entries are added to the Notifications table.
- Watch filters select a subset of those notifications to send to the Firehose.
- Notifications pass through a Notification Template to prepare them for delivery.
- A background process publishes rendered notifications to the Firehose SNS topic.
Prerequisites
- Access to the Guardrails console with
Turbot/AdminorTurbot/Ownerpermissions. - An AWS account with permissions to create SNS topics and IAM users.
Step 1: Install the Firehose Mod
Install the firehose-aws-sns mod into your workspace if not already installed. See Install a Mod for instructions.
Step 2: Create AWS Resources
Create the following AWS resources. If you prefer Terraform, use the Firehose Terraform bootstrap.
- AWS SNS topic, in any account and region. All notifications will be forwarded to this topic.
- AWS IAM user, with publish-only access to the SNS topic. Use a dedicated user for Firehose (not shared with other services). The IAM policy should only grant
sns:Publishto the Firehose topic ARN. - Access key pair, for the IAM user.
Step 3: Configure Firehose Policies
Navigate to Policies and create policy settings for the following. These can ONLY be set at the Turbot (workspace root) level:
| Policy | Value |
|---|---|
Turbot > Firehose > AWS SNS > Notification Topic | The SNS topic ARN from Step 2. |
Turbot > Firehose > AWS SNS > Notification Access Key | The IAM user access key ID. |
Turbot > Firehose > AWS SNS > Notification Secret Key | The IAM user secret access key. |
Step 4: Create Watches
Watches control which notifications flow through the Firehose. Without watches, no notifications are sent.
A watch specifies:
| Parameter | Description | Common Value |
|---|---|---|
| action | The action the watch takes on match (required). | tmod:@turbot/firehose-aws-sns#/action/types/router |
| resource | The resource scope for the watch (required). | tmod:@turbot/turbot#/ (workspace root), a folder ID, or a cloud account ID. |
| filter | A notification filter string (required). | Varies by use case (see below). |
| favorite | A favorite to associate with the watch (optional). | Varies. |
Watch Filters
Watch filters determine which notifications match. See Notification Filters for the full filter syntax.
Supported Filter Pivots
| Keyword | Value | Example |
|---|---|---|
controlCategoryId | Control Category ID or AKA | controlCategoryId:'tmod:@turbot/turbot#/control/categories/cmdbDiscovery' |
controlCategoryLevel | self and/or descendant | controlCategoryLevel:self,descendant |
controlTypeId | Control Type ID or AKA | controlTypeId:'tmod:@turbot/aws-s3#/control/types/bucketVersioning' |
controlTypeLevel | self and/or descendant | controlTypeLevel:self,descendant |
level | self and/or descendant | level:self |
policyTypeId | Policy Type ID or AKA | policyTypeId:'tmod:@turbot/aws-s3#/policy/types/bucketVersioning' |
policyTypeLevel | self and/or descendant | policyTypeLevel:self,descendant |
resourceCategoryId | Resource Category ID or AKA | resourceCategoryId:'tmod:@turbot/turbot#/resource/categories/storage' |
resourceCategoryLevel | self and/or descendant | resourceCategoryLevel:self,descendant |
resourceTypeId | Resource Type ID or AKA | resourceTypeId:'tmod:@turbot/aws-s3#/resource/types/bucket' |
resourceTypeLevel | self and/or descendant | resourceTypeLevel:self |
notificationType | See Supported Notification Types | notificationType:active_grants_deleted |
Supported Notification Types
| Item | Action | Notification Type | Description |
|---|---|---|---|
| Action | Notify | action_notify | A Guardrails action invokes a notify command during a run. |
| Control | Change | control | Aggregates both control_updated and control_notify. |
| Control | Notify | control_notify | A Guardrails control invokes a notify command during a run. |
| Control | Updated | control_updated | A control state change (e.g., ok → alarm). |
| Favorite | Created | favorite_created | A favorite is created for a resource. |
| Favorite | Deleted | favorite_deleted | A favorite is deleted. |
| Grant Activation | Created | active_grants_created | A grant is activated. |
| Grant Activation | Deleted | active_grants_deleted | A grant activation is deleted. |
| Grant | Created | grant_created | A grant is created. |
| Grant | Deleted | grant_deleted | A grant is deleted. |
| Policy Setting | Created | policy_setting_created | A policy setting is created. |
| Policy Setting | Deleted | policy_setting_deleted | A policy setting is deleted. |
| Policy Setting | Updated | policy_setting_updated | A policy setting is updated. |
| Policy Value | Updated | policy_value_updated | A policy value is updated. |
| Resource | Change | resource | Aggregates all resource_* notifications. |
| Resource | Created | resource_created | A resource is created in Guardrails. |
| Resource | Deleted | resource_deleted | A resource is deleted. |
| Resource | Updated | resource_updated | A resource is updated. |
[!WARNING] Creating watches for notification types not listed above may cause system instability.
[!NOTE]
- Watches do not support
resourceIdin the filter. To monitor a specific resource, create the watch on that resource instead.- Filtering
control_updatedby control state is not supported. All control state notifications are delivered whennotificationType:'control_updated'is specified.- There is an important difference between
control_notify(a control took an action) andcontrol_updated(a control changed state). Most customers are interested incontrol_updated.
Common Filter Examples
Controls:
- All AWS control updates:
notificationType:control_updated controlTypeId:'tmod:@turbot/aws#/resource/types/aws' - All Azure control updates:
notificationType:control_updated controlTypeId:'tmod:@turbot/azure#/resource/types/azure' - All GCP control updates:
notificationType:control_updated controlTypeId:'tmod:@turbot/gcp#/resource/types/gcp' - All cloud platforms:
notificationType:control_updated controlTypeId:'tmod:@turbot/aws#/resource/types/aws','tmod:@turbot/azure#/resource/types/azure','tmod:@turbot/gcp#/resource/types/gcp' - All AWS S3 Bucket controls:
notificationType:control_updated controlTypeId:'tmod:@turbot/aws-s3#/resource/types/bucket' - Encryption at Rest controls across all providers:
notificationType:control_updated controlCategoryId:'tmod:@turbot/turbot#/control/categories/resourceEncryptionAtRest'
Resources:
- Resource created:
notificationType:resource_created - Resource updated:
notificationType:resource_updated - Resource deleted:
notificationType:resource_deleted - All resource changes:
notificationType:resource
Creating Filters Interactively
Manually constructing watch filter strings can be tedious. Instead, prototype your filters using the Activity report in the Guardrails console:
- Navigate to the Reports page and find the Activity Ledger report. The Firehose and Activity Ledger both examine the
notificationstable, so whatever rows show up in the report will match in the Firehose too. - Customize the report filters to show exactly the notifications you want.
- Open the Developers tab on the report page and click one of the GraphQL queries.
- In the Query Variables section, find the
filtervalue. This is the machine-generated filter string that matches your report. - Copy the filter string into your watch configuration.
Step 5: Create Watches via Terraform or GraphQL
Terraform
resource "turbot_watch" "control_updates" {
resource = "tmod:@turbot/turbot#/"
action = "tmod:@turbot/firehose-aws-sns#/action/types/router"
filters = [
"level:self,descendant notificationType:control_updated"
]
}
GraphQL
Create a watch:
mutation CreateWatch($input: CreateWatchInput!) {
createWatch(input: $input) {
filters
handler
turbot {
id
resourceId
}
}
}
{
"input": {
"resource": "tmod:@turbot/turbot#/",
"action": "tmod:@turbot/firehose-aws-sns#/action/types/router",
"filters": ["level:self,descendant notificationType:control_updated"]
}
}
List watches:
query MyWatches {
watches(filter: "") {
items {
handler
filters
watchRules {
metadata {
filters
}
}
}
}
}
Delete a watch:
mutation DeleteMyWatch {
deleteWatch(input: { id: "215276026059506" }) {
handler
filters
}
}
Sample Notification
Below is a sample notification of type active_grants_deleted as it appears on the Firehose SNS topic:
{
"notificationType": "active_grants_deleted",
"actor": {
"identity": {
"picture": "https://www.gravatar.com/avatar/cb9ff8606c24daf9cda1d82615bd7a8e",
"turbot": {
"title": "Gary Anderson",
"id": "186957187212252"
},
"title": "Gary Anderson"
}
},
"turbot": {
"id": "202473982728085",
"createTimestamp": "2020-09-10T17:34:58.063Z"
},
"oldActiveGrant": {
"grant": {
"type": {
"trunk": {
"title": "Turbot"
}
},
"level": {
"trunk": {
"title": "User > Metadata > ReadOnly"
}
},
"resource": {
"trunk": {
"title": "Turbot"
}
},
"identity": {
"trunk": {
"title": "Turbot > Goliath Federal Bank > Oscar Reyes"
}
}
},
"resource": {
"trunk": {
"title": "Turbot"
}
}
}
}
Notification Templates
The Firehose uses Notification Templates to format events before publishing to SNS. Override the default templates via policies under Turbot > Firehose > AWS SNS > Notification Template > *. Each notification type has its own template.
The output is JSON by default but can be any format. Test template queries in the Developers > GraphQL Explorer before deploying.
[!NOTE] Notification templates cannot be made into calculated policies.
Troubleshooting
For reference, the data path:
Notification generated → Watch → Render template → Publish to SNS → Downstream integrations
Firehose Mod and Policies
| Issue | Solution |
|---|---|
| No notifications flowing | Is the firehose-aws-sns mod installed without errors? Are the topic ARN, access key, and secret key policies set to correct values? |
| Mod installed but not working | Compare your setup against the Firehose Terraform bootstrap. |
Watches
| Issue | Solution |
|---|---|
| No notifications matching | Set the watch to the broadest possible filter (e.g., all control_updated for all resources). This validates the data path. Refine later. |
| Filter not matching expected events | Prototype the filter using the Activity Ledger report to eliminate typos. |
| Wrong scope | Ensure the watch is attached to the Turbot resource (tmod:@turbot/turbot#/), a folder, or a cloud account, not a control type or policy setting. |
| Easy test | Toggle a policy exception on a single resource from Check: Enabled to Check: Disabled and back to generate control_updated traffic. |
SNS Topic and IAM User
| Issue | Solution |
|---|---|
| Messages not arriving on topic | Test publishing to the topic using the AWS CLI with the Firehose IAM user credentials. |
| Subscription issues | Enable success/failure delivery logging on the SNS topic (disable after debugging in high-volume environments). |
| Topic permissions | Verify the IAM user has sns:Publish permission on the Firehose topic. No other permissions are needed. |
| Access key rotation | Plan for regular access key rotation for the Firehose IAM user. |
Downstream Integrations
| Issue | Solution |
|---|---|
| Lag between event and delivery | 30–60 seconds is typical. Up to 5 minutes under heavy load. |
| Events arriving but downstream not processing | Test by manually publishing a message to the SNS topic and verifying the subscriber processes it. |
Enterprise Customers
Check CloudWatch Logs at /aws/lambda/{turbot_prefix}_turbotfirehoseawssnssender-{hash} for publishing errors. SaaS customers should contact Guardrails Customer Success.
Next Steps
- Build Notification Pipelines: Design downstream processing pipelines for Firehose events.
- Configure Notifications: Set up direct human notifications via email, Slack, and Teams.