diff --git a/resources/appconfig-applications.go b/resources/appconfig-applications.go deleted file mode 100644 index 81afeb9a..00000000 --- a/resources/appconfig-applications.go +++ /dev/null @@ -1,72 +0,0 @@ -package resources - -import ( - "context" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - - "github.com/ekristen/libnuke/pkg/resource" - "github.com/ekristen/libnuke/pkg/types" - - "github.com/ekristen/aws-nuke/pkg/nuke" -) - -type AppConfigApplication struct { - svc *appconfig.AppConfig - id *string - name *string -} - -const AppConfigApplicationResource = "AppConfigApplication" - -func init() { - resource.Register(&resource.Registration{ - Name: AppConfigApplicationResource, - Scope: nuke.Account, - Lister: &AppConfigApplicationLister{}, - DependsOn: []string{ - AppConfigConfigurationProfileResource, - AppConfigEnvironmentResource, - }, - }) -} - -type AppConfigApplicationLister struct{} - -func (l *AppConfigApplicationLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { - opts := o.(*nuke.ListerOpts) - - svc := appconfig.New(opts.Session) - resources := make([]resource.Resource, 0) - params := &appconfig.ListApplicationsInput{ - MaxResults: aws.Int64(50), - } - err := svc.ListApplicationsPages(params, func(page *appconfig.ListApplicationsOutput, lastPage bool) bool { - for _, item := range page.Items { - resources = append(resources, &AppConfigApplication{ - svc: svc, - id: item.Id, - name: item.Name, - }) - } - return true - }) - if err != nil { - return nil, err - } - return resources, nil -} - -func (f *AppConfigApplication) Remove(_ context.Context) error { - _, err := f.svc.DeleteApplication(&appconfig.DeleteApplicationInput{ - ApplicationId: f.id, - }) - return err -} - -func (f *AppConfigApplication) Properties() types.Properties { - return types.NewProperties(). - Set("ID", f.id). - Set("Name", f.name) -} diff --git a/resources/appconfig-configurationprofiles.go b/resources/appconfig-configurationprofiles.go deleted file mode 100644 index ea320164..00000000 --- a/resources/appconfig-configurationprofiles.go +++ /dev/null @@ -1,92 +0,0 @@ -package resources - -import ( - "context" - - "github.com/sirupsen/logrus" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - - "github.com/ekristen/libnuke/pkg/resource" - "github.com/ekristen/libnuke/pkg/types" - - "github.com/ekristen/aws-nuke/pkg/nuke" -) - -type AppConfigConfigurationProfile struct { - svc *appconfig.AppConfig - applicationId *string - id *string - name *string -} - -const AppConfigConfigurationProfileResource = "AppConfigConfigurationProfile" - -func init() { - resource.Register(&resource.Registration{ - Name: AppConfigConfigurationProfileResource, - Scope: nuke.Account, - Lister: &AppConfigConfigurationProfileLister{}, - DependsOn: []string{ - AppConfigHostedConfigurationVersionResource, - }, - }) -} - -type AppConfigConfigurationProfileLister struct{} - -func (l *AppConfigConfigurationProfileLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) { - opts := o.(*nuke.ListerOpts) - - svc := appconfig.New(opts.Session) - resources := make([]resource.Resource, 0) - - applicationLister := &AppConfigApplicationLister{} - - applications, err := applicationLister.List(ctx, o) - if err != nil { - return nil, err - } - for _, applicationResource := range applications { - application, ok := applicationResource.(*AppConfigApplication) - if !ok { - logrus.Errorf("Unable to cast AppConfigApplication.") - continue - } - params := &appconfig.ListConfigurationProfilesInput{ - ApplicationId: application.id, - MaxResults: aws.Int64(50), - } - err := svc.ListConfigurationProfilesPages(params, func(page *appconfig.ListConfigurationProfilesOutput, lastPage bool) bool { - for _, item := range page.Items { - resources = append(resources, &AppConfigConfigurationProfile{ - svc: svc, - applicationId: application.id, - id: item.Id, - name: item.Name, - }) - } - return true - }) - if err != nil { - return nil, err - } - } - return resources, nil -} - -func (f *AppConfigConfigurationProfile) Remove(_ context.Context) error { - _, err := f.svc.DeleteConfigurationProfile(&appconfig.DeleteConfigurationProfileInput{ - ApplicationId: f.applicationId, - ConfigurationProfileId: f.id, - }) - return err -} - -func (f *AppConfigConfigurationProfile) Properties() types.Properties { - return types.NewProperties(). - Set("ApplicationID", f.applicationId). - Set("ID", f.id). - Set("Name", f.name) -} diff --git a/resources/appconfig-deploymentstrategies.go b/resources/appconfig-deploymentstrategies.go deleted file mode 100644 index 30e5c074..00000000 --- a/resources/appconfig-deploymentstrategies.go +++ /dev/null @@ -1,77 +0,0 @@ -package resources - -import ( - "context" - "fmt" - "strings" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - - "github.com/ekristen/libnuke/pkg/resource" - "github.com/ekristen/libnuke/pkg/types" - - "github.com/ekristen/aws-nuke/pkg/nuke" -) - -type AppConfigDeploymentStrategy struct { - svc *appconfig.AppConfig - id *string - name *string -} - -const AppConfigDeploymentStrategyResource = "AppConfigDeploymentStrategy" - -func init() { - resource.Register(&resource.Registration{ - Name: AppConfigDeploymentStrategyResource, - Scope: nuke.Account, - Lister: &AppConfigDeploymentStrategyLister{}, - }) -} - -type AppConfigDeploymentStrategyLister struct{} - -func (l *AppConfigDeploymentStrategyLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { - opts := o.(*nuke.ListerOpts) - - svc := appconfig.New(opts.Session) - resources := make([]resource.Resource, 0) - params := &appconfig.ListDeploymentStrategiesInput{ - MaxResults: aws.Int64(50), - } - err := svc.ListDeploymentStrategiesPages(params, func(page *appconfig.ListDeploymentStrategiesOutput, lastPage bool) bool { - for _, item := range page.Items { - resources = append(resources, &AppConfigDeploymentStrategy{ - svc: svc, - id: item.Id, - name: item.Name, - }) - } - return true - }) - if err != nil { - return nil, err - } - return resources, nil -} - -func (f *AppConfigDeploymentStrategy) Filter() error { - if strings.HasPrefix(*f.name, "AppConfig.") { - return fmt.Errorf("cannot delete predefined Deployment Strategy") - } - return nil -} - -func (f *AppConfigDeploymentStrategy) Remove(_ context.Context) error { - _, err := f.svc.DeleteDeploymentStrategy(&appconfig.DeleteDeploymentStrategyInput{ - DeploymentStrategyId: f.id, - }) - return err -} - -func (f *AppConfigDeploymentStrategy) Properties() types.Properties { - return types.NewProperties(). - Set("ID", f.id). - Set("Name", f.name) -} diff --git a/resources/appconfig-environments.go b/resources/appconfig-environments.go deleted file mode 100644 index 960a5dca..00000000 --- a/resources/appconfig-environments.go +++ /dev/null @@ -1,88 +0,0 @@ -package resources - -import ( - "context" - - "github.com/sirupsen/logrus" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - - "github.com/ekristen/libnuke/pkg/resource" - "github.com/ekristen/libnuke/pkg/types" - - "github.com/ekristen/aws-nuke/pkg/nuke" -) - -type AppConfigEnvironment struct { - svc *appconfig.AppConfig - applicationId *string - id *string - name *string -} - -const AppConfigEnvironmentResource = "AppConfigEnvironment" - -func init() { - resource.Register(&resource.Registration{ - Name: AppConfigEnvironmentResource, - Scope: nuke.Account, - Lister: &AppConfigEnvironmentLister{}, - }) -} - -type AppConfigEnvironmentLister struct{} - -func (l *AppConfigEnvironmentLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) { - opts := o.(*nuke.ListerOpts) - - svc := appconfig.New(opts.Session) - resources := make([]resource.Resource, 0) - - applicationLister := &AppConfigApplicationLister{} - applications, err := applicationLister.List(ctx, o) - if err != nil { - return nil, err - } - for _, applicationResource := range applications { - application, ok := applicationResource.(*AppConfigApplication) - if !ok { - logrus.Errorf("Unable to cast AppConfigApplication.") - continue - } - params := &appconfig.ListEnvironmentsInput{ - ApplicationId: application.id, - MaxResults: aws.Int64(50), - } - err := svc.ListEnvironmentsPages(params, func(page *appconfig.ListEnvironmentsOutput, lastPage bool) bool { - for _, item := range page.Items { - resources = append(resources, &AppConfigEnvironment{ - svc: svc, - applicationId: application.id, - id: item.Id, - name: item.Name, - }) - } - return true - }) - if err != nil { - return nil, err - } - } - return resources, nil -} - -func (f *AppConfigEnvironment) Remove(_ context.Context) error { - _, err := f.svc.DeleteEnvironment(&appconfig.DeleteEnvironmentInput{ - ApplicationId: f.applicationId, - EnvironmentId: f.id, - }) - return err -} - -func (f *AppConfigEnvironment) Properties() types.Properties { - return types.NewProperties(). - Set("ApplicationID", f.applicationId). - Set("ID", f.id). - Set("Name", f.name) -} diff --git a/resources/appconfig-hostedconfigurationversions.go b/resources/appconfig-hostedconfigurationversions.go deleted file mode 100644 index cb38a7e4..00000000 --- a/resources/appconfig-hostedconfigurationversions.go +++ /dev/null @@ -1,90 +0,0 @@ -package resources - -import ( - "context" - - "github.com/sirupsen/logrus" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - - "github.com/ekristen/libnuke/pkg/resource" - "github.com/ekristen/libnuke/pkg/types" - - "github.com/ekristen/aws-nuke/pkg/nuke" -) - -type AppConfigHostedConfigurationVersion struct { - svc *appconfig.AppConfig - applicationId *string - configurationProfileId *string - versionNumber *int64 -} - -const AppConfigHostedConfigurationVersionResource = "AppConfigHostedConfigurationVersion" - -func init() { - resource.Register(&resource.Registration{ - Name: AppConfigHostedConfigurationVersionResource, - Scope: nuke.Account, - Lister: &AppConfigHostedConfigurationVersionLister{}, - }) -} - -type AppConfigHostedConfigurationVersionLister struct{} - -func (l *AppConfigHostedConfigurationVersionLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) { - opts := o.(*nuke.ListerOpts) - - svc := appconfig.New(opts.Session) - resources := make([]resource.Resource, 0) - - profilerLister := &AppConfigConfigurationProfileLister{} - configurationProfiles, err := profilerLister.List(ctx, o) - if err != nil { - return nil, err - } - for _, configurationProfileResource := range configurationProfiles { - configurationProfile, ok := configurationProfileResource.(*AppConfigConfigurationProfile) - if !ok { - logrus.Errorf("Unable to cast AppConfigConfigurationProfile.") - continue - } - params := &appconfig.ListHostedConfigurationVersionsInput{ - ApplicationId: configurationProfile.applicationId, - ConfigurationProfileId: configurationProfile.id, - MaxResults: aws.Int64(50), - } - err := svc.ListHostedConfigurationVersionsPages(params, func(page *appconfig.ListHostedConfigurationVersionsOutput, lastPage bool) bool { - for _, item := range page.Items { - resources = append(resources, &AppConfigHostedConfigurationVersion{ - svc: svc, - applicationId: configurationProfile.applicationId, - configurationProfileId: configurationProfile.id, - versionNumber: item.VersionNumber, - }) - } - return true - }) - if err != nil { - return nil, err - } - } - return resources, nil -} - -func (f *AppConfigHostedConfigurationVersion) Remove(_ context.Context) error { - _, err := f.svc.DeleteHostedConfigurationVersion(&appconfig.DeleteHostedConfigurationVersionInput{ - ApplicationId: f.applicationId, - ConfigurationProfileId: f.configurationProfileId, - VersionNumber: f.versionNumber, - }) - return err -} - -func (f *AppConfigHostedConfigurationVersion) Properties() types.Properties { - return types.NewProperties(). - Set("ApplicationID", f.applicationId). - Set("ConfigurationProfileID", f.configurationProfileId). - Set("VersionNumber", f.versionNumber) -}