Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/securityhub_insight: new resource #18494

Merged
merged 12 commits into from
Apr 15, 2021
3 changes: 3 additions & 0 deletions .changelog/18494.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_securityhub_insight
```
21 changes: 21 additions & 0 deletions aws/internal/service/securityhub/finder/finder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package finder

import (
"context"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/securityhub"
)
Expand Down Expand Up @@ -30,3 +32,22 @@ func AdminAccount(conn *securityhub.SecurityHub, adminAccountID string) (*securi

return result, err
}

func Insight(ctx context.Context, conn *securityhub.SecurityHub, arn string) (*securityhub.Insight, error) {
input := &securityhub.GetInsightsInput{
InsightArns: aws.StringSlice([]string{arn}),
MaxResults: aws.Int64(1),
}

output, err := conn.GetInsightsWithContext(ctx, input)

if err != nil {
return nil, err
}

if output == nil || len(output.Insights) == 0 {
return nil, nil
}

return output.Insights[0], nil
}
1 change: 1 addition & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ func Provider() *schema.Provider {
"aws_security_group_rule": resourceAwsSecurityGroupRule(),
"aws_securityhub_account": resourceAwsSecurityHubAccount(),
"aws_securityhub_action_target": resourceAwsSecurityHubActionTarget(),
"aws_securityhub_insight": resourceAwsSecurityHubInsight(),
"aws_securityhub_invite_accepter": resourceAwsSecurityHubInviteAccepter(),
"aws_securityhub_member": resourceAwsSecurityHubMember(),
"aws_securityhub_organization_admin_account": resourceAwsSecurityHubOrganizationAdminAccount(),
Expand Down
Loading