Manual setup steps
Most of the platform is code. A few steps can’t be: they live in Google consoles or need a super-admin, whose credentials the access policy keeps out of automation. This doc records each one, so setting up a fresh environment doesn’t rely on memory.
Legend: [ ] = to do for a new setup, [x] = done for the current production setup.
1. Project and organization (super-admin)
Done as a Workspace super-admin (master@cyccommunitysailing.org). Reserved to super-admins per
the access policy — not day-to-day deploy identities.
- GCP project
cyc-admin-scriptscreated under the org. - Org policy / project-root IAM as needed.
- Any Google API that must be enabled by hand (most are enabled in code via the
enableServicehelper; enable by hand only if a chicken-and-egg case appears).
2. Deployer identity and access
Done as a Workspace super-admin, granting a human, not code, since these are IAM-policy grants on the org’s and project’s break-glass access.
-
roles/resourcemanager.organizationAdminon the org, so the deployer can manage IAM without super-admin credentials. -
roles/owneron projectcyc-admin-scripts, sopulumi upworks.
gcloud organizations add-iam-policy-binding <ORG_ID> --member="user:<deployer-email>" --role="roles/resourcemanager.organizationAdmin" --condition=NoneGoogle refuses roles/owner for an external principal over the API. Grant it in the
IAM console instead:
add the principal, role Basic → Owner, then have them accept the emailed invitation.
Then add the deployer to bootstrap:humanDeployers in stacks/bootstrap/Pulumi.prod.yaml, and
apply bootstrap. That grants the Pulumi state buckets and keys.
3. Who merges and approves prod deploys
bootstrap creates two teams empty, and their members are added by hand (#212, #280):
maintainersmerge tomainand approve prod deploys. With no member, nothing merges and no deploy is approved.contributorspush branches and open PRs, but can’t merge. Other org members only read.
gh api -X PUT orgs/cyc-seattle/teams/<maintainers or contributors>/memberships/<github-login> -f role=member- The current maintainer is a member of
maintainers.
4. The Workspace SMTP relay admits the cluster
Prod’s pods send mail through smtp-relay.gmail.com:587, which admits senders by IP. The cluster’s
Cloud NAT sends from one static address, the infra stack’s natAddress output. As a Workspace
super-admin, add it in the Admin console under Apps → Google Workspace → Gmail → Routing → SMTP
relay service, to the allowed IP addresses of the relay’s rule:
pulumi stack output natAddress --cwd stacks/infra --stack prod- The relay admits
natAddress.
5. Secret values (Secret Manager)
Pods read their secrets from Kubernetes Secrets that the deploy writes. Secret Manager holds the external credentials, set by hand: Pulumi declares only the container, and the value is added out of band and never committed:
printf %s 'THE_VALUE' | gcloud secrets versions add SECRET_ID --data-file=- --project cyc-admin-scriptsThe rest, marked below, are internal keys with no meaningful human choice. Pulumi generates them as
random resources. Prod’s also keep the Secret Manager copies they had on the VM
(stacks/backend/prod-state.ts and stacks/authentik/prod-secrets.ts), so they’re listed for completeness.
| Secret ID | Used by | Source of the value |
|---|---|---|
clubspot-username |
clubspot-sync | TheClubSpot login email |
clubspot-password |
clubspot-sync | TheClubSpot login password |
directus-license-key |
Directus | The Open Innovation Grant’s license key (§6). Required for the Community and Team roles’ rules |
directus-key |
Directus | Pulumi-generated. |
directus-secret |
Directus | Pulumi-generated. |
directus-db-password |
Directus | Pulumi-generated, and set on the directus Cloud SQL user too |
directus-admin-bootstrap-password |
Directus | Pulumi-generated. The built-in admin, which the Directus* resources sign in as |
directus-oidc-client-secret |
Directus | Pulumi-generated by Authentik before cyc-seattle/workplace#6. See backend.md |
directus-community-role-id |
nothing | Pulumi-generated, from the Community role’s ID. The cluster passes the ID to Directus directly |
clubspot-sync-directus-token |
clubspot-sync | Pulumi-generated. Its machine user’s Directus token |
gsuite-sync-directus-token |
gsuite-sync | Pulumi-generated. Its machine user’s Directus token |
csc-website-directus-token |
csc-website | Pulumi-generated. The website build’s Directus token, which cyc-seattle/csc-website’s build reads |
csc-website-publish-key |
Directus | The private key of the GitHub App that starts the website’s publish workflow (§6) |
google-oauth-client-id |
Authentik | The Google OAuth client’s ID (§8) |
google-oauth-client-secret |
Authentik | The Google OAuth client’s secret (§8) |
authentik-secret-key |
Authentik | Pulumi-generated. |
authentik-db-password |
Authentik | Pulumi-generated, and set on the authentik Cloud SQL user too |
authentik-bootstrap-token |
Authentik | Pulumi-generated. akadmin’s API token, used only to create the pulumi service account and token |
authentik-api-token |
Authentik | Pulumi-generated. The pulumi service account’s token, which authentik signs in with |
authentik-bootstrap-password |
Authentik | Pulumi-generated. akadmin’s break-glass login (§8) |
inbox-app-key |
FreeScout | Pulumi-generated. Encrypts each mailbox’s Google sign-in, so a restore needs it (§11) |
inbox-admin-password |
FreeScout | Pulumi-generated. The break-glass admin, for when Authentik is down (§11) |
inbox-oauth-licence |
nobody | The OAuth & Social Login module’s licence key, kept for a rebuild (§11) |
inbox-api-licence |
nobody | The API & Webhooks module’s licence key, kept for a rebuild (§11) |
6. Directus (directus.<domain>)
backend.md describes what the backend stack deploys. Directus authenticates through
its own authentik OIDC provider and enforces roles itself, with no forward-auth gate in front. The
built-in admin (directus-admin-bootstrap-password, §5) is the break-glass login if Authentik is
down.
- Create a
clubspot_promoted_fieldsrow withtarget_field: schooland the Clubspot labels to match (see syncs.md). - Set
directus-license-key(§5) before Directus first boots, and renew the grant each year. - Make the GitHub App that publishes the website when its content changes
(website.md), in prod only:
- In the
cyc-seattleorganization’s settings, under Developer settings → GitHub Apps, create an App. Turn its webhook off, give it one repository permission, Actions: Read and write, and let it be installed only on this account. - Install it on Only select repositories:
csc-website. - Generate a private key, and set the downloaded file as
csc-website-publish-key(§5):gcloud secrets versions add csc-website-publish-key --data-file=<the .pem file> --project cyc-admin-scripts. Then delete the file. - Set
backend:websitePublishAppIdinstacks/backend/Pulumi.prod.yamlto the App’s ID, and deploy. Until then, nothing reads the key and Directus publishes nothing.
- In the
MCP needs no manual step: backend writes its settings row (backend.md). Connect a
client with claude mcp add --transport http directus https://directus.<domain>/mcp, then authorize
in the browser.
License: Directus 12’s unlicensed Core tier refuses every permission with a relational filter (
403 custom_permission_rules_enabled is a restricted resource), and the roles depend on them. CYC holds a license through Directus’s Open Innovation Grant: free for a nonprofit of its size, valid one year, and renewable.stacks/backend/cluster.tspasses it to Directus asLICENSE_KEY. backend.md says what spends an activation.
7. Groups Administrator role for gsuite-sync
gsuite-sync writes group membership and settings as itself. It holds the Groups Administrator
role directly, rather than impersonating an admin through domain-wide delegation.
- As a Workspace super-admin, open Admin console → Account → Admin roles → Groups Admin →
Assign service accounts, and add
gsuite-sync@cyc-admin-scripts.iam.gserviceaccount.com. - Before the first real run, confirm with
gsuite-sync --dry-runagainst one throwaway group that the Groups Settings API also accepts this credential. Google’s announcement of role-assignable service accounts covers the Directory API and says nothing about Groups Settings. If it 403s, drop the settings pass rather than adding delegation for it.
8. Authentik (login.<domain>)
The authentik stack deploys Authentik and configures its flows, sources, and applications. It
sends sign-in mail through the relay in §4.
- In the Google Cloud console, an OAuth consent screen set to External, so families’ personal Google accounts can sign in.
- An OAuth 2.0 Client ID, type Web application, with the redirect URI
https://login.cycsail.team/source/oauth/callback/google/. Its ID and secret go ingoogle-oauth-client-idandgoogle-oauth-client-secret(§5). - Remove the retired redirect URIs
https://cycsail.team/oauth2/callbackandhttps://directus.cycsail.team/auth/login/google/callbackfrom that client.
If Authentik’s own sign-in is ever unreachable, sign in as akadmin with the password in
authentik-bootstrap-password:
gcloud secrets versions access latest --secret authentik-bootstrap-password --project cyc-admin-scripts9. Delegate cyccommunitysailing.org to Cloud DNS
The website’s domain is registered at Porkbun, which also serves its records. The infra stack’s
external zone holds a copy of them (stacks/infra/external-records.ts), so switching name servers
changes no answer (#150). Mail is what breaks if a record is missing, so do this off-season, and not
during a newsletter send.
-
Apply prod
infrawith the records, then compare the zone with Porkbun. It queries both for every record name the zone declares and the common ones it might lack, and exits 1 on any difference. A record only Porkbun has goes intoexternal-records.tsbefore you go on.Terminal window mise run compare-dns -
In Porkbun’s DNS records for the domain, lower each record’s TTL to 300 seconds, then wait out the old TTL (10 minutes). A wrong answer after the switch is then cached for only 5 minutes. The script doesn’t compare TTLs.
-
Check DNSSEC is off at Porkbun:
host -t DS cyccommunitysailing.orgfinds no record. Porkbun would sign with keys Cloud DNS doesn’t hold, so a DS record left in place breaks the domain. -
Run
mise run compare-dnsonce more, then, at Porkbun, replace the domain’s authoritative name servers with the zone’s:Terminal window pulumi stack output nameServers --cwd stacks/infra --stack prod -
Check the switch. The
.orgregistry serves the new name servers within minutes, but resolvers may keep the old ones for up to 2 days (their TTL is 86400). Both answer the same.host -t NS cyccommunitysailing.orglistsns-cloud-*.googledomains.com.mise run compare-dnsnow compares the zone with itself, so also ask public resolvers:host -t MX cyccommunitysailing.org 8.8.8.8, and the same at1.1.1.1.- Mail from outside reaches a Workspace inbox, and mail sent out shows
spf=passanddmarc=passin its headers at the recipient. - The website loads at the bare domain and at
www.
-
Leave Porkbun’s records in place for at least 2 days. To roll back, put Porkbun’s name servers back.
-
Add Google’s DKIM: generate the key in the Admin console under Apps → Google Workspace → Gmail → Authenticate email, add its
google._domainkeyTXT record toexternal-records.ts, deploy, then press Start authentication.
From then on, the domain’s records change only in external-records.ts, never at Porkbun.
10. The backups project
bootstrap makes csc-backups and everything in it (backups.md). Making a project under
the organization needs more than project Owner.
-
The person who applies
bootstrapholds Project Creator on the organization and Billing Account User on the billing accountcyc-admin-scriptsuses. Check with:Terminal window gcloud organizations get-iam-policy <ORG_ID> --flatten=bindings --filter="bindings.members:user:<deployer-email>" --format="value(bindings.role)"An organization admin grants what’s missing in the IAM console, at the organization.
-
Check prod’s Cloud SQL instance and the buckets
bootstrapcopies exist, which only a rebuild lacks (backups.md). Thenmise run preview-bootstrap, andmise run deploy-bootstrap. It also gives deploy-runner the role theinfrastack’s uptime checks need, so applyinfraafter it. -
After the next run (10:00 or 22:00 UTC), check both buckets have copies, then run the first drill,
mise run restore-drill, and paste its result in cyc-seattle/platform#170.
11. The shared inbox (inbox.<domain>)
inbox.md describes what the inbox stack deploys. These steps come in order.
-
Create the stacks. Each Pulumi stack must exist before the first deploy, which never creates one. A deployer runs, from the repo root:
Terminal window mise exec -- pulumi stack init prod --cwd stacks/inbox --secrets-provider gcpkms://projects/cyc-admin-scripts/locations/us-west1/keyRings/pulumi/cryptoKeys/state-prodIt adds an
encryptedkeyline toPulumi.prod.yaml. Commit it. -
Make the mailbox user, as a Workspace super-admin, in the Admin console:
- Billing → Subscriptions: check it’s Google Workspace for Nonprofits, so a new user is free.
- Directory → Users → Add new user:
inbox@cyccommunitysailing.org, named Inbox FreeScout. Let Google make the password. Nobody signs in to it but to connect FreeScout in step 6. - Directory → Groups → info@ → Members → Add members:
inbox@, delivery “Each email”. - In the info@ group’s settings, check that anyone can post and that moderation holds nothing. Held mail never reaches inbox@.
- Apps → Google Workspace → Gmail → End User Access → IMAP access: on, for inbox@’s organizational unit.
-
Make the Google sign-in for the mailbox, in the Cloud console for
cyc-admin-scripts:- The Gmail API is enabled by the
infrastack. - Credentials → Create credentials → OAuth client ID → Web application, named
FreeScout inbox, with the authorized redirect URIhttps://inbox.cycsail.team/mailbox/oauth. - The consent screen is External, for families’ Google sign-in (§8), so Google treats the mail scope as unverified. In the Admin console, Security → Access and data control → API controls → Manage third-party app access → Configure new app: paste the client ID, and choose Trusted.
- Keep the client ID and secret for step 6. FreeScout keeps them, encrypted, in its database.
- The Gmail API is enabled by the
-
Buy the modules, at freescout.net: OAuth & Social Login ($8) and API & Webhooks ($12.99). A licence covers one instance. Keep the keys for a rebuild, in the two secrets the
inboxstack makes. Run these in your own terminal, so the key isn’t echoed anywhere else:Terminal window printf %s '<key>' | gcloud secrets versions add inbox-oauth-licence --data-file=- --project cyc-admin-scriptsprintf %s '<key>' | gcloud secrets versions add inbox-api-licence --data-file=- --project cyc-admin-scripts -
Install the modules, once prod is deployed. Sign in at
/loginas the break-glass admin,inbox:adminEmail, with its password:gcloud secrets versions access latest --secret inbox-admin-password --project cyc-admin-scripts. Then:- Manage → Modules: paste each licence key, then Install, then Activate.
- Manage → Settings → OAuth: add a provider named Sign in, with Authentik’s URLs
(
https://login.<domain>/application/o/authorize/,.../token/, and.../userinfo/), the scopesopenid email profile, and theinboxstack’soidcClientIdandoidcClientSecretoutputs (pulumi stack output --show-secrets --cwd stacks/inbox). Turn on creating users automatically. Leave Force OAuth Login off until signing in through Authentik works. - Sign out, sign in through Authentik, then turn on Force OAuth Login. If sign-in through Authentik ever breaks after that, inbox.md has the command that turns it off again.
-
Connect info@, in prod’s FreeScout: Manage → Mailboxes → New mailbox, with the email
info@cyccommunitysailing.organd the name CYC Community Sailing Center. Then, in its Connection Settings:- Fetching Emails: IMAP,
imap.gmail.com, port 993, SSL, the client ID from step 3 as the username and its secret as the password, folder INBOX. Reset inbox@’s password in the Admin console, sign in to Google as inbox@ in a private window, then click Connect, and allow FreeScout. Connecting while signed in as anyone else fails with “Invalid credentials”. Sign out after. - Sending Emails: SMTP,
smtp-relay.gmail.com, port 587, TLS, with no username.
- Fetching Emails: IMAP,
-
Test it both ways: email info@ from a personal address, check it arrives, reply from FreeScout, check the reply comes from info@ with
spf=passanddmarc=passin its headers, answer it, and check the answer joins the conversation. -
Let people in: in the Data Studio, under Access → Groups, make a group such as Office that gives the FreeScout Agent policy, and add each person to it. They need to have signed in to something once, so Authentik knows them. After their first sign-in to FreeScout, put them on the mailbox under Manage → Mailboxes → info@ → Permissions.
-
Cut over, once volunteers have used FreeScout side by side with the group for the trial:
- Note the info@ group’s members and settings, in case you need to put it back.
- Admin console → Directory → Groups → info@ → Delete group. Google frees the address once the group is gone, which can take a few minutes.
- Directory → Users → inbox@ → User information → Alternate email addresses (email aliases) →
add
info. Mail to info@ now lands in inbox@ directly. - Email info@ again, and check it arrives in FreeScout and a reply still goes out from info@.
12. The newsletter: AWS, SES, and Listmonk
Listmonk sends the newsletter through Amazon SES (newsletter.md). Do these in order. Apply
bootstrap and infra from the branch that adds them, as for any new output.
-
The AWS account. CSC’s own, with a Google Group, such as
aws@<external domain>, as its root email: the maintainer and one other board member are members, and anyone on the web may post to it. Sign up at https://signin.aws.amazon.com/signup?request_type=register as a Business, with CSC’s card, on the free Basic support plan. -
Lock down root. Under Security credentials, add two MFA devices, one held by the other board member. Never make an access key for root.
-
A login for the maintainer. IAM → Users → Create user, with console access and
AdministratorAccess, then add MFA to it. Use it, not root, from now on. -
Billing alerts. As root, Account → IAM user and role access to Billing information → Activate. Then Budgets → Create budget → Monthly cost budget for a few dollars, emailing the Google Group, and turn on Receive AWS Free Tier alerts under Billing preferences.
-
SES’s plan. In US West (Oregon) us-west-2, Amazon SES → Account dashboard: if it shows Essentials, switch to pay as you go. Neither has a monthly fee.
-
The role Pulumi uses. Get
deploy-runner’s unique ID:Terminal window gcloud iam service-accounts describe deploy-runner@<project>.iam.gserviceaccount.com --format='value(uniqueId)'IAM → Roles → Create role → Custom trust policy, with
<UNIQUE_ID>filled in:{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": { "Federated": "accounts.google.com" },"Action": "sts:AssumeRoleWithWebIdentity","Condition": {"StringEquals": {"accounts.google.com:aud": "<UNIQUE_ID>","accounts.google.com:sub": "<UNIQUE_ID>","accounts.google.com:oaud": "sts.amazonaws.com"}}}]}Name it
pulumi-deploy-runner, with no managed policies. Then Add permissions → Create inline policy → JSON, with<ACCOUNT_ID>filled in, namedses-and-listmonk-smtp:{"Version": "2012-10-17","Statement": [{"Sid": "Ses","Effect": "Allow","Action": "ses:*","Resource": "*","Condition": { "StringEquals": { "aws:RequestedRegion": "us-west-2" } }},{"Sid": "FeedbackTopic","Effect": "Allow","Action": "sns:*","Resource": "arn:aws:sns:us-west-2:<ACCOUNT_ID>:ses-feedback"},{"Sid": "SmtpUser","Effect": "Allow","Action": ["iam:GetUser","iam:CreateUser","iam:DeleteUser","iam:TagUser","iam:UntagUser","iam:ListGroupsForUser","iam:ListUserPolicies","iam:ListAttachedUserPolicies","iam:GetUserPolicy","iam:PutUserPolicy","iam:DeleteUserPolicy","iam:CreateAccessKey","iam:DeleteAccessKey","iam:ListAccessKeys","iam:UpdateAccessKey"],"Resource": "arn:aws:iam::<ACCOUNT_ID>:user/listmonk-smtp"}]} -
bootstrap:mise run preview-bootstrap, thenmise run deploy-bootstrap. It lets deploy-runner make its own ID token, which is all the role trusts, and makes Listmonk’s pictures bucket and its key. -
infra: setinfra:awsRoleArninstacks/infra/Pulumi.prod.yamlto the role’s ARN, in a PR. Its prod deploy verifies the domain in SES and adds the DKIM andbounce.records. Amazon SES → Identities shows the domain verified within the hour. -
Leave SES’s sandbox. Amazon SES → Account dashboard → Request production access: Marketing, the website’s address, and how signups are confirmed and bounces handled. AWS answers within 4 days.
-
Listmonk’s stacks, as for the inbox’s (§11 step 1), with
--cwd stacks/listmonk, before the PR that adds them merges. Commit theencryptedkeyline it adds. -
Send through SES. Once SES is out of its test mode, set
listmonk:ses: trueinstacks/listmonk/Pulumi.prod.yaml, and oncebootstraphas made the pictures bucket,listmonk:mediaBucket: true. Until then prod sends its confirmations through the Workspace relay, and keeps pictures in the pod. -
Bounces back to Listmonk. Once
https://mail.<external domain>/healthanswers, setinfra:listmonkFeedback: truein a PR. Listmonk confirms SNS’s subscription itself: Amazon SNS → Subscriptions shows it confirmed. -
Listmonk’s look. Signed in as
admin(pulumi stack output adminPassword --show-secretsinstacks/listmonk), set the logo, colors, and the confirmation email’s words under Settings → Appearance and Campaigns → Templates. Settings that live in code are written again at each start.
13. The monthly budget
bootstrap sets a $150 monthly budget on the project’s billing account (#171). Its emails go to the
account’s Billing Account Administrators and Users.
- A Billing Account Administrator grants whoever applies
bootstrapBilling Account Costs Manager (roles/billing.costsManager) on the billing account, under Billing → Account management. It manages budgets and reads costs, and can’t change payment or link projects.
When you add a new manual step
If you add infrastructure that needs an out-of-band action, add it here.