You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(discord): auto-register commands in base guilds at terraform apply time (#35)
- Add null_resource.discord_register_commands that PUTs
COMMAND_DESCRIPTORS
to Discord for each base guild when discord_bot_token and
discord_application_id are set; re-runs on token rotation or command
changes
- Add null provider to required_providers
- Fix DiscordConfigRedacted in api.ts to include baseAllowedGuilds and
baseAdmins (server already sent them; web type was missing the fields)
- Update GuildsTab to render terraform-managed guilds as locked rows
with a
Register commands button but no Remove
- Update AdminsTab to show terraform-managed admin lists as a read-only
section
https://claude.ai/code/session_01RDoBVo5enCMbBxJVYvJKzd
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/docs/components/terraform.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ step 3 of the [setup guide](/setup) for details.
19
19
|`watchdog.tf`|`watchdog` Lambda with its IAM, EventBridge schedule at `rate(${watchdog_interval_minutes} minute(s))`. |
20
20
|`interactions.tf`|`interactions` Lambda with IAM + Function URL (`auth_type = NONE`, CORS for `https://discord.com`). Exposes `interactions_invoke_url`. |
21
21
|`followup.tf`|`followup` Lambda with IAM (`ecs:RunTask`, `StopTask`, `DescribeTasks`, `iam:PassRole`, `dynamodb:GetItem`/`PutItem`, `ec2:DescribeNetworkInterfaces`). Async-invoked by interactions. |
22
-
|`discord_store.tf`| DynamoDB table (pk+sk, TTL on `expiresAt`), two Secrets Manager secrets (`${project_name}/discord/bot-token`, `/discord/public-key`) with `recovery_window_in_days = 0` and `lifecycle.ignore_changes` on seeded secret values. Optional `CONFIG#discord` DynamoDB item seeded from tfvars. Optional `BASE#discord` item holding the Terraform-managed base allowlist/admins (see `base_allowed_guilds` / `base_admin_*` variables). |
22
+
|`discord_store.tf`| DynamoDB table (pk+sk, TTL on `expiresAt`), two Secrets Manager secrets (`${project_name}/discord/bot-token`, `/discord/public-key`) with `recovery_window_in_days = 0` and `lifecycle.ignore_changes` on seeded secret values. Optional `CONFIG#discord` DynamoDB item seeded from tfvars. Optional `BASE#discord` item holding the Terraform-managed base allowlist/admins (see `base_allowed_guilds` / `base_admin_*` variables). When `discord_bot_token`, `discord_application_id`, and at least one `base_allowed_guilds` entry are set, a `null_resource` runs `curl` to register slash commands in each base guild during apply; re-runs on token rotation or command-descriptor changes. |
23
23
|`variables.tf`| Every configurable input. See the table below. |
24
24
|`outputs.tf`| Every value the management app (and humans) consume. |
25
25
|`terraform.tfvars.example`| Starting point for your `terraform.tfvars`. |
Copy file name to clipboardExpand all lines: docs/docs/setup.md
+12-5Lines changed: 12 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -333,6 +333,11 @@ connect it to a Discord application.
333
333
base_admin_role_ids = []
334
334
```
335
335
336
+
When `discord_bot_token`, `discord_application_id`, **and** at least one
337
+
entry in `base_allowed_guilds` are all set, `terraform apply` also
338
+
registers the slash commands in each base guild automatically — no manual
339
+
"Register commands" click needed for those guilds.
340
+
336
341
3.**Copy the interactions endpoint URL** (the `interactions_invoke_url`
337
342
Terraform output, also shown in the dashboard Credentials tab) into the
338
343
Discord Developer Portal under **General Information → Interactions
@@ -353,10 +358,12 @@ connect it to a Discord application.
353
358
**Copy ID**.
354
359
355
360
6.**In the dashboard's Discord Bot panel:**
356
-
-**Guilds tab**: add the guild ID and click **Register commands** so
357
-
Discord learns about `/server-start`, `/server-stop`, `/server-status`,
358
-
`/server-list`. This is a per-guild REST call; there are no global
359
-
commands.
361
+
-**Guilds tab**: guilds in `base_allowed_guilds` have their slash commands
362
+
registered automatically by `terraform apply` (provided the bot token and
363
+
application ID were set in tfvars). For any guild added via the UI, click
364
+
**Register commands** to install `/server-start`, `/server-stop`,
365
+
`/server-status`, `/server-list`. This is always a per-guild REST call;
366
+
there are no global commands.
360
367
-**Admins tab**: user IDs and/or role IDs that can run everything on
361
368
everything.
362
369
-**Per-Game Permissions tab**: for each game, which users/roles can
@@ -407,7 +414,7 @@ hitting "already scheduled for deletion".
407
414
| Dashboard says **terraform not applied** in the Discord panel |`interactions_invoke_url` output missing | Re-run `cd app && npm run build:lambdas && cd ../terraform && terraform apply`. |
408
415
| Dashboard says **awaiting credentials**| Secrets still contain the Terraform `"placeholder"` seed | Paste the real bot token + public key in the Credentials tab and Save. |
409
416
| Discord rejects the interactions URL with "invalid interactions endpoint URL" | Public key in Secrets Manager doesn't match Discord's | Re-copy the Application Public Key from the Developer Portal and Save. |
410
-
|`/server-*` slash commands don't appear in Discord | Per-guild registration not done | Guilds tab → **Register commands** next to the guild ID. |
417
+
|`/server-*` slash commands don't appear in Discord | Per-guild registration not done |For base guilds: ensure `discord_bot_token`, `discord_application_id`, and `base_allowed_guilds` are all set in tfvars, then re-run `terraform apply`. For UI-added guilds: Guilds tab → **Register commands** next to the guild ID. |
411
418
|`/server-start` says "You don't have permission" | Your user/role isn't in admins or per-game permissions, or the `start` action isn't ticked | Admins tab or Per-Game Permissions tab, then retry. |
412
419
| Task reaches RUNNING but DNS never updates | update-dns Lambda errored; EventBridge rule might be disabled | Check the Lambda's CloudWatch logs; verify the EventBridge rule is enabled. |
413
420
| Watchdog stops tasks too aggressively | Low `watchdog_min_packets`, short `watchdog_interval_minutes`, or low `watchdog_idle_checks`| Tune the three knobs via the dashboard **Server Config** panel and re-apply. |
0 commit comments