fix(codegen/aws): write custom-method output to dedicated resources (swamp-club #1735) #462
Loading…
Reference in a new issue
No description provided.
Delete branch "1735"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes swamp-club #1735.
Problem
AWS enrichment custom methods wrote their results into the CloudControl
stateresource (lifetime: infinite,StateSchema) under an instance name built from every argument value. Bedrockknowledge-base.retrievetherefore stored every query as a new, never-expiringstateinstance named after the query text (e.g.retrieve-KB123-What is Bedrock?), in a resource whose schema requiresKnowledgeBaseId.garbageCollectioncaps versions per name, so it never bounded anything.Fix (codegen)
Each custom method now declares an
outputresource in its enrichment config: schema (<Name>OutputSchemaexported frommethods.ts), lifetime, garbageCollection, and a stable instance key ({ arg }for single results,{ itemFields }for arrays). The generator emits those resources and fails generation if a method targetsstate, a schema name breaks the convention or collides with a generated schema, the key kind does not match the return shape, or two methods declare the same resource differently.@swamp/aws/bedrock/knowledge-baseretrievestate/retrieve-<all args>(infinite)retrieval/<knowledgeBaseId>(7d); query now in the payload@swamp/aws/events/event-busput_eventsstate/put_events-[object Object]putEventsResult/<bus Name>(7d)@swamp/aws/cloudformation/stack-setlistInstancesstate/<index>stackInstance/<Account>-<Region>(30d)listOperations,describeOperationstate/<index>,state/describeOperation-<args>operation/<OperationId>(30d)detectDriftstate/detectDrift-<args>driftDetection/<StackSetName>(30d)Consumer-visible change
statemust switch to the resource names above.stateby these methods is not migrated. To remove it, delete thestateinstances namedretrieve-*,put_events-*,describeOperation-*,detectDrift-*and numeric (0,1, ...) instances on stack-set models withswamp data— the CloudControlget/syncinstance is unaffected.retrievekeeps only the latest query as the latest version ofretrieval/<kbId>; earlier queries survive as the last 10 versions for 7 days (documented incodegen/designs/aws.md).Adjacent codegen fixes (found while regenerating)
generate:aws eventssubstring-matched type names, pullingAWS::RDS::EventSubscription,AWS::Lambda::EventSourceMapping, etc. into a partial regeneration that deleted every other model in rds, lambda, redshift, dms, neptune, docdb, customerprofiles and servicecatalog. The filter now matches the service segment exactly (matchesServiceFilter, with tests). Reproduced on clean main._libchange check compared unformatted output to the formatted on-disk file, solibChangedwas always true. It now formats before comparing, like the README. Reproduced on clean main (bedrock.1 → .2 → .3with zero model changes).Verification
generate:aws bedrock cloudformation eventschanges exactly those three models + manifests; a fullgenerate:awschanges nothing else (three new upstream types from schema drift were left for the nightly job); second runs produce zero diff.retrieval/KB123(7d, v1–v3 across three queries/pages),putEventsResult/orders-bus,stackInstance/111111111111-us-east-1andeu-west-1(missing Account),operation/op-1v2,driftDetection/my-ss, and zerostateinstances.4afe8efa-8728-4ad2-aee3-6dca00034a0efor0970a624a.Known trade-off flagged by review:
listOperationsafterdescribeOperationmakes the summary the latest version ofoperation/<id>(details remain in prior versions).🤖 Generated with Claude Code