Skip to content

Commit 6d6f99d

Browse files
committed
Skips Billing Views with type other than CUSTOM
1 parent f437568 commit 6d6f99d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/service/billing/sweep.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ package billing
55

66
import (
77
"context"
8+
"fmt"
89

910
"github.com/YakDriver/smarterr"
1011
"github.com/aws/aws-sdk-go-v2/aws"
1112
"github.com/aws/aws-sdk-go-v2/service/billing"
13+
awstypes "github.com/aws/aws-sdk-go-v2/service/billing/types"
14+
"github.com/hashicorp/terraform-plugin-log/tflog"
1215
"github.com/hashicorp/terraform-provider-aws/internal/conns"
1316
"github.com/hashicorp/terraform-provider-aws/internal/sweep"
1417
"github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2"
@@ -21,10 +24,11 @@ func RegisterSweepers() {
2124
}
2225

2326
func sweepViews(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
24-
input := billing.ListBillingViewsInput{}
2527
conn := client.BillingClient(ctx)
28+
2629
var sweepResources []sweep.Sweepable
2730

31+
input := billing.ListBillingViewsInput{}
2832
pages := billing.NewListBillingViewsPaginator(conn, &input)
2933
for pages.HasMorePages() {
3034
page, err := pages.NextPage(ctx)
@@ -33,6 +37,12 @@ func sweepViews(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable
3337
}
3438

3539
for _, v := range page.BillingViews {
40+
if v.BillingViewType != awstypes.BillingViewTypeCustom {
41+
tflog.Info(ctx, "Skipping resource", map[string]any{
42+
"skip_reason": fmt.Sprintf("View Type is %q", v.BillingViewType),
43+
})
44+
continue
45+
}
3646
sweepResources = append(sweepResources, framework.NewSweepResource(newResourceView, client,
3747
framework.NewAttribute(names.AttrARN, aws.ToString(v.Arn))),
3848
)

0 commit comments

Comments
 (0)