Skip to content

Commit 854d1cb

Browse files
authored
Add notification resources
Add notification resources
2 parents b8037ba + bd0344b commit 854d1cb

23 files changed

+2864
-1
lines changed

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,33 @@
33
FEATURES:
44

55
* **New Resource:** `dependencytrack_project_policy` - Manage the assignment of policies to projects in Dependency-Track
6+
* **New Resource:** `dependencytrack_notification_publisher` - Manage notification publishers in Dependency-Track
7+
* **New Resource:** `dependencytrack_notification_rule` - Manage notification rules in Dependency-Track
8+
* **New Resource:** `dependencytrack_notification_rule_project` - Associate projects with notification rules
9+
* **New Resource:** `dependencytrack_notification_rule_team` - Associate teams with notification rules
610

711
ENHANCEMENTS:
812

13+
* docs: Added documentation with examples for the `dependencytrack_notification_publisher` resource
14+
* docs: Added documentation with examples for the `dependencytrack_notification_rule_project` resource
15+
* docs: Added documentation with examples for the `dependencytrack_notification_rule_team` resource
16+
* docs: Added documentation with examples for the `dependencytrack_notification_rule` resource
17+
* docs: Added documentation with examples for the `dependencytrack_project_policy` resource
18+
* resource/notification_publisher: Supports all notification publisher types (Webhook, Email, Console, etc.)
19+
* resource/notification_publisher: Supports full CRUD operations for notification publishers
20+
* resource/notification_publisher: Supports import using UUID
21+
* resource/notification_rule: Supports all notification scopes (PORTFOLIO, SYSTEM) and levels (INFORMATIONAL, WARNING, ERROR)
22+
* resource/notification_rule: Supports full CRUD operations for notification rules
23+
* resource/notification_rule: Supports import using UUID
24+
* resource/notification_rule_project: Supports associating projects with PORTFOLIO-scoped notification rules
25+
* resource/notification_rule_project: Supports import using the format `rule_uuid/project_uuid`
26+
* resource/notification_rule_team: Supports associating teams with EMAIL-publisher notification rules
27+
* resource/notification_rule_team: Supports import using the format `rule_uuid/team_uuid`
928
* resource/project_policy: Supports full CRUD operations for project policy assignments
1029
* resource/project_policy: Supports import using the format `policy_uuid/project_uuid`
30+
* tests: Added acceptance tests for `dependencytrack_notification_publisher` resource using API key authentication
31+
* tests: Added acceptance tests for `dependencytrack_notification_rule` resource using API key authentication
1132
* tests: Added acceptance tests for `dependencytrack_project_policy` resource using API key authentication
12-
* docs: Added documentation with examples for the `dependencytrack_project_policy` resource
1333

1434
## v0.2.2
1535

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_publisher Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Manages a notification publisher in Dependency-Track. Notification publishers are used to send notifications to external systems.
7+
---
8+
9+
# dependencytrack_notification_publisher (Resource)
10+
11+
Manages a notification publisher in Dependency-Track. Notification publishers are used to send notifications to external systems.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Webhook notification publisher
17+
resource "dependencytrack_notification_publisher" "webhook" {
18+
name = "Slack Webhook"
19+
description = "Sends notifications to Slack"
20+
publisher_class = "org.dependencytrack.notification.publisher.WebhookPublisher"
21+
template_mime_type = "application/json"
22+
template = jsonencode({
23+
text = "New vulnerability detected in {{project.name}}"
24+
})
25+
}
26+
27+
# Console notification publisher (minimal example)
28+
resource "dependencytrack_notification_publisher" "console" {
29+
name = "Console Logger"
30+
publisher_class = "org.dependencytrack.notification.publisher.ConsolePublisher"
31+
template_mime_type = "text/plain"
32+
}
33+
34+
# Email notification publisher
35+
resource "dependencytrack_notification_publisher" "email" {
36+
name = "Email Notifications"
37+
description = "Sends email notifications for critical vulnerabilities"
38+
publisher_class = "org.dependencytrack.notification.publisher.SendMailPublisher"
39+
template_mime_type = "text/plain"
40+
template = "Project: {{project.name}}\nVulnerability: {{vulnerability.vulnId}}"
41+
}
42+
```
43+
44+
<!-- schema generated by tfplugindocs -->
45+
## Schema
46+
47+
### Required
48+
49+
- `name` (String) The name of the notification publisher
50+
- `publisher_class` (String) The fully qualified class name of the publisher implementation (e.g., org.dependencytrack.notification.publisher.WebhookPublisher)
51+
- `template_mime_type` (String) The MIME type of the template (e.g., application/json, text/plain)
52+
53+
### Optional
54+
55+
- `description` (String) The description of the notification publisher
56+
- `template` (String) The template content for the notification
57+
58+
### Read-Only
59+
60+
- `default_publisher` (Boolean) Whether this is a default publisher (read-only, cannot be modified or deleted)
61+
- `id` (String) The ID of the notification publisher (same as UUID)
62+
- `uuid` (String) The UUID of the notification publisher
63+
64+
## Import
65+
66+
Import is supported using the following syntax:
67+
68+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
69+
70+
```shell
71+
# Notification publishers can be imported using their UUID
72+
terraform import dependencytrack_notification_publisher.example 00000000-0000-0000-0000-000000000001
73+
```
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_rule_project Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Associates a project with a notification rule. This is only valid for notification rules with PORTFOLIO scope.
7+
---
8+
9+
# dependencytrack_notification_rule_project (Resource)
10+
11+
Associates a project with a notification rule. This is only valid for notification rules with PORTFOLIO scope.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "dependencytrack_notification_rule" "example" {
17+
name = "Example Rule"
18+
scope = "PORTFOLIO"
19+
notify_on = ["NEW_VULNERABILITY"]
20+
publisher = dependencytrack_notification_publisher.slack.uuid
21+
}
22+
23+
resource "dependencytrack_project" "example" {
24+
name = "Example Project"
25+
}
26+
27+
resource "dependencytrack_notification_rule_project" "example" {
28+
rule_uuid = dependencytrack_notification_rule.example.uuid
29+
project_uuid = dependencytrack_project.example.uuid
30+
}
31+
```
32+
33+
<!-- schema generated by tfplugindocs -->
34+
## Schema
35+
36+
### Required
37+
38+
- `project` (String) The UUID of the project to associate with the rule
39+
- `rule` (String) The UUID of the notification rule
40+
41+
### Read-Only
42+
43+
- `id` (String) The ID of the association (format: rule/project)
44+
45+
## Import
46+
47+
Import is supported using the following syntax:
48+
49+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
50+
51+
```shell
52+
terraform import dependencytrack_notification_rule_project.example "rule_uuid/project_uuid"
53+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "dependencytrack_notification_rule_team Resource - dependencytrack"
4+
subcategory: ""
5+
description: |-
6+
Associates a team with a notification rule. IMPORTANT: This only works with notification rules using the EMAIL publisher (SendMailPublisher). Teams receive email notifications when the rule is triggered.
7+
---
8+
9+
# dependencytrack_notification_rule_team (Resource)
10+
11+
Associates a team with a notification rule. **IMPORTANT**: This only works with notification rules using the EMAIL publisher (SendMailPublisher). Teams receive email notifications when the rule is triggered.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "dependencytrack_notification_rule" "example" {
17+
name = "Example Rule"
18+
scope = "PORTFOLIO"
19+
notify_on = ["NEW_VULNERABILITY"]
20+
publisher = dependencytrack_notification_publisher.email.uuid
21+
}
22+
23+
resource "dependencytrack_team" "example" {
24+
name = "Example Team"
25+
}
26+
27+
resource "dependencytrack_notification_rule_team" "example" {
28+
rule_uuid = dependencytrack_notification_rule.example.uuid
29+
team_uuid = dependencytrack_team.example.uuid
30+
}
31+
```
32+
33+
<!-- schema generated by tfplugindocs -->
34+
## Schema
35+
36+
### Required
37+
38+
- `rule` (String) The UUID of the notification rule
39+
- `team` (String) The UUID of the team to associate with the rule
40+
41+
### Read-Only
42+
43+
- `id` (String) The ID of the association (format: rule/team)
44+
45+
## Import
46+
47+
Import is supported using the following syntax:
48+
49+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
50+
51+
```shell
52+
terraform import dependencytrack_notification_rule_team.example "rule_uuid/team_uuid"
53+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Notification publishers can be imported using their UUID
2+
terraform import dependencytrack_notification_publisher.example 00000000-0000-0000-0000-000000000001
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Webhook notification publisher
2+
resource "dependencytrack_notification_publisher" "webhook" {
3+
name = "Slack Webhook"
4+
description = "Sends notifications to Slack"
5+
publisher_class = "org.dependencytrack.notification.publisher.WebhookPublisher"
6+
template_mime_type = "application/json"
7+
template = jsonencode({
8+
text = "New vulnerability detected in {{project.name}}"
9+
})
10+
}
11+
12+
# Console notification publisher (minimal example)
13+
resource "dependencytrack_notification_publisher" "console" {
14+
name = "Console Logger"
15+
publisher_class = "org.dependencytrack.notification.publisher.ConsolePublisher"
16+
template_mime_type = "text/plain"
17+
}
18+
19+
# Email notification publisher
20+
resource "dependencytrack_notification_publisher" "email" {
21+
name = "Email Notifications"
22+
description = "Sends email notifications for critical vulnerabilities"
23+
publisher_class = "org.dependencytrack.notification.publisher.SendMailPublisher"
24+
template_mime_type = "text/plain"
25+
template = "Project: {{project.name}}\nVulnerability: {{vulnerability.vulnId}}"
26+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Notification rules can be imported using their UUID
2+
terraform import dependencytrack_notification_rule.example 00000000-0000-0000-0000-000000000001

0 commit comments

Comments
 (0)