|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "dependencytrack_notification_rule Resource - dependencytrack" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + Manages a notification rule in Dependency-Track. Notification rules define when and how notifications are sent. |
| 7 | +--- |
| 8 | + |
| 9 | +# dependencytrack_notification_rule (Resource) |
| 10 | + |
| 11 | +Manages a notification rule in Dependency-Track. Notification rules define when and how notifications are sent. |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```terraform |
| 16 | +# Basic notification rule for vulnerabilities |
| 17 | +resource "dependencytrack_notification_publisher" "slack" { |
| 18 | + name = "Slack Webhook" |
| 19 | + publisher_class = "org.dependencytrack.notification.publisher.WebhookPublisher" |
| 20 | + template_mime_type = "application/json" |
| 21 | +} |
| 22 | +
|
| 23 | +resource "dependencytrack_notification_rule" "vulnerability_alerts" { |
| 24 | + name = "Critical Vulnerability Alerts" |
| 25 | + scope = "PORTFOLIO" |
| 26 | + notification_level = "ERROR" |
| 27 | + publisher = dependencytrack_notification_publisher.slack.id |
| 28 | +
|
| 29 | + notify_on = [ |
| 30 | + "NEW_VULNERABILITY", |
| 31 | + "NEW_VULNERABLE_DEPENDENCY" |
| 32 | + ] |
| 33 | +
|
| 34 | + enabled = true |
| 35 | + notify_children = true |
| 36 | + log_successful_publish = false |
| 37 | +} |
| 38 | +
|
| 39 | +# Notification rule for specific projects |
| 40 | +resource "dependencytrack_project" "web_app" { |
| 41 | + name = "Web Application" |
| 42 | + version = "1.0.0" |
| 43 | +} |
| 44 | +
|
| 45 | +resource "dependencytrack_notification_rule" "project_specific" { |
| 46 | + name = "Web App Notifications" |
| 47 | + scope = "PORTFOLIO" |
| 48 | + publisher = dependencytrack_notification_publisher.slack.id |
| 49 | +
|
| 50 | + notify_on = [ |
| 51 | + "NEW_VULNERABILITY", |
| 52 | + "POLICY_VIOLATION" |
| 53 | + ] |
| 54 | +
|
| 55 | + projects = [ |
| 56 | + dependencytrack_project.web_app.id |
| 57 | + ] |
| 58 | +
|
| 59 | + message = "Alert for project: {{project.name}}" |
| 60 | +} |
| 61 | +
|
| 62 | +# Notification rule for specific teams |
| 63 | +resource "dependencytrack_team" "security_team" { |
| 64 | + name = "Security Team" |
| 65 | +} |
| 66 | +
|
| 67 | +resource "dependencytrack_notification_rule" "team_notifications" { |
| 68 | + name = "Security Team Alerts" |
| 69 | + scope = "SYSTEM" |
| 70 | + publisher = dependencytrack_notification_publisher.slack.id |
| 71 | +
|
| 72 | + notify_on = [ |
| 73 | + "NEW_VULNERABILITY" |
| 74 | + ] |
| 75 | +
|
| 76 | + teams = [ |
| 77 | + dependencytrack_team.security_team.id |
| 78 | + ] |
| 79 | +} |
| 80 | +
|
| 81 | +# System-level notification rule |
| 82 | +resource "dependencytrack_notification_rule" "system_alerts" { |
| 83 | + name = "System Configuration Alerts" |
| 84 | + scope = "SYSTEM" |
| 85 | + notification_level = "WARNING" |
| 86 | + publisher = dependencytrack_notification_publisher.slack.id |
| 87 | +
|
| 88 | + notify_on = [ |
| 89 | + "CONFIGURATION", |
| 90 | + "DATASOURCE_MIRRORING" |
| 91 | + ] |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +<!-- schema generated by tfplugindocs --> |
| 96 | +## Schema |
| 97 | + |
| 98 | +### Required |
| 99 | + |
| 100 | +- `name` (String) The name of the notification rule |
| 101 | +- `notify_on` (Set of String) Set of notification groups to trigger on (e.g., NEW_VULNERABILITY, POLICY_VIOLATION, etc.) |
| 102 | +- `publisher` (String) The UUID of the notification publisher to use |
| 103 | +- `scope` (String) The scope of the notification rule (PORTFOLIO or SYSTEM) |
| 104 | + |
| 105 | +### Optional |
| 106 | + |
| 107 | +- `enabled` (Boolean) Whether the notification rule is enabled (defaults to true if not specified) |
| 108 | +- `log_successful_publish` (Boolean) Whether to log successful notification publishing (defaults to false if not specified) |
| 109 | +- `notification_level` (String) The notification level (INFORMATIONAL, WARNING, or ERROR) |
| 110 | +- `notify_children` (Boolean) Whether to notify on child projects (defaults to true if not specified) |
| 111 | +- `publisher_config` (String) Publisher-specific configuration (JSON string) |
| 112 | + |
| 113 | +### Read-Only |
| 114 | + |
| 115 | +- `id` (String) The ID of the notification rule (same as UUID) |
| 116 | +- `projects` (Set of String) Set of project UUIDs associated with this rule (read-only, use dependencytrack_notification_rule_project to manage) |
| 117 | +- `teams` (Set of String) Set of team UUIDs associated with this rule (read-only, use dependencytrack_notification_rule_team to manage) |
| 118 | +- `uuid` (String) The UUID of the notification rule |
| 119 | + |
| 120 | +## Import |
| 121 | + |
| 122 | +Import is supported using the following syntax: |
| 123 | + |
| 124 | +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: |
| 125 | + |
| 126 | +```shell |
| 127 | +# Notification rules can be imported using their UUID |
| 128 | +terraform import dependencytrack_notification_rule.example 00000000-0000-0000-0000-000000000001 |
| 129 | +``` |
0 commit comments