diff --git a/pagerdutyplugin/data_source_pagerduty_alert_grouping_setting.go b/pagerdutyplugin/data_source_pagerduty_alert_grouping_setting.go index 34218ee94..b6f4c564f 100644 --- a/pagerdutyplugin/data_source_pagerduty_alert_grouping_setting.go +++ b/pagerdutyplugin/data_source_pagerduty_alert_grouping_setting.go @@ -68,13 +68,12 @@ func (d *dataSourceAlertGroupingSetting) Read(ctx context.Context, req datasourc return } - var cursorAfter, cursorBefore string + var cursorAfter string var found *pagerduty.AlertGroupingSetting err := apiutil.All(ctx, func(offset int) (bool, error) { resp, err := d.client.ListAlertGroupingSettings(ctx, pagerduty.ListAlertGroupingSettingsOptions{ - After: cursorAfter, - Before: cursorBefore, - Limit: 100, + After: cursorAfter, + Limit: 100, }) if err != nil { return false, err @@ -87,6 +86,7 @@ func (d *dataSourceAlertGroupingSetting) Read(ctx context.Context, req datasourc } } + cursorAfter = resp.After return resp.After != "", nil }) if err != nil { diff --git a/pagerdutyplugin/resource_pagerduty_alert_grouping_setting.go b/pagerdutyplugin/resource_pagerduty_alert_grouping_setting.go index 0e5f1f834..7b0d31355 100644 --- a/pagerdutyplugin/resource_pagerduty_alert_grouping_setting.go +++ b/pagerdutyplugin/resource_pagerduty_alert_grouping_setting.go @@ -147,6 +147,9 @@ func (r *resourceAlertGroupingSetting) Create(ctx context.Context, req resource. err := retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError { response, err := r.client.CreateAlertGroupingSetting(ctx, plan) if err != nil { + if util.IsBadRequestError(err) { + return retry.NonRetryableError(err) + } return retry.RetryableError(err) } plan.ID = response.ID