Skip to content

Commit

Permalink
Merge pull request #177 from ekristen/fix-configservice-configrules
Browse files Browse the repository at this point in the history
fix(configservice-configrules): filter out rules created by config-conforms
  • Loading branch information
ekristen authored May 20, 2024
2 parents 91ab562 + 3e4f4ca commit c9e8d90
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion resources/configservice-configrules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package resources

import (
"context"

"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/configservice"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

"github.com/ekristen/aws-nuke/pkg/nuke"
)
Expand Down Expand Up @@ -69,6 +69,10 @@ func (f *ConfigServiceConfigRule) Filter() error {
return fmt.Errorf("cannot remove rule owned by securityhub.amazonaws.com")
}

if aws.StringValue(f.createdBy) == "config-conforms.amazonaws.com" {
return fmt.Errorf("cannot remove rule owned by config-conforms.amazonaws.com")
}

return nil
}

Expand All @@ -83,3 +87,9 @@ func (f *ConfigServiceConfigRule) Remove(_ context.Context) error {
func (f *ConfigServiceConfigRule) String() string {
return *f.configRuleName
}

func (f *ConfigServiceConfigRule) Properties() types.Properties {
props := types.NewProperties()
props.Set("CreatedBy", f.createdBy)
return props
}

0 comments on commit c9e8d90

Please sign in to comment.