diff --git a/chronosphere/resource_bucket.go b/chronosphere/resource_bucket.go index 95d1333..ae08a04 100644 --- a/chronosphere/resource_bucket.go +++ b/chronosphere/resource_bucket.go @@ -270,7 +270,7 @@ func reconcileNotificationPolicy( } if independent { // Can only inline policies that are not independent - return diag.Errorf("cannot use notification_policy_data of owned policy, use a notification policy without team_id") + return diag.Errorf("cannot use notification_policy_data of named policy, use a notification policy without name") } // If policy wasn't set before and still isn't, no-op @@ -405,8 +405,8 @@ func policyModelFromBucket(d *schema.ResourceData) (policy *configmodels.Configv } // When deleting policies, only bucket-owned policies are deleted, deletes of -// other owned policies are ignored to support migrating from an inline policy -// to an independent team-owned policy. +// other policies are ignored to support migrating from an inline policy +// to an independent policy. func policyNotBucketOwned(err error) bool { err = clienterror.Wrap(err) diff --git a/chronosphere/resource_notification_policy.go b/chronosphere/resource_notification_policy.go index 3d595ef..676d5c0 100644 --- a/chronosphere/resource_notification_policy.go +++ b/chronosphere/resource_notification_policy.go @@ -419,7 +419,7 @@ func isNotificationPolicyIndependentForCustomizeDiff( return false } - return !isRawAttributeNull(diff, "team_id") + return !isRawAttributeNull(diff, "name") } func expandMatcherSchema(m intschema.Matcher) *configmodels.Configv1LabelMatcher { diff --git a/chronosphere/resource_notification_policy_independent.go b/chronosphere/resource_notification_policy_independent.go index a8db295..fa47feb 100644 --- a/chronosphere/resource_notification_policy_independent.go +++ b/chronosphere/resource_notification_policy_independent.go @@ -80,6 +80,9 @@ func (independentNotificationPolicyConverter) fromModel( // Note: BucketSlug being set should cause a change to be detected by TF. // Since a policy is either bucket-owned or team-owned, a bucket owned policy // will have no team, so the team will mismatch. + // TODO(brian.barnes): Now that policies can be unowned, it is no longer true + // that setting a bucket slug outside of terraform will lead to a mismatch, since + // team_id is not guaranteed to be set if a policy is not bucket-owned. return &intschema.NotificationPolicy{ Name: m.Name, Slug: m.Slug, diff --git a/chronosphere/tfschema/monitor.go b/chronosphere/tfschema/monitor.go index 0de6dcd..30e37fa 100644 --- a/chronosphere/tfschema/monitor.go +++ b/chronosphere/tfschema/monitor.go @@ -50,7 +50,7 @@ var Monitor = map[string]*schema.Schema{ Optional: true, ValidateDiagFunc: func(policyID any, _ cty.Path) diag.Diagnostics { if localid.IsLocalID(policyID.(string)) { - return diag.Errorf("cannot directly reference unowned notification policy, use a notifcation policy with team_id set") + return diag.Errorf("cannot directly reference unnamed notification policy, use a notification policy with name set") } return nil }, diff --git a/chronosphere/tfschema/notification_policy.go b/chronosphere/tfschema/notification_policy.go index 2bac645..a25a1cf 100644 --- a/chronosphere/tfschema/notification_policy.go +++ b/chronosphere/tfschema/notification_policy.go @@ -26,18 +26,18 @@ import ( const IndependentNotificationPolicyData = "__independent" var NotificationPolicy = map[string]*schema.Schema{ - // NB: slug may be set if bucket_id or team_id is set, but cannot be set if bucket_id and team_id are unset. + // NB: slug can only be set if name is set, but cannot be set if name is unset, e.g. inline. "slug": { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, }, + // NB: there is custom name ForceNew behavior in the DiffSuppressFunc. "name": { Type: schema.TypeString, Optional: true, }, - // NB: there is custom team_id ForceNew behavior in the DiffSuppressFunc. "team_id": { Type: schema.TypeString, Optional: true, @@ -61,8 +61,8 @@ var NotificationPolicy = map[string]*schema.Schema{ DiffSuppressFunc: JSONNotificationPolicyDiffSuppress, ValidateFunc: ValidateNotificationPolicyData, }, - // This field is for internal use only. We use it to force new resources when the ownership - // of a notification policy changes (from unowned to independent or vice versa) + // This field is for internal use only. We use it to force new resources when the name + // of a notification policy changes (from inline to independent or vice versa) "is_independent": { Type: schema.TypeBool, Computed: true,