diff --git a/sysdig/data_source_sysdig_monitor_notification_channel_ibm_function.go b/sysdig/data_source_sysdig_monitor_notification_channel_ibm_function.go deleted file mode 100644 index 665086b6..00000000 --- a/sysdig/data_source_sysdig_monitor_notification_channel_ibm_function.go +++ /dev/null @@ -1,66 +0,0 @@ -package sysdig - -import ( - "context" - "strconv" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func dataSourceSysdigMonitorNotificationChannelIBMFunction() *schema.Resource { - timeout := 5 * time.Minute - - return &schema.Resource{ - ReadContext: dataSourceSysdigMonitorNotificationChannelIBMFunctionRead, - - Timeouts: &schema.ResourceTimeout{ - Read: schema.DefaultTimeout(timeout), - }, - - Schema: createMonitorNotificationChannelSchema(map[string]*schema.Schema{ - "ibm_function_type": { - Type: schema.TypeString, - Computed: true, - }, - "url": { - Type: schema.TypeString, - Computed: true, - }, - "custom_data": { - Type: schema.TypeMap, - Computed: true, - }, - "iam_api_key": { - Type: schema.TypeString, - Computed: true, - }, - "whisk_auth_token": { - Type: schema.TypeString, - Computed: true, - }, - }), - } -} - -func dataSourceSysdigMonitorNotificationChannelIBMFunctionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client, err := getMonitorNotificationChannelClient(meta.(SysdigClients)) - if err != nil { - return diag.FromErr(err) - } - - nc, err := client.GetNotificationChannelByName(ctx, d.Get("name").(string)) - if err != nil { - return diag.FromErr(err) - } - - err = monitorNotificationChannelIBMFunctionToResourceData(&nc, d) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(strconv.Itoa(nc.ID)) - - return nil -} diff --git a/sysdig/data_source_sysdig_secure_notification_channel.go b/sysdig/data_source_sysdig_secure_notification_channel.go index a041e160..9789ab5e 100644 --- a/sysdig/data_source_sysdig_secure_notification_channel.go +++ b/sysdig/data_source_sysdig_secure_notification_channel.go @@ -25,7 +25,6 @@ const ( NOTIFICATION_CHANNEL_TYPE_TEAM_EMAIL = "TEAM_EMAIL" NOTIFICATION_CHANNEL_TYPE_CUSTOM_WEBHOOK = "POWER_WEBHOOK" NOTIFICATION_CHANNEL_TYPE_IBM_EVENT_NOTIFICATION = "IBM_EVENT_NOTIFICATIONS" - NOTIFICATION_CHANNEL_TYPE_IBM_FUNCTION = "IBM_FUNCTION" NOTIFICATION_CHANNEL_TYPE_SLACK_TEMPLATE_KEY_V1 = "SLACK_SECURE_EVENT_NOTIFICATION_TEMPLATE_METADATA_v1" NOTIFICATION_CHANNEL_TYPE_SLACK_TEMPLATE_KEY_V2 = "SLACK_SECURE_EVENT_NOTIFICATION_TEMPLATE_METADATA_v2" diff --git a/sysdig/provider.go b/sysdig/provider.go index 527bae92..262c9248 100644 --- a/sysdig/provider.go +++ b/sysdig/provider.go @@ -190,7 +190,6 @@ func (p *SysdigProvider) Provider() *schema.Provider { "sysdig_monitor_notification_channel_team_email": resourceSysdigMonitorNotificationChannelTeamEmail(), "sysdig_monitor_notification_channel_custom_webhook": resourceSysdigMonitorNotificationChannelCustomWebhook(), "sysdig_monitor_notification_channel_ibm_event_notification": resourceSysdigMonitorNotificationChannelIBMEventNotification(), - "sysdig_monitor_notification_channel_ibm_function": resourceSysdigMonitorNotificationChannelIBMFunction(), "sysdig_monitor_team": resourceSysdigMonitorTeam(), "sysdig_monitor_cloud_account": resourceSysdigMonitorCloudAccount(), "sysdig_secure_posture_zone": resourceSysdigSecurePostureZone(), @@ -261,7 +260,6 @@ func (p *SysdigProvider) Provider() *schema.Provider { "sysdig_monitor_notification_channel_team_email": dataSourceSysdigMonitorNotificationChannelTeamEmail(), "sysdig_monitor_notification_channel_custom_webhook": dataSourceSysdigMonitorNotificationChannelCustomWebhook(), "sysdig_monitor_notification_channel_ibm_event_notification": dataSourceSysdigMonitorNotificationChannelIBMEventNotification(), - "sysdig_monitor_notification_channel_ibm_function": dataSourceSysdigMonitorNotificationChannelIBMFunction(), "sysdig_monitor_custom_role_permissions": dataSourceSysdigMonitorCustomRolePermissions(), "sysdig_monitor_team": dataSourceSysdigMonitorTeam(), "sysdig_monitor_teams": dataSourceSysdigMonitorTeams(), diff --git a/sysdig/resource_sysdig_monitor_notification_channel_ibm_cloud_function.go b/sysdig/resource_sysdig_monitor_notification_channel_ibm_cloud_function.go deleted file mode 100644 index 2b14b616..00000000 --- a/sysdig/resource_sysdig_monitor_notification_channel_ibm_cloud_function.go +++ /dev/null @@ -1,198 +0,0 @@ -package sysdig - -import ( - "context" - "strconv" - "time" - - v2 "github.com/draios/terraform-provider-sysdig/sysdig/internal/client/v2" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -func resourceSysdigMonitorNotificationChannelIBMFunction() *schema.Resource { - timeout := 5 * time.Minute - - return &schema.Resource{ - CreateContext: resourceSysdigMonitorNotificationChannelIBMFunctionCreate, - UpdateContext: resourceSysdigMonitorNotificationChannelIBMFunctionUpdate, - ReadContext: resourceSysdigMonitorNotificationChannelIBMFunctionRead, - DeleteContext: resourceSysdigMonitorNotificationChannelIBMFunctionDelete, - Importer: &schema.ResourceImporter{ - StateContext: schema.ImportStatePassthroughContext, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(timeout), - Update: schema.DefaultTimeout(timeout), - Read: schema.DefaultTimeout(timeout), - Delete: schema.DefaultTimeout(timeout), - }, - - Schema: createMonitorNotificationChannelSchema(map[string]*schema.Schema{ - "ibm_function_type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"WEB_ACTION", "CLOUD_FUNCTION"}, false), - }, - "url": { - Type: schema.TypeString, - Required: true, - }, - "custom_data": { - Type: schema.TypeMap, - Optional: true, - }, - "iam_api_key": { - Type: schema.TypeString, - Optional: true, - }, - "whisk_auth_token": { - Type: schema.TypeString, - Optional: true, - }, - }), - } -} - -func resourceSysdigMonitorNotificationChannelIBMFunctionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client, err := getMonitorNotificationChannelClient(meta.(SysdigClients)) - if err != nil { - return diag.FromErr(err) - } - - teamID, err := client.CurrentTeamID(ctx) - if err != nil { - return diag.FromErr(err) - } - - notificationChannel, err := monitorNotificationChannelIBMFunctionFromResourceData(d, teamID) - if err != nil { - return diag.FromErr(err) - } - - notificationChannel, err = client.CreateNotificationChannel(ctx, notificationChannel) - if err != nil { - return diag.FromErr(err) - } - - d.SetId(strconv.Itoa(notificationChannel.ID)) - - return resourceSysdigMonitorNotificationChannelIBMFunctionRead(ctx, d, meta) -} - -func resourceSysdigMonitorNotificationChannelIBMFunctionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client, err := getMonitorNotificationChannelClient(meta.(SysdigClients)) - if err != nil { - return diag.FromErr(err) - } - - id, _ := strconv.Atoi(d.Id()) - nc, err := client.GetNotificationChannelById(ctx, id) - if err != nil { - if err == v2.NotificationChannelNotFound { - d.SetId("") - return nil - } - return diag.FromErr(err) - } - - err = monitorNotificationChannelIBMFunctionToResourceData(&nc, d) - if err != nil { - return diag.FromErr(err) - } - - return nil -} - -func resourceSysdigMonitorNotificationChannelIBMFunctionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client, err := getMonitorNotificationChannelClient(meta.(SysdigClients)) - if err != nil { - return diag.FromErr(err) - } - - teamID, err := client.CurrentTeamID(ctx) - if err != nil { - return diag.FromErr(err) - } - - nc, err := monitorNotificationChannelIBMFunctionFromResourceData(d, teamID) - if err != nil { - return diag.FromErr(err) - } - - nc.Version = d.Get("version").(int) - nc.ID, _ = strconv.Atoi(d.Id()) - - _, err = client.UpdateNotificationChannel(ctx, nc) - if err != nil { - return diag.FromErr(err) - } - - return nil -} - -func resourceSysdigMonitorNotificationChannelIBMFunctionDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client, err := getMonitorNotificationChannelClient(meta.(SysdigClients)) - if err != nil { - return diag.FromErr(err) - } - - id, _ := strconv.Atoi(d.Id()) - - err = client.DeleteNotificationChannel(ctx, id) - if err != nil { - return diag.FromErr(err) - } - - return nil -} - -func monitorNotificationChannelIBMFunctionFromResourceData(d *schema.ResourceData, teamID int) (nc v2.NotificationChannel, err error) { - nc, err = monitorNotificationChannelFromResourceData(d, teamID) - if err != nil { - return - } - - nc.Type = NOTIFICATION_CHANNEL_TYPE_IBM_FUNCTION - nc.Options.IbmFunctionType = d.Get("ibm_function_type").(string) - nc.Options.Url = d.Get("url").(string) - nc.Options.CustomData = d.Get("custom_data").(map[string]interface{}) - if nc.Options.IbmFunctionType == "CLOUD_FUNCTION" { - nc.Options.APIKey = d.Get("iam_api_key").(string) - } else { - nc.Options.APIKey = "" - } - if nc.Options.IbmFunctionType == "WEB_ACTION" { - nc.Options.AdditionalHeaders = map[string]interface{}{ - "X-Require-Whisk-Auth": d.Get("whisk_auth_token").(string), - } - } else { - nc.Options.AdditionalHeaders = map[string]interface{}{} - } - - return -} - -func monitorNotificationChannelIBMFunctionToResourceData(nc *v2.NotificationChannel, d *schema.ResourceData) (err error) { - err = monitorNotificationChannelToResourceData(nc, d) - if err != nil { - return - } - - _ = d.Set("ibm_function_type", nc.Options.IbmFunctionType) - _ = d.Set("url", nc.Options.Url) - _ = d.Set("custom_data", nc.Options.CustomData) - _ = d.Set("iam_api_key", nc.Options.APIKey) - if nc.Options.AdditionalHeaders != nil { - whishAuthToken, ok := nc.Options.AdditionalHeaders["X-Require-Whisk-Auth"] - if ok { - _ = d.Set("whisk_auth_token", whishAuthToken) - } - } - - return -} diff --git a/website/docs/d/monitor_notification_channel_ibm_function.md b/website/docs/d/monitor_notification_channel_ibm_function.md deleted file mode 100644 index d29083b9..00000000 --- a/website/docs/d/monitor_notification_channel_ibm_function.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -subcategory: "Sysdig Monitor" -layout: "sysdig" -page_title: "Sysdig: sysdig_monitor_notification_channel_email" -description: |- - Retrieves information about a Monitor notification channel of type IBM Function ---- - -# Data Source: sysdig_monitor_notification_channel_email - -Retrieves information about a Monitor notification channel of type IBM Function. - --> **Note:** Sysdig Terraform Provider is under rapid development at this point. If you experience any issue or discrepancy while using it, please make sure you have the latest version. If the issue persists, or you have a Feature Request to support an additional set of resources, please open a [new issue](https://github.com/sysdiglabs/terraform-provider-sysdig/issues/new) in the GitHub repository. - -## Example Usage - -```terraform -data "sysdig_monitor_notification_channel_email" "nc_email" { - name = "some notification channel name" -} -``` - -## Argument Reference - -* `name` - (Required) The name of the Notification Channel to retrieve. - -## Attributes Reference - -In addition to all arguments above, the following attributes are exported: - -* `id` - The Notification Channel ID. -* `name` - The Notification Channel Name. -* `ibm_function_type` - Type of IBM Function. -* `url` - URL of the IBM Function. -* `custom_data` - Key value list of additional parameters for the IBM Function. -* `whisk_auth_token` Whisk authentication token. -* `iam_api_key` - API Key to call the private cloud function. -* `enabled` - Whether the Notification Channel is active or not. -* `notify_when_ok` - Whether the Notification Channel sends a notification when the condition is no longer triggered. -* `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a - user. -* `version` - The version of the Notification Channel. -* `send_test_notification` - Whether the Notification Channel has enabled the test notification. diff --git a/website/docs/index.md b/website/docs/index.md index 345fe427..c27b9dd5 100644 --- a/website/docs/index.md +++ b/website/docs/index.md @@ -234,7 +234,6 @@ When IBM Workload Protection resources are to be created, this authentication mu > - `sysdig_secure_notification_channel_team_email` > - `sysdig_monitor_notification_channel_google_chat` > - `sysdig_monitor_notification_channel_custom_webhook` -> - `sysdig_monitor_notification_channel_ibm_function` > - `sysdig_monitor_notification_channel_ibm_event_notification` > - `sysdig_monitor_silence_rule` > - `sysdig_monitor_inhibition_rule` diff --git a/website/docs/r/monitor_notification_channel_ibm_function.md b/website/docs/r/monitor_notification_channel_ibm_function.md deleted file mode 100644 index 1458c06f..00000000 --- a/website/docs/r/monitor_notification_channel_ibm_function.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -subcategory: "Sysdig Monitor" -layout: "sysdig" -page_title: "Sysdig: sysdig_monitor_notification_channel_ibm_function" -description: |- - Creates a Sysdig Monitor Notification Channel of type IBM Function. ---- - -# Resource: sysdig_monitor_notification_channel_ibm_function - -Creates a Sysdig Monitor Notification Channel of type IBM Function. - --> **Note:** Sysdig Terraform Provider is under rapid development at this point. If you experience any issue or discrepancy while using it, please make sure you have the latest version. If the issue persists, or you have a Feature Request to support an additional set of resources, please open a [new issue](https://github.com/sysdiglabs/terraform-provider-sysdig/issues/new) in the GitHub repository. - -## Example Usage - -```terraform -resource "sysdig_monitor_notification_channel_ibm_function" "sample-ibm-function-web-action" { - name = "Example Channel - IBM Function - web action" - enabled = true - ibm_function_type = "WEB_ACTION" - url = "https://eu-gb.functions.cloud.ibm.com/api/v1/web/namespaces/eeeeeeee-623b-4776-ba35-4065bcbfee7b/actions/hello-world/helloworld?param=true" - whisk_auth_token = "xxx" - - custom_data = { - "data1": "value1" - "data2": "value2" - } - - notify_when_ok = false - notify_when_resolved = false - send_test_notification = false -} - -resource "sysdig_monitor_notification_channel_ibm_function" "sample-ibm-function-cloud-function" { - name = "Example Channel - IBM Function - cloud function" - ibm_function_type = "CLOUD_FUNCTION" - url = "https://eu-gb.functions.cloud.ibm.com/api/v1/namespaces/13eeeeee-623b-4776-ba35-4065bcbfee7b/actions/hello-world/myaction" - iam_api_key = "xxx" -} -``` - -## Argument Reference - -* `name` - (Required) The name of the Notification Channel. Must be unique. - -* `ibm_function_type` - (Required) Type of IBM Function. Can be `WEB_ACTION` for a Web Action (with or without X-Require-Whisk-Auth header) or `CLOUD_FUNCTION` for an IAM Secured Action. - -* `url` - (Required) URL of the IBM Function. - -* `custom_data` - (Optional) Key value list of additional parameters for the IBM Function. - -* `whisk_auth_token` - (Optional) Only if `ibm_function_type` is `WEB_ACTION`: Whisk authentication token. - -* `iam_api_key` - (Optional) Required if `ibm_function_type` is `CLOUD_FUNCTION`: API Key to call the private cloud function. - -* `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 - no longer triggered. Default is false. - -* `notify_when_resolved` - (Optional) Send a new notification when the alert is manually - acknowledged by a user. Default is false. - -* `send_test_notification` - (Optional) Send an initial test notification to check - if the notification channel is working. Default is false. - -* `share_with_current_team` - (Optional) If set to `true` it will share notification channel only with current team (in which user is logged in). - Otherwise, it will share it with all teams, which is the default behaviour. Although this is an optional setting, beware that if you have lower permissions than admin you may see a `error: 403 Forbidden` if this is not set to `true`. - -## Attributes Reference - -In addition to all arguments above, the following attributes are exported: - -* `id` - (Computed) The ID of the Notification Channel. - -* `version` - (Computed) The current version of the Notification Channel. - -## Import - -IBM Function notification channels for Monitor can be imported using the ID, e.g. - -``` -$ terraform import sysdig_monitor_notification_channel_ibm_function.example 12345 -```