Skip to content

Comments

feat: migrate 10 more AWS resources to generic Resource[C] pattern (batch 2)#985

Closed
james00012 wants to merge 1 commit intomasterfrom
feat/generic-resource-aws-batch2
Closed

feat: migrate 10 more AWS resources to generic Resource[C] pattern (batch 2)#985
james00012 wants to merge 1 commit intomasterfrom
feat/generic-resource-aws-batch2

Conversation

@james00012
Copy link
Contributor

@james00012 james00012 commented Dec 31, 2025

Summary

  • Migrates 10 more AWS resources to the generic Resource[C] pattern
  • Deletes 10 *_types.go files (consolidated into main resource files)

Resources Migrated

  1. CloudTrail
  2. CloudWatch Alarm (custom nuker that leverages SequentialDeleter and BulkDeleter)
  3. DataSync Location
  4. DataSync Task
  5. DynamoDB
  6. ECR
  7. Elastic Beanstalk
  8. GuardDuty
  9. SES Configuration Set
  10. SQS Queue

CloudWatch Alarms Special Handling

CloudWatch Alarms requires different deletion strategies for composite vs metric alarms:

  • Composite alarms: Need to clear dependencies first, then delete sequentially
  • Metric alarms: Can be bulk deleted

The custom nuker classifies alarms and delegates to:

  • resource.SequentialDeleter(deleteCompositeAlarm) for composite alarms
  • resource.BulkDeleter(deleteMetricAlarmsBulk) for metric alarms

Test plan

  • All unit tests pass (go test ./aws/resources/... ./resource/...)
  • Build succeeds (go build ./...)

@james00012 james00012 requested a review from denis256 as a code owner December 31, 2025 15:36
…atch 2)

This PR continues the migration to the generic Resource[C] pattern.

## New Resources Migrated (10)
- CloudTrail
- CloudWatch Alarm (with ClassifyAndNuke for composite/metric alarms)
- DataSync Location
- DataSync Task
- DynamoDB
- ECR
- Elastic Beanstalk
- GuardDuty
- SES Configuration Set
- SQS Queue

## New Pattern: ClassifyAndNuke
Added `ClassifyAndNuke` to batch_deleter.go for resources that need different
deletion strategies for different subtypes. It:
- Takes a classifier function that splits resources into N ordered groups
- Takes N handlers (variadic) - one per group
- Composes with existing handlers (SequentialDeleter, BulkDeleter, etc.)

Example usage (CloudWatch Alarms):
```go
Nuker: resource.ClassifyAndNuke(
    classifyCloudWatchAlarms,                         // [[composite], [metric]]
    resource.SequentialDeleter(deleteCompositeAlarm), // Group 0: prep + delete
    resource.BulkDeleter(deleteMetricAlarmsBulk),     // Group 1: bulk delete
)
```

## Files Deleted (10 *_types.go files consolidated)
- cloudtrail_types.go
- cloudwatch_alarm_types.go
- datasync_location_types.go
- datasync_task_types.go
- dynamodb_types.go
- ecr_types.go
- elastic_beanstalk_types.go
- guardduty_types.go
- ses_configuration_set_types.go
- sqs_types.go
@james00012 james00012 force-pushed the feat/generic-resource-aws-batch2 branch from b6334e2 to 4f0d0bf Compare December 31, 2025 15:41
@james00012 james00012 closed this Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant