diff --git a/docs/resources/metric_alert.md b/docs/resources/metric_alert.md index b2c010f2..03639da7 100644 --- a/docs/resources/metric_alert.md +++ b/docs/resources/metric_alert.md @@ -95,13 +95,13 @@ resource "sentry_metric_alert" "main" { Required: +- `action` (Block List, Min: 1) (see [below for nested schema](#nestedblock--trigger--action)) - `alert_threshold` (Number) - `label` (String) - `threshold_type` (Number) Optional: -- `action` (Block List) (see [below for nested schema](#nestedblock--trigger--action)) - `resolve_threshold` (Number) Read-Only: diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 64322c4a..65c3a50f 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -111,8 +111,8 @@ func (p *SentryProvider) Resources(ctx context.Context) []func() resource.Resour func (p *SentryProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ NewAllClientKeysDataSource, - NewAllProjectsDataSource, NewAllOrganizationMembersDataSource, + NewAllProjectsDataSource, NewClientKeyDataSource, NewIssueAlertDataSource, NewOrganizationDataSource, diff --git a/sentry/data_source_sentry_metric_alert_test.go b/sentry/data_source_sentry_metric_alert_test.go index 8ec8ddcb..52ae03c0 100644 --- a/sentry/data_source_sentry_metric_alert_test.go +++ b/sentry/data_source_sentry_metric_alert_test.go @@ -45,7 +45,7 @@ func TestAccSentryMetricAlertDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dn, "owners", rn, "owners"), resource.TestCheckResourceAttr(dn, "trigger.#", "2"), resource.TestCheckResourceAttrPair(dn, "triggers.0", rn, "triggers.0"), - resource.TestCheckResourceAttr(dn, "trigger.0.action.#", "0"), + resource.TestCheckResourceAttr(dn, "trigger.0.action.#", "1"), resource.TestCheckResourceAttrPair(dn, "triggers.1", rn, "triggers.1"), resource.TestCheckResourceAttr(dn, "trigger.1.action.#", "1"), testAccCheckSentryMetricAlertExists(rnCopy, &alertCopyID), @@ -85,6 +85,12 @@ resource "sentry_metric_alert" "test" { resolve_threshold = 100.0 trigger { + action { + type = "email" + target_type = "team" + target_identifier = sentry_team.test.internal_id + } + alert_threshold = 1000 label = "critical" resolve_threshold = 100.0 diff --git a/sentry/resource_sentry_metric_alert.go b/sentry/resource_sentry_metric_alert.go index 3aa29b11..41c8197a 100644 --- a/sentry/resource_sentry_metric_alert.go +++ b/sentry/resource_sentry_metric_alert.go @@ -107,7 +107,7 @@ func resourceSentryMetricAlert() *schema.Resource { }, "action": { Type: schema.TypeList, - Optional: true, + Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { diff --git a/sentry/resource_sentry_metric_alert_test.go b/sentry/resource_sentry_metric_alert_test.go index 5a0392e0..11e2980a 100644 --- a/sentry/resource_sentry_metric_alert_test.go +++ b/sentry/resource_sentry_metric_alert_test.go @@ -134,7 +134,6 @@ resource "sentry_metric_alert" "test" { type = "email" target_type = "team" target_identifier = sentry_team.test.internal_id - integration_id = 32 } alert_threshold = 1000 @@ -144,6 +143,12 @@ resource "sentry_metric_alert" "test" { } trigger { + action { + type = "email" + target_type = "team" + target_identifier = sentry_team.test.internal_id + } + alert_threshold = 500 label = "warning" resolve_threshold = 100.0