Skip to content

Commit

Permalink
Merge pull request #37919 from GlennChia/f-aws_guardduty_malware_prot…
Browse files Browse the repository at this point in the history
…ection_plan

r/aws_guardduty_malware_protection_plan
  • Loading branch information
ewbankkit authored Jun 11, 2024
2 parents 32b7ada + 3aa743e commit 8fbbb25
Show file tree
Hide file tree
Showing 16 changed files with 1,595 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .changelog/37919.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_guardduty_malware_protection_plan
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/glacier v1.22.10
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.24.1
github.com/aws/aws-sdk-go-v2/service/groundstation v1.27.6
github.com/aws/aws-sdk-go-v2/service/guardduty v1.43.0
github.com/aws/aws-sdk-go-v2/service/healthlake v1.24.6
github.com/aws/aws-sdk-go-v2/service/iam v1.32.6
github.com/aws/aws-sdk-go-v2/service/identitystore v1.23.12
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.24.1 h1:bDVYY5tSzBnLAc
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.24.1/go.mod h1:ct31bulbJED7Z4Vdtr+Jtvt6bPRB5PdeH96NNm4wkOc=
github.com/aws/aws-sdk-go-v2/service/groundstation v1.27.6 h1:2GSPMCtOlEVwltVhqUT1x6CFKpFi/5D2yFhd/PqaSic=
github.com/aws/aws-sdk-go-v2/service/groundstation v1.27.6/go.mod h1:gFFqhE7646BA034Im+oTpkfnefC1AR/E4ZUTs/sV7lc=
github.com/aws/aws-sdk-go-v2/service/guardduty v1.43.0 h1:Jz/FJc/n27a9j1du1JxtBaMb/Wg/dSkWPbrfn2Y7CT4=
github.com/aws/aws-sdk-go-v2/service/guardduty v1.43.0/go.mod h1:tNfynl7aA5gEHA7yJZiEICHYMkITKSc0Z+vic+YpW0M=
github.com/aws/aws-sdk-go-v2/service/healthlake v1.24.6 h1:AlmacWcocqb7vowwTlYtVR9AbYWW4vFExIoD7+kFR4g=
github.com/aws/aws-sdk-go-v2/service/healthlake v1.24.6/go.mod h1:jp0Co1hHoXMEQTzyRICGBHvN8owh1QISx56d79dulFU=
github.com/aws/aws-sdk-go-v2/service/iam v1.32.6 h1:NRlKKQ/BPHPqsuN2Hy6v4WA8/bsRTP0j8/BFPBC5+SU=
Expand Down
5 changes: 5 additions & 0 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions internal/service/guardduty/exports_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package guardduty

// Exports for use in tests only.
var (
ResourceMalwareProtectionPlan = newResourceMalwareProtectionPlan
)
45 changes: 45 additions & 0 deletions internal/service/guardduty/find.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package guardduty

import (
"context"
"errors"

guardduty_v2 "github.com/aws/aws-sdk-go-v2/service/guardduty"
"github.com/aws/aws-sdk-go-v2/service/guardduty/types"
"github.com/aws/aws-sdk-go/aws"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

func FindMalwareProtectionPlanByID(ctx context.Context, conn *guardduty_v2.Client, id string) (*guardduty_v2.GetMalwareProtectionPlanOutput, error) {
input := &guardduty_v2.GetMalwareProtectionPlanInput{
MalwareProtectionPlanId: aws.String(id),
}

return FindMalwareProtectionPlan(ctx, conn, input)
}

func FindMalwareProtectionPlan(ctx context.Context, conn *guardduty_v2.Client, input *guardduty_v2.GetMalwareProtectionPlanInput) (*guardduty_v2.GetMalwareProtectionPlanOutput, error) {
result, err := conn.GetMalwareProtectionPlan(ctx, input)

if err != nil {
var nfe *types.ResourceNotFoundException
if errors.As(err, &nfe) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
}
}

return nil, err
}

if result == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return result, nil
}
1 change: 1 addition & 0 deletions internal/service/guardduty/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MPL-2.0

//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags
//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -TagsFunc=TagsV2 -KeyValueTagsFunc=keyValueTagsV2 -GetTagsInFunc=getTagsInV2 -SetTagsOutFunc=setTagsOutV2 -ServiceTagsMap -KVTValues -SkipTypesImp -SkipAWSServiceImp -SkipAWSImp -- tagsv2_gen.go
//go:generate go run ../../generate/servicepackage/main.go
// ONLY generate directives and package declaration! Do not add anything else to this file.

Expand Down
Loading

0 comments on commit 8fbbb25

Please sign in to comment.