Skip to content

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.

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.

Terminal window
export AWS_PROFILE=gomoe
export TF_DATA_DIR=~/.agents-app/terraform/gomoe
npm ci

npm ci installs the packages the deploy tools import, and the esbuild that a Terraform plan runs for the Watchtower coverage Lambda.

  1. 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.tfbackend names.
    • The gomoe.app zone, which gomoe.tfvars imports by the id in preview_parent.
    • The check fleet’s IAM role that check_fleet_role names, which ops/check-fleet/fleet.ts makes. The apply attaches policies to it.
    • A Route 53 zone for each domain in ses_recipient_domains, which is gomoe.ai in gomoe.tfvars. watchtower.tf reads 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.
  2. Initialize the root against that bucket.

    Terminal window
    cd ops/terraform/agents
    terraform init -reconfigure -backend-config=gomoe.s3.tfbackend
  3. Apply goMoE’s values.

    Terminal window
    terraform apply -var-file=gomoe.tfvars

    With 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 in redirect_hosts, agents.intrepidrhino.dev in gomoe.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/watchtower and /agents/conformance/facts.

  4. 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_nameservers names 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 output redirect_nameservers gives for it. Until both are delegated the certificate stays unvalidated and the apply keeps waiting.

  5. SNS emails a confirmation link to the alarm address. Open it, or the alarms in alarms.tf reach 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.

The host installs its packages at first boot. A deploy before that ends refuses with first boot has not finished.

  1. Return to the checkout’s root, and deploy its HEAD.

    Terminal window
    node ops/aws-deploy/deploy.ts

    It uploads a git bundle to the objects bucket, then has the host check the commit out in /srv/agents and run ops/aws-deploy/host.ts as root, over SSM. It prints the host’s full output, then <commit> is live at https://gomoe.dev once GET /v1/me has 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 outside allowed_countries gets 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 prints no earlier commit passed, so there is nothing to roll back to and exits 1.

  2. Build the computer image of the same commit.

    Terminal window
    node ops/aws-deploy/deploy.ts --image

    It 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 as latest. --no-soci leaves out the lazy-loading index.

The API applies the database migrations each time it starts, so the first deploy makes the tables.

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.

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.