Skip to content

Commit

Permalink
Add optional quals for aws_accessanalyzer_finding table (#2331)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbermuehler authored Nov 21, 2024
1 parent 504c16e commit f9e74da
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion aws/table_aws_accessanalyzer_finding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"context"
"errors"
"strconv"

"github.com/aws/aws-sdk-go-v2/service/accessanalyzer"
"github.com/aws/aws-sdk-go-v2/service/accessanalyzer/types"
Expand Down Expand Up @@ -46,14 +47,30 @@ func tableAwsAccessAnalyzerFinding(_ context.Context) *plugin.Table {
Name: "access_analyzer_arn",
Require: plugin.Optional,
},
{
Name: "error",
Require: plugin.Optional,
},
{
Name: "id",
Require: plugin.Optional,
},
{
Name: "is_public",
Require: plugin.Optional,
},
{
Name: "resource",
Require: plugin.Optional,
},
{
Name: "resource_owner_account",
Require: plugin.Optional,
},
{
Name: "resource_type",
Require: plugin.Optional,
},
{
Name: "status",
Require: plugin.Optional,
Expand Down Expand Up @@ -299,12 +316,30 @@ func getAccessAnalyzerFinding(ctx context.Context, d *plugin.QueryData, h *plugi
}

func setFilterCriteria(d *plugin.QueryData, input *accessanalyzer.ListFindingsInput) {
params := []string{"id", "status", "resource"}
params := []string{"id", "status", "resource", "error"}
for _, param := range params {
if d.Quals[param] != nil {
input.Filter[param] = types.Criterion{
Eq: []string{d.EqualsQualString(param)},
}
}
}

if d.Quals["resource_owner_account"] != nil {
input.Filter["resourceOwnerAccount"] = types.Criterion{
Eq: []string{d.EqualsQualString("resource_owner_account")},
}
}

if d.Quals["resource_type"] != nil {
input.Filter["resourceType"] = types.Criterion{
Eq: []string{d.EqualsQualString("resource_type")},
}
}

if d.EqualsQuals["is_public"] != nil {
input.Filter["isPublic"] = types.Criterion{
Eq: []string{strconv.FormatBool(d.EqualsQuals["is_public"].GetBoolValue())},
}
}
}

0 comments on commit f9e74da

Please sign in to comment.