diff --git a/sysdig/internal/client/v2/model.go b/sysdig/internal/client/v2/model.go index e7f5db0d..ec8c53ef 100644 --- a/sysdig/internal/client/v2/model.go +++ b/sysdig/internal/client/v2/model.go @@ -116,13 +116,13 @@ type NotificationChannelOptions struct { ServiceName string `json:"serviceName,omitempty"` // Type: PagerDuty AdditionalHeaders map[string]interface{} `json:"additionalHeaders,omitempty"` // Type: Webhook, prometheus alert manager, custom webhook, ibm function Region string `json:"region,omitempty"` // Type: OpsGenie - AllowInsecureConnections *bool `json:"allowInsecureConnections,omitempty"` // Type: prometheus alert manager, custom webhook + AllowInsecureConnections *bool `json:"allowInsecureConnections,omitempty"` // Type: prometheus alert manager, custom webhook, Webhook TeamId int `json:"teamId,omitempty"` // Type: team email HttpMethod string `json:"httpMethod,omitempty"` // Type: custom webhook MonitorTemplate string `json:"monitorTemplate,omitempty"` // Type: custom webhook InstanceId string `json:"instanceId,omitempty"` // Type: ibm event notification IbmFunctionType string `json:"ibmFunctionType,omitempty"` // Type: ibm event function - CustomData map[string]interface{} `json:"customData,omitempty"` // Type: ibm function + CustomData map[string]interface{} `json:"customData,omitempty"` // Type: ibm function, Webhook TemplateConfiguration []NotificationChannelTemplateConfiguration `json:"templateConfiguration,omitempty"` NotifyOnOk bool `json:"notifyOnOk"` diff --git a/sysdig/resource_sysdig_monitor_notification_channel_webhook.go b/sysdig/resource_sysdig_monitor_notification_channel_webhook.go index 2649e2cd..c8b221b6 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_webhook.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_webhook.go @@ -40,6 +40,15 @@ func resourceSysdigMonitorNotificationChannelWebhook() *schema.Resource { Type: schema.TypeMap, Optional: true, }, + "allow_insecure_connections": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "custom_data": { + Type: schema.TypeMap, + Optional: true, + }, }), } } @@ -147,6 +156,9 @@ func monitorNotificationChannelWebhookFromResourceData(d *schema.ResourceData, t nc.Type = NOTIFICATION_CHANNEL_TYPE_WEBHOOK nc.Options.Url = d.Get("url").(string) nc.Options.AdditionalHeaders = d.Get("additional_headers").(map[string]interface{}) + nc.Options.CustomData = d.Get("custom_data").(map[string]interface{}) + allowInsecureConnections := d.Get("allow_insecure_connections").(bool) + nc.Options.AllowInsecureConnections = &allowInsecureConnections return } @@ -158,6 +170,10 @@ func monitorNotificationChannelWebhookToResourceData(nc *v2.NotificationChannel, _ = d.Set("url", nc.Options.Url) _ = d.Set("additional_headers", nc.Options.AdditionalHeaders) + _ = d.Set("custom_data", nc.Options.CustomData) + if nc.Options.AllowInsecureConnections != nil { + _ = d.Set("allow_insecure_connections", *nc.Options.AllowInsecureConnections) + } return } diff --git a/sysdig/resource_sysdig_monitor_notification_channel_webhook_test.go b/sysdig/resource_sysdig_monitor_notification_channel_webhook_test.go index 10a7d71a..10441b1e 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_webhook_test.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_webhook_test.go @@ -48,6 +48,22 @@ func TestAccMonitorNotificationChannelWebhook(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: monitorNotificationChannelWebhookSharedWithAllowInsecureConnections(rText()), + }, + { + ResourceName: "sysdig_monitor_notification_channel_webhook.sample-webhook4", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: monitorNotificationChannelWebhookSharedWithCustomData(rText()), + }, + { + ResourceName: "sysdig_monitor_notification_channel_webhook.sample-webhook5", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -91,3 +107,32 @@ func monitorNotificationChannelWebhookSharedWithCurrentTeam(name string) string send_test_notification = false }`, name) } + +func monitorNotificationChannelWebhookSharedWithAllowInsecureConnections(name string) string { + return fmt.Sprintf(` + resource "sysdig_monitor_notification_channel_webhook" "sample-webhook4" { + name = "Example Channel %s - Webhook With Allow Insecure Connections" + enabled = true + allow_insecure_connections = true + url = "https://example.com/" + notify_when_ok = false + notify_when_resolved = false + send_test_notification = false + }`, name) +} + +func monitorNotificationChannelWebhookSharedWithCustomData(name string) string { + return fmt.Sprintf(` + resource "sysdig_monitor_notification_channel_webhook" "sample-webhook5" { + name = "Example Channel %s - Webhook With Custom Data" + enabled = true + url = "https://example.com/" + notify_when_ok = false + notify_when_resolved = false + send_test_notification = false + custom_data = { + "data1": "value1" + "data2": "value2" + } + }`, name) +} diff --git a/sysdig/resource_sysdig_secure_notification_channel_webhook.go b/sysdig/resource_sysdig_secure_notification_channel_webhook.go index 283caaa6..981e83cd 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_webhook.go +++ b/sysdig/resource_sysdig_secure_notification_channel_webhook.go @@ -40,6 +40,15 @@ func resourceSysdigSecureNotificationChannelWebhook() *schema.Resource { Type: schema.TypeMap, Optional: true, }, + "allow_insecure_connections": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "custom_data": { + Type: schema.TypeMap, + Optional: true, + }, }), } } @@ -146,6 +155,9 @@ func secureNotificationChannelWebhookFromResourceData(d *schema.ResourceData, te nc.Type = NOTIFICATION_CHANNEL_TYPE_WEBHOOK nc.Options.Url = d.Get("url").(string) nc.Options.AdditionalHeaders = d.Get("additional_headers").(map[string]interface{}) + nc.Options.CustomData = d.Get("custom_data").(map[string]interface{}) + allowInsecureConnections := d.Get("allow_insecure_connections").(bool) + nc.Options.AllowInsecureConnections = &allowInsecureConnections return } @@ -157,6 +169,10 @@ func secureNotificationChannelWebhookToResourceData(nc *v2.NotificationChannel, _ = d.Set("url", nc.Options.Url) _ = d.Set("additional_headers", nc.Options.AdditionalHeaders) + _ = d.Set("custom_data", nc.Options.CustomData) + if nc.Options.AllowInsecureConnections != nil { + _ = d.Set("allow_insecure_connections", *nc.Options.AllowInsecureConnections) + } return } diff --git a/sysdig/resource_sysdig_secure_notification_channel_webhook_test.go b/sysdig/resource_sysdig_secure_notification_channel_webhook_test.go index 292ccf29..5d73ff17 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_webhook_test.go +++ b/sysdig/resource_sysdig_secure_notification_channel_webhook_test.go @@ -41,6 +41,22 @@ func TestAccSecureNotificationChannelWebhook(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: secureNotificationChannelWebhookSharedWithAllowInsecureConnections(rText()), + }, + { + ResourceName: "sysdig_secure_notification_channel_webhook.sample-webhook4", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: secureNotificationChannelWebhookSharedWithCustomData(rText()), + }, + { + ResourceName: "sysdig_secure_notification_channel_webhook.sample-webhook5", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -69,3 +85,32 @@ func secureNotificationChannelWebhookSharedWithCurrentTeam(name string) string { send_test_notification = false }`, name) } + +func secureNotificationChannelWebhookSharedWithAllowInsecureConnections(name string) string { + return fmt.Sprintf(` + resource "sysdig_secure_notification_channel_webhook" "sample-webhook4" { + name = "Example Channel %s - Webhook With Allow Insecure Connections" + enabled = true + allow_insecure_connections = true + url = "https://example.com/" + notify_when_ok = false + notify_when_resolved = false + send_test_notification = false + }`, name) +} + +func secureNotificationChannelWebhookSharedWithCustomData(name string) string { + return fmt.Sprintf(` + resource "sysdig_secure_notification_channel_webhook" "sample-webhook5" { + name = "Example Channel %s - Webhook With Custom Data" + enabled = true + url = "https://example.com/" + notify_when_ok = false + notify_when_resolved = false + send_test_notification = false + custom_data = { + "data1": "value1" + "data2": "value2" + } + }`, name) +} diff --git a/website/docs/r/monitor_notification_channel_webhook.md b/website/docs/r/monitor_notification_channel_webhook.md index 7ac96b63..38b8f089 100644 --- a/website/docs/r/monitor_notification_channel_webhook.md +++ b/website/docs/r/monitor_notification_channel_webhook.md @@ -16,12 +16,17 @@ Creates a Sysdig Monitor Notification Channel of type Webhook. ```terraform resource "sysdig_monitor_notification_channel_webhook" "sample-webhook" { - name = "Example Channel - Webhook" - enabled = true - url = "localhost:8080" - notify_when_ok = false - notify_when_resolved = false - send_test_notification = false + name = "Example Channel - Webhook" + enabled = true + url = "localhost:8080" + notify_when_ok = false + notify_when_resolved = false + send_test_notification = false + + custom_data = { + "data1": "value1" + "data2": "value2" + } } ``` @@ -31,6 +36,8 @@ resource "sysdig_monitor_notification_channel_webhook" "sample-webhook" { * `url` - (Required) URL to send the event. +* `custom_data` - (Optional) Key value list of additional data you want to attach to the alert notification. + * `enabled` - (Optional) If false, the channel will not emit notifications. Default is true. * `notify_when_ok` - (Optional) Send a new notification when the alert condition is @@ -44,6 +51,8 @@ resource "sysdig_monitor_notification_channel_webhook" "sample-webhook" { * `additional_headers` - (Optional) Key value list of custom headers. +* `allow_insecure_connections` - (Optional) Whether to skip TLS verification. Default: `false`. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/secure_notification_channel_webhook.md b/website/docs/r/secure_notification_channel_webhook.md index 874a6ca4..0ba8beea 100644 --- a/website/docs/r/secure_notification_channel_webhook.md +++ b/website/docs/r/secure_notification_channel_webhook.md @@ -16,12 +16,17 @@ Creates a Sysdig Secure Notification Channel of type Webhook. ```terraform resource "sysdig_secure_notification_channel_webhook" "sample-webhook" { - name = "Example Channel - Webhook" - enabled = true - url = "localhost:8080" - notify_when_ok = false - notify_when_resolved = false - send_test_notification = false + name = "Example Channel - Webhook" + enabled = true + url = "localhost:8080" + notify_when_ok = false + notify_when_resolved = false + send_test_notification = false + + custom_data = { + "data1": "value1" + "data2": "value2" + } } ``` @@ -31,6 +36,8 @@ resource "sysdig_secure_notification_channel_webhook" "sample-webhook" { * `url` - (Required) URL to send the event. +* `custom_data` - (Optional) Key value list of additional data you want to attach to the alert notification. + * `enabled` - (Optional) If false, the channel will not emit notifications. Default is true. * `notify_when_ok` - (Optional) Send a new notification when the alert condition is @@ -44,6 +51,8 @@ resource "sysdig_secure_notification_channel_webhook" "sample-webhook" { * `additional_headers` - (Optional) Key value list of custom headers. +* `allow_insecure_connections` - (Optional) Whether to skip TLS verification. Default: `false`. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: