@swamp/aws/ec2: auto-generated models lack list, tag, and factory-compatible update methods
Opened by stack72 · 4/7/2026· GitHub #45
Problem
The auto-generated @swamp/aws/ec2 extension models (VPC, Subnet, and presumably all 100+ other types) only ship with basic CRUD methods: create, get, update, delete, sync. This makes them unusable for the most common real-world workflow: importing and managing existing AWS infrastructure.
During import testing against a live AWS account, we hit the following gaps across every resource type we tried:
1. No list method for resource discovery
There is no way to discover existing resources within swamp. Users are forced to either:
- Fall back to the AWS CLI outside of swamp (violates the "extend, don't be clever" principle)
- Write a
listextension for every single resource type they want to import
We had to write list extensions for both @swamp/aws/ec2/vpc and @swamp/aws/ec2/subnet using CloudControl's ListResourcesCommand + GetResourceCommand. This pattern is identical for every type and should be generated automatically.
2. No tag method
Tagging is one of the most common AWS operations. The only way to add tags currently is via the update method, which has its own issues (see below). We had to extend the subnet type with a fan-out tag method that accepts multiple subnet IDs and a tag list.
3. update and sync are incompatible with factory-pattern data
The update and sync methods derive instanceName from globalArgs.name:
const instanceName = (g.name?.toString() ?? "current").replace(...)This means they can only operate on single-instance models. Once you use a list method (factory pattern) to discover resources — where each resource is stored under its own identifier (e.g., vpc-0025265f7d7b4de3c) — the built-in update and sync methods cannot target individual instances within that factory data.
4. Required globalArguments force placeholder values for discovery
For example, @swamp/aws/ec2/subnet requires VpcId in globalArguments even when you just want to list/discover subnets. We had to pass VpcId=placeholder to create the model, which is misleading.
Proposed Solution
Since all @swamp/aws/* types are auto-generated (deno task generate:aws), the fix should be in the code generator:
Add a
listmethod to every type that uses CloudControlListResourcesCommandwith pagination, thenGetResourceCommandfor each discovered resource, writing results as factory-pattern data keyed by the resource's primary identifier.Add a
tagmethod to taggable types that accepts resource IDs and tags, reads current state, merges tags, and applies a CloudControl patch. Should support fan-out (multiple resources in one execution).Make
updateandsyncfactory-aware so they can operate on individual instances within factory data, not just the single instance derived fromglobalArgs.name.Make discovery-only globalArguments optional so that required fields like
VpcIdon subnet don't force placeholder values when the model is only used for listing.
Alternatives Considered
- Writing per-type extensions manually (what we did — works but doesn't scale to 100+ types)
- Using
command/shellto wrap AWS CLI (violates swamp conventions)
Environment
- swamp version: 20260403.193957.0-sha.d27992dc
- Extension:
@swamp/aws/ec2version 2026.04.03.2 - Tested against:
@swamp/aws/ec2/vpcand@swamp/aws/ec2/subnet
Automoved by swampadmin from GitHub issue #45
Open
No activity in this phase yet.
Sign in to post a ripple.