File tree Expand file tree Collapse file tree 9 files changed +141
-0
lines changed
harness_central_notification_channel
harness_central_notification_rule
harness_default_notification_template_set
harness_central_notification_channel
harness_central_notification_rule
harness_default_notification_template_set Expand file tree Collapse file tree 9 files changed +141
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Example of fetching a notification channel by identifier
2
+ data "harness_central_notification_channel" "example" {
3
+ identifier = " email_channel"
4
+ org_id = " my_org"
5
+ project_id = " my_project"
6
+ }
Original file line number Diff line number Diff line change
1
+ # Example of fetching a notification rule by identifier
2
+ data "harness_central_notification_rule" "example" {
3
+ identifier = " high_severity_rule"
4
+ org_id = " my_org"
5
+ project_id = " my_project"
6
+ }
Original file line number Diff line number Diff line change
1
+ # Example of fetching the default notification template set
2
+ data "harness_default_notification_template_set" "example" {
3
+ identifier = " default"
4
+ org_id = " my_org"
5
+ project_id = " my_project"
6
+ }
Original file line number Diff line number Diff line change
1
+ # Import account level Central Notification Channel
2
+ terraform import harness_central_notification_channel.example < central_notification_channel_id>
3
+
4
+ # Import org level Central Notification Channel
5
+ terraform import harness_central_notification_channel.example < ord_id> /< central_notification_channel_id>
6
+
7
+ # Import project level Central Notification Channel
8
+ terraform import harness_central_notification_channel.example < org_id> /< project_id> /< central_notification_channel_id>
Original file line number Diff line number Diff line change
1
+ resource "harness_central_notification_channel" "email_channel" {
2
+ name = " Email Notification Channel"
3
+ identifier = " email_notification_channel"
4
+ description = " Email channel for critical alerts"
5
+ org_id = " my_org"
6
+ project_id = " my_project"
7
+
8
+ # Email channel configuration
9
+ email_config {
10
+
11
+ subject = " [ALERT] Harness Notification"
12
+ send_to_all_admins = false
13
+ }
14
+
15
+ # Notification preferences
16
+ notification_method = " EMAIL"
17
+ enabled = true
18
+
19
+ tags = {
20
+ environment = " production"
21
+ team = " devops"
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ # Import account level Central Notification Rule
2
+ terraform import harness_central_notification_rule.example < harness_central_notification_rule_id>
3
+
4
+ # Import org level Central Notification Rule
5
+ terraform import harness_central_notification_rule.example < ord_id> /< harness_central_notification_rule_id>
6
+
7
+ # Import project level Central Notification Rule
8
+ terraform import harness_central_notification_rule.example < org_id> /< project_id> /< harness_central_notification_rule_id>
Original file line number Diff line number Diff line change
1
+ resource "harness_central_notification_rule" "high_severity_rule" {
2
+ name = " High Severity Alerts Rule"
3
+ identifier = " high_severity_alerts_rule"
4
+ description = " Rule for high severity alerts notification"
5
+ org_id = " my_org"
6
+ project_id = " my_project"
7
+
8
+ # Rule conditions
9
+ conditions {
10
+ type = " PIPELINE"
11
+ event = " PIPELINE_START"
12
+
13
+ # Filter for high severity events
14
+ filter {
15
+ type = " severity"
16
+ value = " HIGH"
17
+ }
18
+ }
19
+
20
+ # Notification channels to notify
21
+ notification_channels = [
22
+ " email_notification_channel"
23
+ ]
24
+
25
+ # Execution settings
26
+ enabled = true
27
+
28
+ tags = {
29
+ environment = " production"
30
+ team = " devops"
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ # Import account level Default Notification Template Set
2
+ terraform import harness_default_notification_template_set.example < harness_default_notification_template_set>
3
+
4
+ # Import org level Default Notification Template Set
5
+ terraform import harness_default_notification_template_set.example < ord_id> /< harness_default_notification_template_set>
6
+
7
+ # Import project level Default Notification Template Set
8
+ terraform import harness_default_notification_template_set.example < org_id> /< project_id> /< harness_default_notification_template_set>
Original file line number Diff line number Diff line change
1
+ resource "harness_default_notification_template_set" "default_set" {
2
+ name = " Default Template Set"
3
+ identifier = " default_template_set"
4
+ description = " Default notification templates for all events"
5
+ org_id = " my_org"
6
+ project_id = " my_project"
7
+
8
+ # Email template configuration
9
+ email_templates {
10
+ type = " PIPELINE_START"
11
+ subject = " [${ var . env } ] Pipeline Started: ${ pipeline . name } "
12
+ body = <<- EOT
13
+ <!DOCTYPE html>
14
+ <html>
15
+ <body>
16
+ <h2>Pipeline Started</h2>
17
+ <p><strong>Pipeline:</strong> ${ pipeline . name } </p>
18
+ <p><strong>Triggered by:</strong> ${ pipeline . triggered_by } </p>
19
+ <p><strong>Start Time:</strong> ${ pipeline . start_time } </p>
20
+ <p>View details: <a href="${ pipeline . execution_url } ">${ pipeline . execution_url } </a></p>
21
+ </body>
22
+ </html>
23
+ EOT
24
+ }
25
+
26
+ # Slack template configuration
27
+ slack_templates {
28
+ type = " PIPELINE_SUCCESS"
29
+ message = " ✅ *${ pipeline . name } * succeeded!\n *Environment*: ${ env . name } \n *Duration*: ${ pipeline . duration } \n <${ pipeline . execution_url } |View Details>"
30
+ }
31
+
32
+ # Default settings
33
+ is_default = true
34
+
35
+ tags = {
36
+ environment = " production"
37
+ team = " devops"
38
+ }
39
+ }
40
+
41
+ # Output the created template set details
42
+ output "created_template_set" {
43
+ value = harness_default_notification_template_set. default_set
44
+ }
You can’t perform that action at this time.
0 commit comments