forked from rebuy-de/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from oreillymedia/CL-869-glue-security-config
Add module to handle Glue security configurations
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/glue" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type GlueSecurityConfiguration struct { | ||
svc *glue.Glue | ||
name *string | ||
} | ||
|
||
func init() { | ||
register("GlueSecurityConfiguration", ListGlueSecurityConfigurations) | ||
} | ||
|
||
func ListGlueSecurityConfigurations(sess *session.Session) ([]Resource, error) { | ||
svc := glue.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &glue.GetSecurityConfigurationsInput{ | ||
MaxResults: aws.Int64(25), | ||
} | ||
|
||
for { | ||
output, err := svc.GetSecurityConfigurations(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, securityConfiguration := range output.SecurityConfigurations { | ||
resources = append(resources, &GlueSecurityConfiguration{ | ||
svc: svc, | ||
name: securityConfiguration.Name, | ||
}) | ||
} | ||
|
||
// Check if there are more security configurations to fetch | ||
if output.NextToken == nil || *output.NextToken == "" { | ||
break | ||
} | ||
|
||
params.NextToken = output.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *GlueSecurityConfiguration) Remove() error { | ||
_, err := f.svc.DeleteSecurityConfiguration(&glue.DeleteSecurityConfigurationInput{ | ||
Name: f.name, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *GlueSecurityConfiguration) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("Name", f.name) | ||
|
||
return properties | ||
} | ||
|
||
func (f *GlueSecurityConfiguration) String() string { | ||
return *f.name | ||
} |