The three-cloud demo
One small website runs in three clouds: ECS on Fargate behind a load balancer in AWS, a Container App in Azure, and a Cloud Run service in GCP. Route 53 sits in front with one latency record per cloud, and each record is guarded by a health check on that cloud’s endpoint. All of it runs on the floci emulators in Docker, so no cloud account is involved.
The demo answers one question: turn Azure off, and where does traffic go?
npx @intentius/behold demo three-cloudThat copies example-three-cloud to ./behold-demos/three-cloud, boots floci, floci-az and floci-gcp, runs choudoufu init in the Azure estate, and serves the workspace with the local environment picked. It needs Docker, choudoufu on PATH (or CHOUDOUFU_BIN) and plunge on PATH (or PLUNGE_BIN), and pulls three emulator images, the azurerm provider and pulumi-aws the first time. On a Mac, floci-az serves the TLS certificate choudoufu’s scripts/floci-az-mac-cert.sh makes, which you run once and trust in the keychain.
What you are looking at
Section titled “What you are looking at”The estate is a chant workspace of four members on three engines, drawn as four boxes in one graph. dns and gcp are chant projects. azure is a choudoufu estate: Terraform with a live block, whose ownership is a tag on each resource. aws is a Pulumi program that plunge runs, declared in chant.workspace.json as kind pulumi.
| member | engine | what it declares |
|---|---|---|
dns |
chant | the hosted zone, three health checks, three latency CNAMEs, and an A record naming the GCP load balancer |
aws |
plunge | in aws/index.ts, through pulumi-aws: a VPC with public and private subnets in two zones, internet and NAT gateways and their routes, and the website: ECS cluster, roles, log group, task definition, security groups, the load balancer, its target group and listener, and the service. These are the resources the chant lexicon’s VpcDefault and FargateAlb declared when aws was a chant member |
azure |
choudoufu | in azure/*.tf, through hashicorp/azurerm: the resource group, a Log Analytics workspace, a VNet with a subnet for the Container Apps environment, the environment, a user-assigned identity, and the app with external ingress |
gcp |
chant | a custom VPC and a subnet for Cloud Run’s egress, and the Cloud Run service (public, running as its own service account) behind a global external Application Load Balancer: address, forwarding rule, HTTP proxy, URL map, backend service, serverless NEG |
Each cloud publishes its endpoint as an output (gcpEndpoint with chant’s output(), azureEndpoint as a Terraform output, awsEndpoint as a Pulumi stack output), and dns declares a parameter of the same name. That shared name is the edge behold draws from each record’s endpoint to the cloud that answers it. Config Connector YAML has no outputs, so chant build warns that the gcp member’s output is not written; the edge is still drawn, and the Op below reads the load balancer’s IP from the emulator and hands it to dns.
How dns reads the Azure and AWS endpoints
Section titled “How dns reads the Azure and AWS endpoints”dns reads azureEndpoint and awsEndpoint through chant (chant#4455). dns/src/records.component.ts has three components:
export const azure = memberOutputsComponent("azure");export const aws = memberOutputsComponent("aws");
export const records: Component = { name: "records", dependsOn: ["azure", "aws"], deploy: [ phase("Build", [{ kind: "shell", cmd: "npx tsx ../scripts/front-door.ts build-dns", reason: "..." }]), phase("Apply", [{ kind: "cfn-deploy", stack: "local", template: "dist/dns.json", inputs: { azureEndpoint: stackOutput("azure", "azureEndpoint"), awsEndpoint: stackOutput("aws", "awsEndpoint") } }]), ],};azure stands for the workspace member of that name. Its one step, member-outputs, reads the estate’s outputs through choudoufu and never applies it; the estate applies through its own pipeline. Because the member is kind choudoufu, the terraform lexicon is the one that reads it, so dns/chant.config.ts lists terraform beside aws. It also names the estate as its one terraform.roots entry, azure, so a change under azure/ names the azure component as a changed unit and brings dns into the change with it.
aws works the same way for the Pulumi member. The member is kind pulumi, so the pulumi lexicon reads it, and dns/chant.config.ts lists pulumi too. Its Pulumi.yaml names plunge’s backend (plunge+file://./.plunge), which is how chant knows the member runs on plunge: the applied outputs come from plunge stack output --json --show-secrets=false and the planned ones from plunge preview --json. While aws’s preview still has changes, the step refuses, so dns never applies against an awsEndpoint from before aws’s own change.
When a change to azure/ creates or replaces the Container App, its address is known only after azure applies. The pull request’s plan of dns lists azure under its unresolved inputs and azure.azureEndpoint under its unknown inputs, and the change set has a hole on azure#outputs naming the output. On merge, dns waits until azure applied, then is planned again against the address it applied as. A change that leaves azure/ alone plans dns against the address azure has now.
gcpEndpoint still reaches dns the old way: build-dns reads it from what is applied and writes it into the template as a parameter default, and points each health check at the emulator that answers for it (see below).
member-outputs and the pulumi lexicon (@intentius/chant-lexicon-pulumi) are in chant 0.124.54, the release the example depends on, so npm ci in example-three-cloud installs them. The workspace pins both lexicons by package at 0.124.58, and chant checks each pin against the installed lexicon.
Turning Azure off
Section titled “Turning Azure off”The front-door Op, in dns/ops/front-door.op.ts, rebuilds the whole picture:
- Apply gcp, azure, aws and dns to the emulators, then wait until the Azure health check reads healthy. The azure estate goes through chant’s terraform lexicon:
choudoufuPlanSet, run as an Op activity, plans it as a one-root set, andchoudoufuWaveApplyapplies exactly that set. The aws program goes through plunge:plunge upon the stacklocal, thenplunge stack exportintoaws/stack-export.json, the export chant draws the member’s graph from. dns runs itsazure,awsandrecordscomponents, so the Azure and AWS addresses it deploys are the onesmember-outputsread. - Deactivate the Azure app’s active revision, so its endpoint answers 503.
- Wait until
chant lifecycle healthreads the Azure check unhealthy. - Export the page.
Run it from the Deploy tab, or from the copy:
cd behold-demos/three-cloud/dns && npx chant run front-door# or, the same steps without chant's runner, from the workspace rootnpm run front-doorAfterwards the Azure check is unhealthy, the Azure record is dimmed and reads out of rotation: azureCheck unhealthy, and the AWS and GCP records stay in rotation. Route 53 answers with what is left. The marks are the ones Health and rotation describes.
The emulators’ checkers run inside floci’s container, where a floci-az or floci-gcp hostname resolves to nothing. The Op therefore gives each deployed health check the emulator container’s address and port, and the checkers send the endpoint as the Host header, as Route 53 does for a check with an IPAddress. The source declares the checks as they would be on AWS, without either field.
floci runs each load balancer listener on the listener’s own port in its container, so the AWS check is given port 80 rather than floci’s API port.
Drift, per engine
Section titled “Drift, per engine”Each member’s cards are coloured by its own engine’s read: chant’s live read for dns and gcp, choudoufu’s plan for azure, and plunge drift --resource <urn> --stream for each resource of aws, through chant workspace drift. An edit made outside any of them turns that card from in sync to drifted. scripts/front-door.ts oob-edit <member> makes one such edit on the emulators:
| member | the edit |
|---|---|
dns |
the hosted zone’s comment, through Route 53 |
gcp |
a label on the Cloud Run service |
azure |
a tag on the Container App, beside its ownership markers |
aws |
the log group’s retention, 7 days to 14 |
npx tsx scripts/front-door.ts oob-edit awsThen read the member’s drift from its box (the streamed read colours each card as its record arrives).
One change set over four members
Section titled “One change set over four members”npm run change-setThat plans every member without applying anything and writes one chant change-set document to .front-door/change-set.json, with a part per member in its own engine’s terms: a chant part for each of dns and gcp, from chant lifecycle plan local --json, a choudoufu part for azure, from choudoufuPlanSet, with choudoufu’s root digest as its nativeDigest, and a pulumi part for aws, from plunge preview --json read by the pulumi lexicon’s pulumiPreviewPart. One document digest covers all four, so a gate over it binds every part. Its root chant.config.json names the estate as the terraform lexicon’s azure root, which is how choudoufuPlanSet finds it.
To apply exactly that set:
npx tsx scripts/front-door.ts apply --change-set .front-door/change-set.jsonIt plans the four members again first. When the fresh document’s digest is the approved one, it applies. When any part’s plan moved, whichever engine planned it, the whole set is refused before anything applies: .front-door/apply-verdict.json says refused and names each part that moved with chant’s reason, and the command exits 3, chant’s code for a moved plan.
The exported page
Section titled “The exported page”The Op’s last step is a static export into export/:
behold export . --open-env local --open-zoom logical \ --note "Azure was switched off: its app answers 503, Route 53's check on it fails, and AWS and GCP take the traffic. Run this yourself: \`npx @intentius/behold demo three-cloud\`" --out exportIt opens on the local environment at the logical zoom, which draws each record, the service it fronts and whether it is in rotation, and ends with the line that brings a reader back here. To rebuild the page from nothing, boot the emulators and run the Op:
npm run emulators && npm run front-doorCleaning up
Section titled “Cleaning up”Stopping behold demo stops the three emulators. floci-gcp leaves the Cloud Run container it started behind; docker ps -a --filter name=floci-gcp-cloudrun lists it.