Skip to main content
← Back to list
01Issue
FeatureOpenExtensions

@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 list extension 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:

  1. Add a list method to every type that uses CloudControl ListResourcesCommand with pagination, then GetResourceCommand for each discovered resource, writing results as factory-pattern data keyed by the resource's primary identifier.

  2. Add a tag method 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).

  3. Make update and sync factory-aware so they can operate on individual instances within factory data, not just the single instance derived from globalArgs.name.

  4. Make discovery-only globalArguments optional so that required fields like VpcId on 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/shell to wrap AWS CLI (violates swamp conventions)

Environment

  • swamp version: 20260403.193957.0-sha.d27992dc
  • Extension: @swamp/aws/ec2 version 2026.04.03.2
  • Tested against: @swamp/aws/ec2/vpc and @swamp/aws/ec2/subnet

Automoved by swampadmin from GitHub issue #45

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

4/7/2026, 11:29:07 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.