Repository navigation
feat(cloudformation): serve the stack operations over the wire (#483) - #503
Merged
Merged
Conversation
CloudFormation was fully modelled in process — StackDeployer exports 13 methods and 113 resource types deploy through the plugin registry — but no plugin served the `cloudformation` service, so every wire caller got ServiceNotAvailable/501. README.md and docs/index.md advertise CloudFormation as a first-class target, which made this read as a bug from outside rather than a boundary. Register a CloudFormationPlugin: a deliberately thin Query-protocol adapter that translates params in and XML out over the existing StackDeployer. No CFN logic moves into the plugin. Because the deployer is constructed over the same registry and state the server already holds, a stack created over the wire creates real resources in the other plugins — a template's bucket is reachable through S3, its role through IAM. DescribeStackEvents is refused with UnsupportedOperation rather than answered. CFNStackState carries a single Status string, so a per-resource CREATE_IN_PROGRESS → CREATE_COMPLETE sequence would be invented observations. A consumer polling events gets a clear signal instead of a fabricated one (#501). The adapter maps StackDeployer's fmt.Errorf strings onto AWS codes at the boundary; typed errors in betty_cfn.go would be better (#502). Closes #483
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CloudFormation was fully modelled in process —
StackDeployerexports 13 methods and 113 resource types deploy through the plugin registry — but no plugin served thecloudformationservice, so every wire caller gotServiceNotAvailable/501 (types.go:264-276).README.mdanddocs/index.mdadvertise CloudFormation as a first-class target, which is what made this read as a bug from outside rather than a boundary.This registers a
CloudFormationPlugin: a deliberately thin Query-protocol adapter over the existingStackDeployer. No CFN logic moves into the plugin — every handler translates params in and XML out.The reporter offered two resolutions and would have accepted either (register the plugin, or document CloudFormation as out of scope over the wire). Decision: register the plugin, because the modelling was already done and option 2 meant visibly walking back an advertised capability.
Stacks share state with every other plugin
The deployer is constructed over the same registry and state the server already holds, so a wire-created stack creates real resources elsewhere in the emulator rather than in a private world:
TestCFNPlugin_StackSharesStateWithOtherPluginsis the assertion that pins this: a template creating a bucket and a role, then reached through the S3 and IAM plugins over the wire.Operations
CreateStack,UpdateStack,DeleteStack,DescribeStacks,ListStacks,GetTemplate,DescribeStackResourcesCreateChangeSet,DescribeChangeSet,ExecuteChangeSet,ListChangeSets,DeleteChangeSetDetectStackDrift,DescribeStackResourceDrifts,DescribeStackDriftDetectionStatusDeployderives the stack name from its stream ID, so the plugin passes the caller'sStackNameas the stream ID —BettyClient.Deployusesdeploy-<unixnano>, which would make a wire-created stack undiscoverable by name. The comment says why.DescribeStackEvents is refused, not answered
CFNStackStatecarries a singleStatusstring, hardcodedCREATE_COMPLETE. Synthesizing a per-resourceCREATE_IN_PROGRESS → CREATE_COMPLETEsequence would be inventing observations, which is the opposite of this repo's provenance discipline. It returnsUnsupportedOperation/400 with a message naming the reason, is documented indocs/services.md, and is asserted deliberately so the scope decision is pinned rather than incidental. Filed as #501.#502 covers the other deferral:
StackDeployerreports failures asfmt.Errorfstrings, so the adapter matches on prefixes to map AWS codes.Tests — 30 in a new
emulator/cloudformation_plugin_test.goThe test server registers S3 + IAM + CloudFormation in one registry, since a CFN-only registry could not distinguish a shared world from a private one.
ServiceNotAvailable, with a correct account in the stack ARN.DELETED.CREATE_FAILEDwith its reason while its sibling reportsCREATE_COMPLETE.DescribeStackEvents→UnsupportedOperation.BettyClientpath is untouched:betty_cfn_test.gopasses unchanged, and a wire-created stack is visible to an in-processListStacks.Verification
gofmt -l .,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),make test(race),make docs-reference docs-reference-check docs-versions(64 → 65 plugins),npm --prefix docs run build,go test -C test/e2e ./...— all pass from the repo root.Mutation-tested 32/32. Mutations covered not registering the plugin, registering under an unroutable name, handing the deployer a fresh registry or its own state (the shared-state property), forwarding a nil event store or cost controller (
dispatchdereferences both), using BettyClient's synthetic stream ID, each error code and status, the missingserviceErrorProtocolsentry, theParameters.member.Nwalk, clock-derived ARNs, both status filters, and reporting a failed resource as complete. Three mutations initially reported a wrong result for harness reasons (a non-unique anchor hittingupdateStackinstead ofgetTemplate, an anchor that did not match post-gofmt text, and a mutant that did not compile) and were re-authored before being trusted.End-to-end verified against a running
substrate serverwith the real AWS CLI — every response above was parsed by the SDK, not just asserted as XML.Closes #483