Skip to content

Commit

Permalink
r/aws_appfabric_app_authorization: Add sweeper.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Sep 30, 2024
1 parent 3b8b39c commit e2c1af1
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion internal/service/appfabric/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import (
)

func RegisterSweepers() {
awsv2.Register("aws_appfabric_app_bundle", sweepAppBundles)
awsv2.Register("aws_appfabric_app_bundle", sweepAppBundles, "aws_appfabric_app_authorization")
awsv2.Register("aws_appfabric_app_authorization", sweepAppAuthorizations)
}

func sweepAppBundles(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
Expand All @@ -40,3 +41,42 @@ func sweepAppBundles(ctx context.Context, client *conns.AWSClient) ([]sweep.Swee

return sweepResources, nil
}

func sweepAppAuthorizations(ctx context.Context, client *conns.AWSClient) ([]sweep.Sweepable, error) {
conn := client.AppFabricClient(ctx)
input := &appfabric.ListAppBundlesInput{}
var sweepResources []sweep.Sweepable

pages := appfabric.NewListAppBundlesPaginator(conn, input)
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if err != nil {
return nil, err
}

for _, v := range page.AppBundleSummaryList {
appBundleARN := aws.ToString(v.Arn)
input := &appfabric.ListAppAuthorizationsInput{
AppBundleIdentifier: aws.String(appBundleARN),
}

pages := appfabric.NewListAppAuthorizationsPaginator(conn, input)
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if err != nil {
return nil, err
}

for _, v := range page.AppAuthorizationSummaryList {
sweepResources = append(sweepResources, framework.NewSweepResource(newAppAuthorizationResource, client,
framework.NewAttribute("app_bundle_arn", appBundleARN),
framework.NewAttribute(names.AttrARN, aws.ToString(v.AppAuthorizationArn))))
}
}
}
}

return sweepResources, nil
}

0 comments on commit e2c1af1

Please sign in to comment.