Skip to content

feat(cloudformation): serve the stack operations over the wire (#483) - #503

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/483-cloudformation-plugin
Aug 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/483-cloudformation-plugin

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Summary

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 (types.go:264-276). README.md and docs/index.md advertise 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 existing StackDeployer. 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:

$ aws cloudformation create-stack --stack-name probe \
    --template-body '{"Resources":{"B":{"Type":"AWS::S3::Bucket",
                      "Properties":{"BucketName":"probe-e2e-bucket"}}}}'
{ "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/probe/a5e7a132-..." }

$ aws cloudformation describe-stacks --stack-name probe   # → CREATE_COMPLETE
$ aws s3api head-bucket --bucket probe-e2e-bucket         # → 200

TestCFNPlugin_StackSharesStateWithOtherPlugins is 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

Family Operations
Stacks CreateStack, UpdateStack, DeleteStack, DescribeStacks, ListStacks, GetTemplate, DescribeStackResources
Change sets CreateChangeSet, DescribeChangeSet, ExecuteChangeSet, ListChangeSets, DeleteChangeSet
Drift DetectStackDrift, DescribeStackResourceDrifts, DescribeStackDriftDetectionStatus

Deploy derives the stack name from its stream ID, so the plugin passes the caller's StackName as the stream ID — BettyClient.Deploy uses deploy-<unixnano>, which would make a wire-created stack undiscoverable by name. The comment says why.

DescribeStackEvents is refused, not answered

CFNStackState carries a single Status string, hardcoded CREATE_COMPLETE. Synthesizing a per-resource CREATE_IN_PROGRESS → CREATE_COMPLETE sequence would be inventing observations, which is the opposite of this repo's provenance discipline. It returns UnsupportedOperation/400 with a message naming the reason, is documented in docs/services.md, and is asserted deliberately so the scope decision is pinned rather than incidental. Filed as #501.

#502 covers the other deferral: StackDeployer reports failures as fmt.Errorf strings, so the adapter matches on prefixes to map AWS codes.

Tests — 30 in a new emulator/cloudformation_plugin_test.go

The test server registers S3 + IAM + CloudFormation in one registry, since a CFN-only registry could not distinguish a shared world from a private one.

  • The CloudFormation is unreachable over the wire: no cloudformation plugin is registered, so Betty's CFN support is Go-only #483 gate: the reporter's exact reproduction → 200, not ServiceNotAvailable, with a correct account in the stack ARN.
  • An unregistered service still gets 501, so the fix is not a blanket router change.
  • Every family end to end over the wire, including the change-set flow and a drift run that deletes the bucket through S3 and observes DELETED.
  • A resource that fails to deploy reports CREATE_FAILED with its reason while its sibling reports CREATE_COMPLETE.
  • DescribeStackEvents → UnsupportedOperation.
  • Stack and change-set ARNs are deterministic (sha256, not the clock) — a replay must produce the same ARN.
  • The in-process BettyClient path is untouched: betty_cfn_test.go passes unchanged, and a wire-created stack is visible to an in-process ListStacks.

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 (dispatch dereferences both), using BettyClient's synthetic stream ID, each error code and status, the missing serviceErrorProtocols entry, the Parameters.member.N walk, 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 hitting updateStack instead of getTemplate, 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 server with the real AWS CLI — every response above was parsed by the SDK, not just asserted as XML.

Closes #483

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

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.76728% with 108 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/cloudformation_plugin.go 84.77% 57 Missing and 49 partials ⚠️
emulator/plugins.go 84.61% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit ff3521a into main Aug 2, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/483-cloudformation-plugin branch August 2, 2026 21:58
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.

CloudFormation is unreachable over the wire: no cloudformation plugin is registered, so Betty's CFN support is Go-only

1 participant