Skip to content

Commit fabfbb6

Browse files
authored
Merge pull request #45348 from hashicorp/b-billing-sweep
sweeper/aws_billing_view: Skips non-`CUSTOM` billing views
2 parents 3588fdf + 3f9bbc4 commit fabfbb6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

internal/service/billing/sweep.go

Lines changed: 12 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,13 @@ 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+
names.AttrName: aws.ToString(v.Name),
43+
"skip_reason": fmt.Sprintf("View Type is %q", v.BillingViewType),
44+
})
45+
continue
46+
}
3647
sweepResources = append(sweepResources, framework.NewSweepResource(newResourceView, client,
3748
framework.NewAttribute(names.AttrARN, aws.ToString(v.Arn))),
3849
)

0 commit comments

Comments
 (0)