Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions docs/data-sources/monitor_alert_channels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
page_title: "Linode: linode_monitor_alert_channels"
description: |-
Provides information about Linode Monitor Alert notification channels.
---

# Data Source: linode_monitor_alert_channels

Use this data source to query Linode Monitor Alert notification channels.
For more information, see the [Linode APIv4 docs](https://techdocs.akamai.com/linode-api/reference/get-notification-channels). (**Note: v4beta only.**)

## Example Usage

Retrieve ALL Monitor Alert Channels:

```hcl
data "linode_monitor_alert_channels" "all" {}
```

## Filter Example

```hcl
data "linode_monitor_alert_channels" "system" {
filter {
name = "type"
values = ["system"]
}
}
```

## Arguments Reference

The following arguments are supported:

* [`filter`](#filter) - (Optional) A set of filters used to select monitor alert channels that meet certain requirements.

### Filter

* `name` - (Required) The name of the field to filter by. See the [Filterable Fields section](#filterable-fields) for a complete list of filterable fields.
* `values` - (Required) A list of values for the filter to allow. These values should all be in string form.
* `match_by` - (Optional) The method to match the field by. (`exact`, `regex`, `substring`; default `exact`)

## Attributes Reference

Each Alert Channel will be stored in the `monitor_alert_channels` attribute and will export the following attributes:

* `id` - The unique ID of the channel.
* `label` - The display label for the channel.
* `type` - The channel type (`system` or `user`).
* `channel_type` - The notification transport type (currently `email`).
* `created` - When the channel was created.
* `updated` - When the channel was last updated.
* `created_by` - The user who created the channel, or `system`.
* `updated_by` - The user who last updated the channel, or `system`.
* `alerts` - Alert linkage metadata for this channel.
* `url` - The API URL for associated alerts.
* `type` - The alert type associated with the channel.
* `alert_count` - The number of associated alerts.
* `details` - Channel configuration details.
* `email` - Email-specific configuration details.
* `usernames` - Usernames that receive notifications.
* `recipient_type` - Recipient selection mode (for example `read_write_users` or `user`).

## Filterable Fields

The following top-level fields can be used with the `filter` block:

* `id`
* `label`
* `type`
* `channel_type`
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ require (
github.com/hashicorp/terraform-plugin-mux v0.23.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.0
github.com/hashicorp/terraform-plugin-testing v1.15.0
github.com/linode/linodego v1.67.0
github.com/linode/linodego v1.68.0
github.com/linode/linodego/k8s v1.25.2
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.49.0
golang.org/x/net v0.52.0
golang.org/x/crypto v0.50.0
golang.org/x/sync v0.20.0
)

Expand Down Expand Up @@ -100,13 +99,14 @@ require (
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.17.0 // indirect
golang.org/x/mod v0.33.0 // indirect
golang.org/x/mod v0.34.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/term v0.41.0 // indirect
golang.org/x/text v0.35.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/term v0.42.0 // indirect
golang.org/x/text v0.36.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.42.0 // indirect
golang.org/x/tools v0.43.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/grpc v1.79.3 // indirect
Expand Down
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/linode/linodego v1.67.0 h1:pomhFuuCCJI4N6emtB9027h1yXHY2/MIT0hwHEFwvq4=
github.com/linode/linodego v1.67.0/go.mod h1:+9mbdu0P3WMRCl0QbVfiFavR+Iel7TCRDJk3nInyx14=
github.com/linode/linodego v1.68.0 h1:lAsXuHm/cwQT3KCbVpMGtRiH8IpQl4hUuBOXpqkuNwo=
github.com/linode/linodego v1.68.0/go.mod h1:X7nmTNq1GmZT4bG6w9aiuVrOnhVxYaywrzxM+buC/qU=
github.com/linode/linodego/k8s v1.25.2 h1:PY6S0sAD3xANVvM9WY38bz9GqMTjIbytC8IJJ9Cv23o=
github.com/linode/linodego/k8s v1.25.2/go.mod h1:DC1XCSRZRGsmaa/ggpDPSDUmOM6aK1bhSIP6+f9Cwhc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand Down Expand Up @@ -293,21 +293,21 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -330,27 +330,27 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s=
golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion linode/firewall/helpers.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package firewall

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/linode/linodego"
"golang.org/x/net/context"
)

// firewallDeviceAssignment is a helper struct intended to be used in conjunction
Expand Down
2 changes: 2 additions & 0 deletions linode/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
"github.com/linode/terraform-provider-linode/v3/linode/lock"
"github.com/linode/terraform-provider-linode/v3/linode/locks"
"github.com/linode/terraform-provider-linode/v3/linode/maintenancepolicies"
"github.com/linode/terraform-provider-linode/v3/linode/monitoralertchannels"
"github.com/linode/terraform-provider-linode/v3/linode/monitoralertdefinition"
"github.com/linode/terraform-provider-linode/v3/linode/monitoralertdefinitions"
"github.com/linode/terraform-provider-linode/v3/linode/nb"
Expand Down Expand Up @@ -382,5 +383,6 @@ func (p *FrameworkProvider) DataSources(ctx context.Context) []func() datasource
lkenodepool.NewDataSource,
regionvpcavailability.NewDataSource,
regionsvpcavailability.NewDataSource,
monitoralertchannels.NewDataSource,
}
}
2 changes: 1 addition & 1 deletion linode/helper/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (f FilterConfig) GetFilterID(d *schema.ResourceData) (string, error) {
return "", err
}

hash := sha3.Sum512(result)
hash := sha3.Sum512(result) //nolint:govet
return base64.StdEncoding.EncodeToString(hash[:]), nil
}

Expand Down
2 changes: 1 addition & 1 deletion linode/helper/frameworkfilter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (f Config) GenerateID(filters []FilterModel) (types.String, diag.Diagnostic
)
}

hash := sha3.Sum512(filterJSON)
hash := sha3.Sum512(filterJSON) //nolint:govet
return types.StringValue(base64.StdEncoding.EncodeToString(hash[:])), nil
}

Expand Down
2 changes: 1 addition & 1 deletion linode/instance/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ func rootPasswordState(val any) string {

// hashString hashes a string.
func hashString(key string) string {
hash := sha3.Sum512([]byte(key))
hash := sha3.Sum512([]byte(key)) //nolint:govet
return base64.StdEncoding.EncodeToString(hash[:])
}

Expand Down
91 changes: 91 additions & 0 deletions linode/monitoralertchannels/datasource_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//go:build integration || monitoralertchannels

package monitoralertchannels_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
"github.com/linode/terraform-provider-linode/v3/linode/acceptance"
"github.com/linode/terraform-provider-linode/v3/linode/monitoralertchannels/tmpl"
)

func TestAccDataSourceMonitorAlertChannels_basic(t *testing.T) {
t.Parallel()

resourceName := "data.linode_monitor_alert_channels.channels"

resource.Test(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
ProtoV6ProviderFactories: acceptance.ProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: tmpl.DataBasic(t),
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("id"), knownvalue.NotNull()),
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("monitor_alert_channels"), knownvalue.NotNull()),

statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("id"), knownvalue.NotNull()),
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("label"), knownvalue.NotNull()),
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("type"), knownvalue.NotNull()),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("channel_type"),
knownvalue.NotNull(),
),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("created"),
knownvalue.NotNull(),
),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("updated"),
knownvalue.NotNull(),
),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("created_by"),
knownvalue.NotNull(),
),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("updated_by"),
knownvalue.NotNull(),
),

statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("alerts").AtMapKey("url"),
knownvalue.NotNull(),
),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("alerts").AtMapKey("type"),
knownvalue.NotNull(),
),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("alerts").AtMapKey("alert_count"),
knownvalue.NotNull(),
),
},
},
{
Config: tmpl.DataFilter(t, "system"),
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("id"), knownvalue.NotNull()),
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("monitor_alert_channels"), knownvalue.NotNull()),
statecheck.ExpectKnownValue(
resourceName,
tfjsonpath.New("monitor_alert_channels").AtSliceIndex(0).AtMapKey("type"),
knownvalue.StringExact("system"),
),
},
},
},
})
}
Loading
Loading