Skip to content

Comments

feat: introduce generic Resource[C] pattern for AWS (first batch)#984

Merged
james00012 merged 3 commits intomasterfrom
feat/generic-resource-aws
Dec 31, 2025
Merged

feat: introduce generic Resource[C] pattern for AWS (first batch)#984
james00012 merged 3 commits intomasterfrom
feat/generic-resource-aws

Conversation

@james00012
Copy link
Contributor

Summary

Migrates AWS resources to use the same generic Resource[C] pattern introduced for GCP in #983.

  • Add AwsResourceAdapter[C] to wrap generic resources for AWS interface compatibility
  • Update AwsResource.Nuke() signature to accept context.Context
  • Migrate first batch of 10 simple resources to the generic pattern

Migrated Resources

Resource Old Pattern New Pattern
AccessAnalyzer &resources.AccessAnalyzer{} resources.NewAccessAnalyzer()
CloudWatchDashboards &resources.CloudWatchDashboards{} resources.NewCloudWatchDashboards()
CloudWatchLogGroups &resources.CloudWatchLogGroups{} resources.NewCloudWatchLogGroups()
EC2KeyPairs &resources.EC2KeyPairs{} resources.NewEC2KeyPairs()
EC2PlacementGroups &resources.EC2PlacementGroups{} resources.NewEC2PlacementGroups()
EventBridgeSchedule &resources.EventBridgeSchedule{} resources.NewEventBridgeSchedule()
KinesisFirehose &resources.KinesisFirehose{} resources.NewKinesisFirehose()
KinesisStreams &resources.KinesisStreams{} resources.NewKinesisStreams()
LaunchConfigs &resources.LaunchConfigs{} resources.NewLaunchConfigs()
SesEmailTemplates &resources.SesEmailTemplates{} resources.NewSesEmailTemplates()

Benefits

  • Consolidates *_types.go + *.go into single file per resource
  • Factory functions instead of struct literals
  • Context passed directly to Nuke() instead of stored in struct
  • Consistent pattern between AWS and GCP

Breaking Change

AwsResource.Nuke() signature changed from Nuke(identifiers []string) to Nuke(ctx context.Context, identifiers []string). All existing resources updated.

Test plan

  • go build ./... passes
  • Unit tests pass (go test ./aws/resources/...)
  • Migrated resources use factory functions in registry

@james00012 james00012 requested a review from denis256 as a code owner December 31, 2025 03:35
Migrates AWS resources to use the same generic Resource[C] pattern
introduced for GCP in #983. This is the first batch of 10 resources.

Changes:
- Add AwsResourceAdapter[C] to wrap generic resources for AWS interface
- Update AwsResource.Nuke() signature to accept context.Context
- Migrate 10 simple resources to generic pattern:
  - AccessAnalyzer
  - CloudWatchDashboards
  - CloudWatchLogGroups
  - EC2KeyPairs
  - EC2PlacementGroups
  - EventBridgeSchedule
  - KinesisFirehose
  - KinesisStreams
  - LaunchConfigs
  - SesEmailTemplates

Benefits:
- Consolidates _types.go + .go files into single .go file
- Uses factory functions (NewXxx()) instead of struct literals
- Context passed directly to Nuke() instead of stored in struct
- Consistent pattern between AWS and GCP resources

Remaining 111 AWS resources can be migrated incrementally.
@james00012 james00012 force-pushed the feat/generic-resource-aws branch from eac9250 to 6087800 Compare December 31, 2025 03:36
…rectness

Changes:
- Use interface types instead of concrete clients for mockability
- Add BulkDeleter helper for APIs with batch delete support
- Fix missing pagination in KinesisFirehose, LaunchConfigs, SesEmailTemplates
- Fix logging levels: errors use Errorf, deletion start uses Infof
- Add unit tests for list, filter, and delete functions
The batch_deleter already logs "[OK] Deleted X" for each item,
so individual delete functions don't need to log again.
@james00012 james00012 merged commit c7a01b5 into master Dec 31, 2025
11 checks passed
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.

2 participants