Deploy with an AI agent
This page is a runbook for a coding agent, such as Claude Code, Codex or Cursor, that can run the AWS CLI in your account. It covers the same launch as the rest of this guide, with every step as a command and a check. The agent does the AWS work. You do the steps that need your consent or your credentials: subscribing, signing in, and entering keys and passwords.
Give your agent this prompt:
Deploy Mitzu from AWS Marketplace into my AWS account by following
https://docs.mitzu.io/aws-marketplace/deploy-with-an-agent.md
Use the AWS CLI with my current credentials. Ask me before anything the page marks
as needing a person, and before you create or delete anything.
The .md address serves the page as plain Markdown. Every page of these docs except the REST API reference
is available that way (the home page at /index.md), and llms.txt lists them all.
Rules for the agent
- A person subscribes, signs in and handles secrets. Never accept a Marketplace offer, sign in to Mitzu, or read, type or store a password, API key or client secret. Ask the person to do it, and say exactly where.
- Ask before you create or delete. Show the person what a command will create or delete, and what it costs, and wait for a yes. Read-only commands need no confirmation.
- Use one region. Pass
--region "$REGION"on every command. The certificate, the licence check and the stack must all be in that region. - Launch from the template URL. The template is larger than the 51,200 bytes CloudFormation accepts
inline, so use
--template-url, never--template-body. - Leave
DbDeletionProtectionon. Set it tofalseonly for a teardown the person asked for, or for a diagnostic launch (see If the launch fails). - Delete only what this runbook names. Never delete a resource you can't tie to this stack's name.
- Stop on surprises. If a command's output doesn't match the check below it, stop, quote the output to the person and ask how to continue.
- Stay in the session while AWS works. The certificate and the stack each take up to an hour. Run
every
aws ... waitcommand in the foreground, with a command timeout of at least 10 minutes, and run it again if your timeout cuts it off. Don't end your turn while a wait is still pending: nothing will remind you to come back when it finishes.
Step 1: Collect the inputs
Shell variables don't survive between separate tool calls in most agents, so keep the inputs in a file and source it before each command:
cat > mitzu-deploy.env <<'EOF'
export REGION=us-east-1
export STACK=mitzu
export DOMAIN=mitzu.example.com
export ADMIN_EMAIL=admin@example.com
export ORG_NAME="Example Inc"
export ALLOWED_CIDR=0.0.0.0/0
export ALARM_EMAIL=
export HOSTED_ZONE_ID=
export CERT_ARN=
export TEMPLATE_URL=
export IMAGE_URI=
export AWS_PROFILE=
EOF
| Variable | Where it comes from |
|---|---|
REGION | Ask the person. Any region with ECS Fargate, RDS for PostgreSQL 17, ElastiCache and Cognito. |
STACK | mitzu unless the person wants another name. It also names the ECS cluster and the log group. |
DOMAIN | Ask the person: the host name people will open. |
ADMIN_EMAIL | Ask the person: the first admin, who gets the invitation email. |
ORG_NAME | Ask the person: the organisation's name in Mitzu. |
ALLOWED_CIDR | Ask the person. 0.0.0.0/0 lets anyone reach the sign-in page. A company range keeps Mitzu internal, but then claude.ai and Claude Desktop can't reach the MCP server. |
ALARM_EMAIL | Optional. Ask the person: receives the stack's alarms. |
HOSTED_ZONE_ID | Step 4. |
CERT_ARN | Step 5. |
TEMPLATE_URL, IMAGE_URI | Step 3. |
AWS_PROFILE | Only if the person's credentials are a named profile: its name. Otherwise delete the line. |
Write this helper too. Stack updates use it to keep every current value except the ones you change. Its arguments are the stack's parameter names, the template's parameter names, and the changes:
cat > mitzu-params.py <<'EOF'
import json
import sys
stack_keys = set(json.load(open(sys.argv[1])))
template_keys = json.load(open(sys.argv[2]))
changes = dict(arg.split("=", 1) for arg in sys.argv[3:])
params = []
for key in template_keys:
if key in changes:
params.append({"ParameterKey": key, "ParameterValue": changes.pop(key)})
elif key in stack_keys:
params.append({"ParameterKey": key, "UsePreviousValue": True})
if changes:
sys.exit(f"not in the template: {', '.join(changes)}")
print(json.dumps(params, indent=2))
EOF
Then check the tools and the account:
source mitzu-deploy.env
aws --version
aws sts get-caller-identity --region "$REGION"
Check: AWS CLI version 2, and an identity in the account the person means. Tell the person which account ID you'll use. Creating the stack needs permission for CloudFormation, IAM roles, VPC, ECS, RDS, ElastiCache, EFS, Elastic Load Balancing, Cognito, Lambda, Secrets Manager, CloudWatch, SNS and, with a hosted zone, Route 53. An administrator role covers it.
Step 2: Subscription (a person)
Ask the person to subscribe from this same account, as in Launch → Subscribe: open
the Mitzu listing in AWS Marketplace, choose View purchase options, enter 1 for Mitzu platform plus
any Additional seat units, and choose Subscribe. Accepting the offer is a purchase, so the person
does it.
Then check that the licence reached this account and region:
source mitzu-deploy.env
aws license-manager list-received-licenses --region "$REGION" \
--query "Licenses[?contains(ProductName, 'Mitzu')].{Product: ProductName, Sku: ProductSKU, Status: Status, Ends: Validity.End, Entitlements: Entitlements[].[Name, MaxCount]}"
Check: a licence with Status AVAILABLE and a platform entitlement of 1 (a private offer may
instead have platform_custom, with one unit per seat). Without it, the stack's
setup task fails and the launch rolls back. A licence can take a few minutes to appear after subscribing.
The image checks only the licence whose Sku is its own product's ID, so if more than one Mitzu licence
shows up, ask the person which listing they subscribed to; the others don't matter.
Step 3: Template and image (a person, then the agent)
Ask the person to choose Launch your software on the subscription, choose ECS, pick the version
(the newest is already selected), and paste you the link under Follow the vendor's instructions that
starts with https://console.aws.amazon.com/cloudformation. It holds the template URL and the exact
image. Read both from it:
python3 - "<the link>" <<'EOF'
import sys
from urllib.parse import parse_qs
query = parse_qs(sys.argv[1].rsplit("?", 1)[1])
print("TEMPLATE_URL=" + query["templateURL"][0])
print("IMAGE_URI=" + query["param_ImageUri"][0])
EOF
Put both values in mitzu-deploy.env, then validate the template:
source mitzu-deploy.env
aws cloudformation validate-template --region "$REGION" --template-url "$TEMPLATE_URL" \
--query "{Capabilities: Capabilities, Parameters: Parameters[].ParameterKey}"
Check: IMAGE_URI ends in @sha256: and a digest, and Capabilities is CAPABILITY_IAM. The image is
built for ARM64 only; leave CpuArchitecture at its default.
Step 4: Preflight checks
All of these are read-only.
source mitzu-deploy.env
aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].StackStatus" --output text
aws logs describe-log-groups --region "$REGION" --log-group-name-prefix "/mitzu/$STACK" \
--query "logGroups[].logGroupName" --output text
aws service-quotas get-service-quota --region "$REGION" --service-code vpc --quota-code L-F678F1CE \
--query Quota.Value
aws ec2 describe-vpcs --region "$REGION" --query "length(Vpcs)"
aws service-quotas get-service-quota --region "$REGION" --service-code ec2 --quota-code L-0263D0A3 \
--query Quota.Value
aws ec2 describe-addresses --region "$REGION" --query "length(Addresses)"
aws route53 list-hosted-zones \
--query "HostedZones[?Config.PrivateZone == \`false\`].[Id, Name]" --output text
Check:
describe-stacksfails withStack with id ... does not exist. If the stack exists, ask the person whether to pick another name or to tear the old one down.- The log groups don't include exactly
/mitzu/$STACK. If it's there, an earlier stack with this name left it behind. Ask the person, then delete it withaws logs delete-log-group --region "$REGION" --log-group-name "/mitzu/$STACK", or the launch fails. - The VPC count is below its quota, and the Elastic IP count is below its quota. The stack needs one of each.
- Hosted zones: pick the zone named
DOMAINitself, or else the longest suffix ofDOMAIN(example.com.formitzu.example.com). SetHOSTED_ZONE_IDto its ID without the/hostedzone/prefix; the stack then creates the DNS record. With no such zone, leave it empty: a person creates a CNAME after the launch.
Step 5: Certificate
Reuse an issued certificate that covers DOMAIN, if there is one:
source mitzu-deploy.env
aws acm list-certificates --region "$REGION" --certificate-statuses ISSUED \
--query "CertificateSummaryList[].[DomainName, CertificateArn]" --output text
A certificate for DOMAIN itself, or for *. and its parent domain, covers it. An issued certificate that
nothing uses yet shows renewal as INELIGIBLE; that's normal, and it becomes eligible once the stack uses
it. Otherwise, after the person
agrees, request one:
source mitzu-deploy.env
aws acm request-certificate --region "$REGION" --domain-name "$DOMAIN" --validation-method DNS \
--query CertificateArn --output text
Put the ARN in CERT_ARN, wait a few seconds, then read the validation record:
source mitzu-deploy.env
aws acm describe-certificate --region "$REGION" --certificate-arn "$CERT_ARN" \
--query "Certificate.DomainValidationOptions[0].ResourceRecord"
-
With a hosted zone: create the record yourself:
aws route53 change-resource-record-sets --hosted-zone-id "$HOSTED_ZONE_ID" --change-batch '{
"Changes": [{"Action": "UPSERT", "ResourceRecordSet": {
"Name": "<Name>", "Type": "CNAME", "TTL": 300,
"ResourceRecords": [{"Value": "<Value>"}]}}]}' -
Without one: give the person the record's name and value to create as a CNAME with their DNS provider.
Then wait for it. The waiter gives up after 40 minutes:
source mitzu-deploy.env
aws acm wait certificate-validated --region "$REGION" --certificate-arn "$CERT_ARN"
Step 6: Launch
Write the parameters to a file, so values with spaces or commas survive:
source mitzu-deploy.env
python3 - > create-params.json <<'EOF'
import json
import os
names = {
"ImageUri": "IMAGE_URI",
"DomainName": "DOMAIN",
"CertificateArn": "CERT_ARN",
"HostedZoneId": "HOSTED_ZONE_ID",
"OrgName": "ORG_NAME",
"AdminEmail": "ADMIN_EMAIL",
"AllowedIngressCidr": "ALLOWED_CIDR",
"AlarmEmail": "ALARM_EMAIL",
}
params = [
{"ParameterKey": key, "ParameterValue": os.environ[env]}
for key, env in names.items()
if os.environ.get(env)
]
print(json.dumps(params, indent=2))
EOF
cat create-params.json
The other parameters keep their defaults; Launch → Parameters describes them all.
Show the person this file and what the stack costs: roughly 230 USD a month at the default sizes in us-east-1, plus data transfer, plus the Mitzu subscription. Launch only after a clear yes. Then create the stack and wait in the foreground (rule 8). It takes about 15 minutes, and the waiter gives up after an hour:
source mitzu-deploy.env
aws cloudformation create-stack --region "$REGION" --stack-name "$STACK" \
--template-url "$TEMPLATE_URL" --capabilities CAPABILITY_IAM \
--parameters file://create-params.json
aws cloudformation wait stack-create-complete --region "$REGION" --stack-name "$STACK"
ADMIN_EMAIL gets its invitation within a minute, but its link doesn't work until the stack is complete.
Tell the person not to use it yet.
Check: the waiter returns without an error. If it fails, go to If the launch fails.
Step 7: DNS without a hosted zone (a person)
Skip this with HOSTED_ZONE_ID set. Otherwise read the load balancer's name and ask the person to create a
CNAME from DOMAIN to it:
source mitzu-deploy.env
aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].Outputs[?OutputKey == 'LoadBalancerDnsName'].OutputValue" --output text
Step 8: Check the deployment
source mitzu-deploy.env
aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].Outputs[].[OutputKey, OutputValue]" --output table
aws ecs describe-services --region "$REGION" --cluster "$STACK" \
--services web mcp scheduler indexing generic \
--query "services[].[serviceName, runningCount, desiredCount]" --output table
curl -s -o /dev/null -w "%{http_code}\n" "https://$DOMAIN/ping"
curl -s "https://$DOMAIN/.well-known/oauth-protected-resource/mcp"
curl -s -o /dev/null -w "%{http_code}\n" -X POST "https://$DOMAIN/mcp"
aws logs filter-log-events --region "$REGION" --log-group-name "/mitzu/$STACK" \
--filter-pattern '{ $.level = "ERROR" }' --query "events[].message" --output text
Check:
- All five services run 1 of 1.
/pinganswers200. DNS can take a few minutes after a new CNAME.- The MCP metadata is JSON whose
authorization_serversishttps://<DOMAIN>/, andPOST /mcpwithout a token answers401. - There are no
ERRORlog lines, apart from one known one:Failed to fetch usage data from PostgreSQLwithrelation "tracking_events" does not exist. A scheduled job writes it every few hours. It's harmless; the appliance doesn't record usage events, so the job has nothing to read. Quote any otherERRORline to the person.
Step 9: Hand over to the person
Tell the person:
- The address, from the
Urloutput, and that the invitation toADMIN_EMAILcomes fromno-reply@verificationemail.comwith the subject You're invited to Mitzu, possibly in spam. - To sign in from that email and set their own password: First sign-in.
- The
EgressIpoutput, to allow on their data warehouse: Connect your warehouse. - The steps that happen in Mitzu, by a person: connect the warehouse, turn on AI, invite the team and connect SSO, and connect MCP clients.
If the email is lost or the temporary password has expired after 7 days, send a new one:
source mitzu-deploy.env
USER_POOL_ID=$(aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].Outputs[?OutputKey == 'UserPoolId'].OutputValue" --output text)
aws cognito-idp admin-create-user --region "$REGION" --user-pool-id "$USER_POOL_ID" \
--username "$ADMIN_EMAIL" --message-action RESEND
Change stack parameters
To change a parameter, for example AlarmEmail, the SES invite sender or the SMTP settings, update the stack
and keep every other value with the helper from step 1. The template stays the same, so its parameter names
are the stack's:
source mitzu-deploy.env
aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].Parameters[].ParameterKey" > stack-keys.json
python3 mitzu-params.py stack-keys.json stack-keys.json AlarmEmail=ops@example.com > update-params.json
cat update-params.json
aws cloudformation update-stack --region "$REGION" --stack-name "$STACK" --use-previous-template \
--capabilities CAPABILITY_IAM --parameters file://update-params.json
aws cloudformation wait stack-update-complete --region "$REGION" --stack-name "$STACK"
The parameters are described under Launch → Parameters, and the SES and SMTP set-up under Invite emails and Operate → Email.
Secrets
The stack-wide Anthropic key and the SMTP password live in Secrets Manager, in the secrets named by the
AnthropicApiKeySecretArn and SmtpPasswordSecretArn outputs. A person stores the value, in the console or
with aws secretsmanager put-secret-value in their own terminal, as {"api_key":"..."} or
{"password":"..."}. Keep it out of your context. Then restart the services so they read it:
source mitzu-deploy.env
for service in web mcp scheduler indexing generic; do
aws ecs update-service --region "$REGION" --cluster "$STACK" --service "$service" \
--force-new-deployment --query "service.serviceName" --output text
done
aws ecs wait services-stable --region "$REGION" --cluster "$STACK" \
--services web mcp scheduler indexing generic
Most organisations enter their AI key in Mitzu instead, which needs no restart: see AI and MCP.
Upgrade
Ask the person for the new version's link, the same way as in step 3 but with the new Version picked, and
read TEMPLATE_URL and IMAGE_URI from it. Validate the new template, then update the stack with the new
template and image, keeping every other value:
source mitzu-deploy.env
aws cloudformation validate-template --region "$REGION" --template-url "$TEMPLATE_URL" \
--query "Parameters[].ParameterKey" > template-keys.json
aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].Parameters[].ParameterKey" > stack-keys.json
python3 mitzu-params.py stack-keys.json template-keys.json "ImageUri=$IMAGE_URI" > update-params.json
cat update-params.json
aws cloudformation update-stack --region "$REGION" --stack-name "$STACK" \
--template-url "$TEMPLATE_URL" --capabilities CAPABILITY_IAM \
--parameters file://update-params.json
aws cloudformation wait stack-update-complete --region "$REGION" --stack-name "$STACK"
A parameter that's new in this version takes its default. The update migrates the database first, then replaces the
services one at a time, so Mitzu stays available. If the migration fails, CloudFormation rolls back to the
previous version, and the stack ends in UPDATE_ROLLBACK_COMPLETE. Then run the checks in step 8.
If the launch fails
The stack rolls back and ends in ROLLBACK_COMPLETE. Find the first failure; later ones only say their
creation was cancelled:
source mitzu-deploy.env
aws cloudformation describe-stack-events --region "$REGION" --stack-name "$STACK" \
--query "reverse(StackEvents[?ResourceStatus == 'CREATE_FAILED'])[0].[LogicalResourceId, ResourceStatusReason]" \
--output text
| Failed resource | Reason | Fix |
|---|---|---|
LogGroup | /mitzu/<stack name> already exists | Delete that log group. See step 4. |
InitRun | The init task exited with an error | Usually the licence: repeat the check in step 2 in the stack's region. |
HttpsListener | The certificate can't be found or used | It must be ISSUED, in REGION. |
| Anything else | Quote the reason to the person. |
Then, after the person agrees, delete the rolled-back stack. Its name stays taken until you do:
source mitzu-deploy.env
aws cloudformation delete-stack --region "$REGION" --stack-name "$STACK"
aws cloudformation wait stack-delete-complete --region "$REGION" --stack-name "$STACK"
Run the leftover checks, then launch again from step 6.
If the stack ends in ROLLBACK_FAILED because the database has deletion protection, turn it off on that
database and delete the stack:
source mitzu-deploy.env
DB_ID=$(aws cloudformation describe-stack-resource --region "$REGION" --stack-name "$STACK" \
--logical-resource-id Database --query "StackResourceDetail.PhysicalResourceId" --output text)
aws rds modify-db-instance --region "$REGION" --db-instance-identifier "$DB_ID" \
--no-deletion-protection --apply-immediately
Diagnostic launch
The init task logs to /mitzu/$STACK, which the rollback deletes. If the InitRun reason isn't enough,
launch again with rollback turned off and deletion protection off, so the logs stay and the stack can be
deleted afterwards. Ask the person first: the stack bills until it's deleted.
source mitzu-deploy.env
python3 - create-params.json > diagnostic-params.json <<'EOF'
import json
import sys
params = [p for p in json.load(open(sys.argv[1])) if p["ParameterKey"] != "DbDeletionProtection"]
params.append({"ParameterKey": "DbDeletionProtection", "ParameterValue": "false"})
print(json.dumps(params, indent=2))
EOF
aws cloudformation create-stack --region "$REGION" --stack-name "$STACK" \
--template-url "$TEMPLATE_URL" --capabilities CAPABILITY_IAM \
--parameters file://diagnostic-params.json --disable-rollback
aws cloudformation wait stack-create-complete --region "$REGION" --stack-name "$STACK"
aws logs tail "/mitzu/$STACK" --region "$REGION" --since 1h
The waiter fails when the stack reaches CREATE_FAILED; then read the log. Quote the error to the person,
or send it to support@mitzu.io with the region and IMAGE_URI. Then delete the stack as above and run the
leftover checks.
Teardown
Only when the person asks for it. Tell them first that it deletes Mitzu's own database (workspaces, dashboards, users and saved settings) except for a final snapshot, and wait for a yes. Their warehouse data isn't touched.
source mitzu-deploy.env
aws cloudformation describe-stacks --region "$REGION" --stack-name "$STACK" \
--query "Stacks[0].Parameters[].ParameterKey" > stack-keys.json
python3 mitzu-params.py stack-keys.json stack-keys.json DbDeletionProtection=false > update-params.json
aws cloudformation update-stack --region "$REGION" --stack-name "$STACK" --use-previous-template \
--capabilities CAPABILITY_IAM --parameters file://update-params.json
aws cloudformation wait stack-update-complete --region "$REGION" --stack-name "$STACK"
aws cloudformation delete-stack --region "$REGION" --stack-name "$STACK"
aws cloudformation wait stack-delete-complete --region "$REGION" --stack-name "$STACK"
If DbDeletionProtection is already false, update-stack answers No updates are to be performed; go on
to delete-stack.
Leftovers
After a teardown or a failed launch, look for what the stack can leave behind:
source mitzu-deploy.env
STACK_LC=$(echo "$STACK" | tr '[:upper:]' '[:lower:]')
aws rds describe-db-snapshots --region "$REGION" --snapshot-type manual \
--query "DBSnapshots[?starts_with(DBSnapshotIdentifier, '$STACK_LC-snapshot-')].[DBSnapshotIdentifier, SnapshotCreateTime]" \
--output text
aws logs describe-log-groups --region "$REGION" --log-group-name-prefix "/mitzu/$STACK" \
--query "logGroups[].logGroupName" --output text
aws logs describe-log-groups --region "$REGION" \
--log-group-name-prefix "/aws/ecs/containerinsights/$STACK/" \
--query "logGroups[].logGroupName" --output text
- The final snapshot (
<stack>-snapshot-database-…, with the stack name in lowercase, as RDS stores it) is the only copy of Mitzu's database after a teardown. Delete it withaws rds delete-db-snapshotonly when the person says so. /mitzu/$STACKcan be recreated by a last log line after the stack deletes it. Delete it, or a new stack under the same name fails to launch.- The Container Insights log group keeps data for one day and costs nothing. Delete it for a clean account.
Delete log groups with aws logs delete-log-group --region "$REGION" --log-group-name <name>. What you or the
person created outside the stack stays: the certificate and its validation record, a DNS record made by
hand, an SES identity, and the Marketplace subscription, which the person cancels in AWS Marketplace.
If you also search by tag (aws resourcegroupstaggingapi get-resources), expect it to list the stack's ECS
cluster, NAT gateway and Cognito user pool for a while after they're gone. The tag index lags behind
deletions, so check each hit with its own describe command before calling it a leftover.