Stand up the stack
This page takes goMoE’s AWS account from a Terraform apply to gomoe.dev answering with a running API and a computer image in the registry. Meet the requirements first.
The steps follow the header of ops/terraform/agents/gomoe.tfvars and of each tool in ops/aws-deploy/. A stand-up into an empty account from these steps alone has not been recorded.
Set the shell up
Section titled “Set the shell up”Run the commands from the root of a checkout, apart from the Terraform ones, which run in ops/terraform/agents. Use a shell with Node 24 first on your PATH that holds these two settings.
export AWS_PROFILE=gomoeexport TF_DATA_DIR=~/.agents-app/terraform/gomoenpm cinpm ci installs the packages the deploy tools import, and the esbuild that a Terraform plan runs for the Watchtower coverage Lambda.
Apply the Terraform root
Section titled “Apply the Terraform root”-
Check that four things exist first. The stack doesn’t make them, so a new account needs each one made before the apply.
- The state bucket that
gomoe.s3.tfbackendnames. - The gomoe.app zone, which
gomoe.tfvarsimports by the id inpreview_parent. - The check fleet’s IAM role that
check_fleet_rolenames, whichops/check-fleet/fleet.tsmakes. The apply attaches policies to it. - A Route 53 zone for each domain in
ses_recipient_domains, which is gomoe.ai ingomoe.tfvars.watchtower.tfreads each zone (data.aws_route53_zone.ses_recipient) and writes SES’s DKIM records into it, so Watchtower can email alarms to addresses there. The plan fails when a zone is missing. Leave the list empty to skip it.
- The state bucket that
-
Initialize the root against that bucket.
Terminal window cd ops/terraform/agentsterraform init -reconfigure -backend-config=gomoe.s3.tfbackend -
Apply goMoE’s values.
Terminal window terraform apply -var-file=gomoe.tfvarsWith
own_zone = true, the apply makes the gomoe.dev zone, then waits for ACM to validate the certificate through a record in that zone. The certificate also names each host inredirect_hosts, agents.intrepidrhino.dev ingomoe.tfvars, and the apply makes a zone of its own for each and writes that host’s validation record there. ACM can read the records only once DNS points at those zones, so do step 4 while the apply waits. If the apply times out first, run it again once DNS points there.The apply makes the VPC with its NAT, the certificate and load balancer for gomoe.dev, the web ACL in front of it, RDS, EFS, the ECS cluster
agents-computers, the image registry, the server host, SES’s identity for gomoe.dev, the alarms and the budget, the Watchtower collector at watch.gomoe.dev, the four conformance hosts, the preview zone and its certificate, and the SSM parameters/agents/facts,/agents/follow,/agents/previews,/agents/watchtowerand/agents/conformance/facts. -
Point the registrar at the gomoe.dev zone’s name servers. The Route 53 console lists them under the zone, and after the apply the output
app_nameserversnames them. SES’s identity is checked through records in the same zone, so it is not ready until the registrar points there either. Then delegate each redirect host from its parent zone, an NS record for agents.intrepidrhino.dev in the intrepidrhino.dev zone, to the name servers the outputredirect_nameserversgives for it. Until both are delegated the certificate stays unvalidated and the apply keeps waiting. -
SNS emails a confirmation link to the alarm address. Open it, or the alarms in
alarms.tfreach nobody.
The Watchtower collector at watch.gomoe.dev runs a release copied to the stack’s releases bucket first. watchtower.tf’s header gives the aws s3 cp line, and watchtower_version and watchtower_sha256 in gomoe.tfvars name what was copied. Copy the release’s watchtower-agent tarball to the same folder too, which watchtower_agent_sha256 names. The computer image build and the agents-watchtower-enroll association install the agent from it.
Deploy the server
Section titled “Deploy the server”The host installs its packages at first boot. A deploy before that ends refuses with first boot has not finished.
-
Return to the checkout’s root, and deploy its
HEAD.Terminal window node ops/aws-deploy/deploy.tsIt uploads a git bundle to the objects bucket, then has the host check the commit out in
/srv/agentsand runops/aws-deploy/host.tsas root, over SSM. It prints the host’s full output, then<commit> is live at https://gomoe.devonceGET /v1/mehas answered 401 through the load balancer six times in a row, 5 seconds apart, within two minutes. A 401 is the API refusing a caller with no session, and any other answer starts the count again. The laptop runs the check, so a deploy by hand from outsideallowed_countriesgets the web ACL’s block and fails it. The first deploy has no earlier commit to roll back to, so when it fails its health check the command printsno earlier commit passed, so there is nothing to roll back toand exits 1. -
Build the computer image of the same commit.
Terminal window node ops/aws-deploy/deploy.ts --imageIt refuses unless
/agents/deployed, the last commit that passed, names that commit. The host builds the image and pushes it to the registry as the commit and aslatest.--no-socileaves out the lazy-loading index.
The API applies the database migrations each time it starts, so the first deploy makes the tables.
Put in the parameters a person keeps
Section titled “Put in the parameters a person keeps”Terraform writes facts into SSM and never a secret. Each secret below is a SecureString, put in from a private file or from standard input, never on a command line. A person puts in the GitHub, Stripe, AssemblyAI and ElevenLabs values and the follow credential. The Watchtower values are minted on the collector by the commands in watchtower.tf, which a person runs there and which write each value to SSM themselves. The next deploy writes the GitHub, Stripe, AssemblyAI and ElevenLabs values into the server’s .env, and the Watchtower app, minter and window tokens once /agents/watchtower exists. follow.ts reads the follow credential and the follow token itself, each deploy reads the deploy token to open its window, and the agents-watchtower-enroll association reads the group keys.
| Parameter | Turns on |
|---|---|
/agents/github/follow-credential |
Deploys on a merge to main, once /agents/follow exists. A token that may read the repo’s contents, or a deploy key’s private half when follow_credential_kind says deploy-key. |
/agents/github/client-id, /agents/github/client-secret, /agents/github/app-slug |
GitHub sign-in for people. See Turn on GitHub. |
/agents/stripe/test-key, /agents/stripe/webhook-secret |
Billing. See Bill teams through Stripe. |
/agents/assemblyai/key |
Speech to text. See Turn on connectors, views and speech. |
/agents/elevenlabs/key |
Agents’ voices in voice chat. See the same page. |
/agents/livekit/key, /agents/livekit/secret |
Calls, once Terraform writes /agents/calls, which no apply does yet. Each is letters and digits only, the secret at least 32 characters, and a deploy stops when /agents/calls exists and either is missing or breaks those rules. |
/agents/watchtower/app-token, /agents/watchtower/minter-token, /agents/watchtower/follow-token |
The app’s, the computers’ and the follower’s numbers in Watchtower. |
/agents/watchtower/deploy-token |
The deployment window each deploy of the server opens (ops/aws-deploy/window.ts). |
/agents/watchtower/window-token |
Computers’ keepers reading deployment windows, so they hold their daemons’ calls through a deploy. |
/agents/watchtower/group-key/hosts, /agents/watchtower/group-key/checks |
The Watchtower agent on the stack’s hosts, and on the conformance and check fleet hosts. |
/agents/watchtower/read-token |
The coverage alarm, which names running instances Watchtower doesn’t report (watchtower-coverage.tf). |
The billing page shows the way to put a SecureString in from a file.
Make the first team
Section titled “Make the first team”People make their own accounts and teams on gomoe.dev. Open https://gomoe.dev, choose Create an account, and make the team under Make a team. Making a team needs a checked email, which the account gets by opening a link the app emails. The maker of a team is its admin.
ops/aws-deploy/admin.ts also makes a team from the laptop, with an email as its admin’s login. See Add teams and people.