Skip to content

Conversation

@james00012
Copy link
Contributor

@james00012 james00012 commented Jan 2, 2026

Summary

Introduces a type-safe generic Resource[C] pattern that consolidates duplicate boilerplate across all AWS resource implementations.

Key Changes

  • Generic Resource[C]: Type-safe client handling via generics with centralized reporting and error handling
  • Composable deleters: Reusable deletion patterns (SimpleBatchDeleter, SequentialDeleter, BulkDeleter, DeleteThenWait, etc.)
  • DefaultBatchSize constant: Standardized batch size (50) across all resources
  • DefaultOnly support: NewEC2AwsResource helper for EC2 resources that support default VPC filtering
  • Expanded awsDefaults: Now deletes VPC dependencies (endpoints, NAT gateways, ENIs, IGWs, subnets) before default VPCs
  • Merged types: All *_types.go files consolidated into main resource files
  • Pagination: All resources use AWS SDK v2 paginators

Impact

  • ~10,000 lines removed across 300+ files
  • 87 *_types.go files deleted
  • Improved testability with interface-based clients

Deleter Functions

Deleter Use Case
SimpleBatchDeleter Concurrent requests for APIs without strict rate limits
SequentialDeleter APIs with rate limits or ordering requirements
BulkDeleter APIs accepting multiple IDs per call
MultiStepDeleter Resources requiring cleanup before deletion
DeleteThenWait APIs where deletion is async

Testing

  • Build: ✓
  • Lint: ✓
  • Unit tests: ✓

@james00012 james00012 requested a review from denis256 as a code owner January 2, 2026 14:00
@james00012 james00012 force-pushed the feat/generic-resource-combined branch from c2a5a8e to 86903df Compare January 2, 2026 14:03
This refactoring introduces a type-safe generic resource pattern that simplifies
AWS resource implementations and reduces code duplication.

Key changes:
- Introduce Resource[C] generic type with type-safe client handling
- Add WrapAwsInitClient helper for AWS config initialization
- Add batch deleters: SimpleBatchDeleter, SequentialDeleter, BulkDeleter,
  MultiStepDeleter, DeleteThenWait
- Merge all *_types.go files into main resource files (55 files deleted)
- Remove base_resource.go, common.go, globals.go (consolidated into adapter.go)
- Update golangci-lint config for v2 compatibility
- Fix context key type for SA1029 compliance
- Add pagination support across all resources

Net reduction: ~5,500 lines of code across 280 files changed.
@james00012 james00012 force-pushed the feat/generic-resource-combined branch from 86903df to 8d5a91f Compare January 2, 2026 14:16
…C2 resources

- Add DefaultBatchSize=50 constant, standardize batch sizes across resources
- Add NewEC2AwsResource helper for EC2 resources with DefaultOnly support
- Expand awsDefaults command to delete VPC dependencies (endpoints, NAT gateways, ENIs, IGWs, subnets) before VPCs
- Update EC2Endpoint, NatGateway, InternetGateway, NetworkInterface config types to EC2ResourceType
- Remove unused nukeInternetGateway and nukeVpcEndpoint functions
- Fix tests to use DefaultBatchSize constant
@james00012 james00012 force-pushed the feat/generic-resource-combined branch from d979ea8 to 37f43a5 Compare January 2, 2026 20:15
@james00012 james00012 merged commit 37a9279 into master Jan 6, 2026
11 checks passed
@james00012 james00012 deleted the feat/generic-resource-combined branch January 6, 2026 19:39
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.

3 participants