Documentation
¶
Index ¶
- Constants
- type BulkDeleteFunc
- type BulkResultDeleteFunc
- type DeleteFunc
- type NukeResult
- type NukeableResource
- type NukerFunc
- func BulkDeleter[C any](deleteFn BulkDeleteFunc[C]) NukerFunc[C]
- func BulkResultDeleter[C any](deleteFn BulkResultDeleteFunc[C]) NukerFunc[C]
- func ConcurrentDeleteThenWaitAll[C any](deleteFn DeleteFunc[C], waitAllFn WaitAllFunc[C]) NukerFunc[C]
- func MultiStepDeleter[C any](steps ...DeleteFunc[C]) NukerFunc[C]
- func SequentialDeleteThenWaitAll[C any](deleteFn DeleteFunc[C], waitAllFn WaitAllFunc[C]) NukerFunc[C]
- func SequentialDeleter[C any](deleteFn DeleteFunc[C]) NukerFunc[C]
- func SimpleBatchDeleter[C any](deleteFn DeleteFunc[C]) NukerFunc[C]
- type Resource
- func (r *Resource[C]) GetAndSetIdentifiers(ctx context.Context, configObj config.Config) ([]string, error)
- func (r *Resource[C]) GetAndSetResourceConfig(configObj config.Config) config.ResourceType
- func (r *Resource[C]) Init(cfg any)
- func (r *Resource[C]) IsNukable(id string) (bool, error)
- func (r *Resource[C]) MaxBatchSize() int
- func (r *Resource[C]) Nuke(ctx context.Context, identifiers []string) ([]NukeResult, error)
- func (r *Resource[C]) ResourceIdentifiers() []string
- func (r *Resource[C]) ResourceName() string
- type Scope
- type WaitAllFunc
Constants ¶
const DefaultBatchSize = 50
DefaultBatchSize is the maximum number of resources per batch
const (
// DefaultMaxConcurrent is the default number of concurrent deletions
DefaultMaxConcurrent = 10
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkDeleteFunc ¶
BulkDeleteFunc is a function that deletes multiple resources in a single API call.
type BulkResultDeleteFunc ¶
type BulkResultDeleteFunc[C any] func(ctx context.Context, client C, ids []string) []NukeResult
BulkResultDeleteFunc is a function that deletes multiple resources and returns per-item results. Use this for AWS APIs that return partial success/failure (e.g., ReleaseHosts, DeleteMessageBatch).
type DeleteFunc ¶
DeleteFunc is a function that deletes a single resource by ID.
func DeleteThenWait ¶
func DeleteThenWait[C any](deleteFn DeleteFunc[C], waitFn DeleteFunc[C]) DeleteFunc[C]
DeleteThenWait combines a delete function with a wait function into a single DeleteFunc. Use this with SequentialDeleter for resources that need to wait for deletion to complete.
Example:
Nuker: resource.SequentialDeleter(resource.DeleteThenWait(
deleteCluster,
waitForClusterDeleted,
))
type NukeResult ¶
NukeResult represents the result of nuking a single resource.
type NukeableResource ¶
type NukeableResource interface {
ResourceName() string
ResourceIdentifiers() []string
MaxBatchSize() int
Nuke(ctx context.Context, identifiers []string) ([]NukeResult, error)
GetAndSetIdentifiers(ctx context.Context, configObj config.Config) ([]string, error)
IsNukable(string) (bool, error)
GetAndSetResourceConfig(config.Config) config.ResourceType
}
NukeableResource defines the common interface for all cloud resources that can be nuked. This is embedded by provider-specific interfaces (AwsResource, GcpResource) which add their own Init method with provider-specific config types.
type NukerFunc ¶
type NukerFunc[C any] func(ctx context.Context, client C, scope Scope, resourceType string, identifiers []*string) []NukeResult
NukerFunc is the standard signature for batch deletion functions. Returns results for each identifier. Reporting is handled by Resource.Nuke().
func BulkDeleter ¶
func BulkDeleter[C any](deleteFn BulkDeleteFunc[C]) NukerFunc[C]
BulkDeleter creates a nuker for APIs that support batch deletion in a single call. Use this for AWS APIs like DeleteDashboards that accept an array of identifiers. Note: All identifiers share the same error since it's a single API call.
func BulkResultDeleter ¶
func BulkResultDeleter[C any](deleteFn BulkResultDeleteFunc[C]) NukerFunc[C]
BulkResultDeleter creates a nuker for APIs that return per-item results in a bulk operation. Use this for AWS APIs where some items can succeed while others fail in the same call.
func ConcurrentDeleteThenWaitAll ¶
func ConcurrentDeleteThenWaitAll[C any](deleteFn DeleteFunc[C], waitAllFn WaitAllFunc[C]) NukerFunc[C]
ConcurrentDeleteThenWaitAll creates a nuker that: 1. Deletes all resources concurrently with controlled parallelism 2. Waits for ALL successfully deleted resources to be confirmed deleted
Use this for resources where concurrent deletion is safe and the wait API can check multiple resources at once.
Example:
Nuker: resource.ConcurrentDeleteThenWaitAll(
deleteOpenSearchDomain,
waitForOpenSearchDomainsDeleted,
)
func MultiStepDeleter ¶
func MultiStepDeleter[C any](steps ...DeleteFunc[C]) NukerFunc[C]
MultiStepDeleter creates a nuker that executes multiple steps per resource in sequence. Use this for resources that require cleanup before deletion (e.g., detach policies, empty bucket). Each resource is processed sequentially, but if any step fails for a resource, it moves to the next resource.
func SequentialDeleteThenWaitAll ¶
func SequentialDeleteThenWaitAll[C any](deleteFn DeleteFunc[C], waitAllFn WaitAllFunc[C]) NukerFunc[C]
SequentialDeleteThenWaitAll creates a nuker that: 1. Deletes all resources sequentially 2. Waits for ALL successfully deleted resources to be confirmed deleted
Use this for resources where the delete API returns immediately but the resource takes time to be fully deleted, and the wait API can check multiple resources at once.
Example:
Nuker: resource.SequentialDeleteThenWaitAll(
deleteASG,
waitForASGsDeleted, // Uses autoscaling.NewGroupNotExistsWaiter
)
func SequentialDeleter ¶
func SequentialDeleter[C any](deleteFn DeleteFunc[C]) NukerFunc[C]
SequentialDeleter creates a nuker that deletes resources one at a time. Use this for APIs with strict rate limits.
func SimpleBatchDeleter ¶
func SimpleBatchDeleter[C any](deleteFn DeleteFunc[C]) NukerFunc[C]
SimpleBatchDeleter creates a nuker that deletes resources concurrently. Uses DefaultMaxConcurrent for parallelism control.
type Resource ¶
type Resource[C any] struct { // ResourceTypeName is the unique identifier (e.g., "ec2-keypairs", "gcs-bucket") ResourceTypeName string // BatchSize is the maximum number of resources to delete per batch. // If 0, defaults to DefaultBatchSize (50). // Set based on AWS/GCP API rate limits for this resource type. BatchSize int // InitClient initializes the client from cloud-specific config. // For AWS: cfg is aws.Config // For GCP: cfg is resources.GcpConfig // Set r.Client and r.Scope directly in this function. InitClient func(r *Resource[C], cfg any) // ConfigGetter retrieves the resource-specific config section ConfigGetter func(c config.Config) config.ResourceType // Lister retrieves all resource identifiers to nuke. // Receives the resource-specific config (extracted via ConfigGetter). Lister func(ctx context.Context, client C, scope Scope, resourceCfg config.ResourceType) ([]*string, error) // Nuker deletes the resources. Use SimpleBatchDeleter, SequentialDeleter, or MultiStepDeleter. Nuker NukerFunc[C] // PermissionVerifier performs optional dry-run permission checks (nil = skip verification) PermissionVerifier func(ctx context.Context, client C, id *string) error // Client is the typed cloud service client Client C // InitializationError stores any error that occurred during InitClient InitializationError error // Scope contains Region (AWS) and/or ProjectID (GCP) Scope Scope // contains filtered or unexported fields }
Resource is the universal struct for all nukeable resources. C is the cloud service client type (e.g., *ec2.Client, *storage.Client).
This single struct contains: - Configuration: what kind of resource this is and how to interact with it - Runtime state: client, scope, discovered identifiers, nukable status
Usage: Create with struct literal, then call Init() before other methods.
func (*Resource[C]) GetAndSetIdentifiers ¶
func (r *Resource[C]) GetAndSetIdentifiers(ctx context.Context, configObj config.Config) ([]string, error)
GetAndSetIdentifiers discovers resources and stores their identifiers (implements AwsResource/GcpResource interface)
func (*Resource[C]) GetAndSetResourceConfig ¶
func (r *Resource[C]) GetAndSetResourceConfig(configObj config.Config) config.ResourceType
GetAndSetResourceConfig retrieves the resource-specific configuration (implements AwsResource/GcpResource interface)
func (*Resource[C]) Init ¶
Init initializes the resource with cloud-specific configuration. For AWS: cfg should be aws.Config For GCP: cfg should be resources.GcpConfig Must be called before GetAndSetIdentifiers or Nuke.
func (*Resource[C]) IsNukable ¶
IsNukable checks if a resource can be nuked (implements AwsResource/GcpResource interface). Returns (true, nil) if nukable, (false, error) if not. If the identifier was never verified, returns (true, nil) - assuming nukable by default.
func (*Resource[C]) MaxBatchSize ¶
MaxBatchSize returns the batch size for this resource (implements AwsResource/GcpResource interface)
func (*Resource[C]) Nuke ¶
Nuke deletes the resources with the given identifiers (implements AwsResource/GcpResource interface) Returns the results of each deletion attempt. The caller is responsible for reporting.
func (*Resource[C]) ResourceIdentifiers ¶
ResourceIdentifiers returns the currently stored identifiers (implements AwsResource/GcpResource interface)
func (*Resource[C]) ResourceName ¶
ResourceName returns the unique resource type name (implements AwsResource/GcpResource interface)
type Scope ¶
type Scope struct {
Region string // AWS region (e.g., "us-east-1") or "global" for global resources
ProjectID string // GCP project ID
}
Scope represents the cloud provider-specific scope for a resource. For AWS: Region is set (e.g., "us-east-1" or "global" for global resources) For GCP: ProjectID is set, and optionally Region for regional resources