-
-
Notifications
You must be signed in to change notification settings - Fork 38
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 #492 from ekristen/feat-ssm
feat: ssm quick setup resources
- Loading branch information
Showing
7 changed files
with
125 additions
and
7 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,31 @@ | ||
--- | ||
generated: true | ||
--- | ||
|
||
# SSMQuickSetupConfigurationManager | ||
|
||
|
||
## Resource | ||
|
||
```text | ||
SSMQuickSetupConfigurationManager | ||
``` | ||
|
||
## Properties | ||
|
||
|
||
- `ARN`: No Description | ||
- `Name`: No Description | ||
|
||
!!! note - Using Properties | ||
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property | ||
names to write filters for what you want to **keep** and omit from the nuke process. | ||
|
||
### String Property | ||
|
||
The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all | ||
resources support properties. To write a filter against the string representation, simply omit the `property` field in | ||
the filter. | ||
|
||
The string value is always what is used in the output of the log format when a resource is identified. | ||
|
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
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
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
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
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,82 @@ | ||
package resources | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/gotidy/ptr" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/ssmquicksetup" | ||
|
||
"github.com/ekristen/libnuke/pkg/registry" | ||
"github.com/ekristen/libnuke/pkg/resource" | ||
"github.com/ekristen/libnuke/pkg/types" | ||
|
||
"github.com/ekristen/aws-nuke/v3/pkg/nuke" | ||
) | ||
|
||
const SSMQuickSetupConfigurationManagerResource = "SSMQuickSetupConfigurationManager" | ||
|
||
func init() { | ||
registry.Register(®istry.Registration{ | ||
Name: SSMQuickSetupConfigurationManagerResource, | ||
Scope: nuke.Account, | ||
Resource: &SSMQuickSetupConfigurationManager{}, | ||
Lister: &SSMQuickSetupConfigurationManagerLister{}, | ||
}) | ||
} | ||
|
||
type SSMQuickSetupConfigurationManagerLister struct{} | ||
|
||
func (l *SSMQuickSetupConfigurationManagerLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) { | ||
opts := o.(*nuke.ListerOpts) | ||
svc := ssmquicksetup.NewFromConfig(*opts.Config) | ||
var resources []resource.Resource | ||
|
||
res, err := svc.ListConfigurationManagers(ctx, &ssmquicksetup.ListConfigurationManagersInput{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, p := range res.ConfigurationManagersList { | ||
resources = append(resources, &SSMQuickSetupConfigurationManager{ | ||
svc: svc, | ||
ARN: p.ManagerArn, | ||
Name: p.Name, | ||
}) | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
type SSMQuickSetupConfigurationManager struct { | ||
svc *ssmquicksetup.Client | ||
ARN *string | ||
Name *string | ||
} | ||
|
||
// GetName returns the name of the resource or the last part of the ARN if not set so that the stringer resource has | ||
// a value to display | ||
func (r *SSMQuickSetupConfigurationManager) GetName() string { | ||
if ptr.ToString(r.Name) != "" { | ||
return ptr.ToString(r.Name) | ||
} | ||
|
||
parts := strings.Split(ptr.ToString(r.ARN), "/") | ||
return parts[len(parts)-1] | ||
} | ||
|
||
func (r *SSMQuickSetupConfigurationManager) Remove(ctx context.Context) error { | ||
_, err := r.svc.DeleteConfigurationManager(ctx, &ssmquicksetup.DeleteConfigurationManagerInput{ | ||
ManagerArn: r.ARN, | ||
}) | ||
return err | ||
} | ||
|
||
func (r *SSMQuickSetupConfigurationManager) Properties() types.Properties { | ||
return types.NewPropertiesFromStruct(r) | ||
} | ||
|
||
func (r *SSMQuickSetupConfigurationManager) String() string { | ||
return r.GetName() | ||
} |
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