Skip to content

dolphin-maps: MusicKit key container (dolphin-maps/musickit), loaded into prod and stage Workers - #715

Open
ejc3 wants to merge 2 commits into
mainfrom
dolphin-maps-musickit
Open

ejc3 wants to merge 2 commits into
mainfrom
dolphin-maps-musickit

Conversation

@ejc3

@ejc3 ejc3 commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

dolphin-labs-hq/dolphin-maps is adding Apple Music (its docs/design/music.md, stage 7). The car screen plays it through MusicKit JS, which needs a developer token: an ES256 JWT signed with a MusicKit private key. The site's Worker mints short-lived ones at /api/music/apple/token, so the Worker needs the key. This PR adds a place to keep it and loads it into both Workers.

What changes

  • dolphin-maps-musickit.tf: a Secrets Manager container, dolphin-maps/musickit (us-west-1). Its JSON holds MUSICKIT_KEY_ID, MUSICKIT_TEAM_ID and MUSICKIT_PRIVATE_KEY (the PEM text of the .p8 file).
    • A resource policy denies GetSecretValue to anyone outside games_mp_admin_principals.
    • dev-server-role gets PutSecretValue and DescribeSecret on this one secret, and no GetSecretValue, as a statement in the existing dev-dolphin-maps-pems policy (the role is at IAM's 20 managed-policy attachments). The key was made from a dev box's session, so the box can store it but never read it back.
    • Terraform never holds the value.
  • scripts/workers-prod-secrets.sh and scripts/workers-stage-secrets.sh: for dolphin-maps, the loader also reads this container and merges its three names.
    • It reads with the caller's own credentials. This container lives in this account, unlike the site's other containers, which are in the Dolphin account.
    • If the container has no value yet (ResourceNotFoundException), the loader says so and loads without it. The site then keeps Apple Music off on the car screen.
    • These refuse the whole load before Wrangler runs: any other read failure, a set of names that isn't exactly those three, a key id or team id that isn't 10 characters, a key that isn't PEM, and a name that is also in another container.
  • Tests: scripts/test-dolphin-maps-prod.py and scripts/test-workers-stage-secrets.py.
    • The fake aws now answers for the container.
    • New tests cover these cases: the key is merged; it is read with the caller's credentials; there is no value yet; the read is denied; the container is malformed; a name collides; no other site reads it; values are never printed.
    • The new tests were seen failing against the old scripts (9 and 2 failures) and passing with the change.
  • AGENTS.md: an entry next to the PeMS login.

One key for prod and stage. The owner chose this. A developer token identifies the app to Apple, not a person, and carries no one's data. To rotate it, make a second MusicKit key for the same Media ID (Apple allows two), put it here, load it, then revoke the first.

After this is applied

  1. A dev box puts the value with the jq … | aws secretsmanager put-secret-value … file:///dev/stdin command in the .tf header.
  2. After the site's next deploy, run scripts/workers-stage-secrets.sh dolphin-maps and scripts/workers-prod-secrets.sh dolphin-maps.

Tests run: python3 scripts/test-dolphin-maps-prod.py (24 OK), python3 scripts/test-workers-stage-secrets.py (22 OK), and every other scripts/test-*.py. Two of those need root or a Terraform init and fail the same way on main. terraform fmt -check passes.

- dolphin-maps-musickit.tf: the Secrets Manager container dolphin-maps/musickit
  (JSON: MUSICKIT_KEY_ID, MUSICKIT_TEAM_ID, MUSICKIT_PRIVATE_KEY), readable by
  administration only; dev-server-role may put and describe it, never read it.
  No value in Terraform.
- scripts/workers-prod-secrets.sh and workers-stage-secrets.sh: for dolphin-maps,
  read it with the caller's own credentials (this account) and merge its three
  names into dolphin-maps-prod / -stage. No value yet: load without it. Any other
  read failure, a wrong set of names, a non-PEM key or a name in two containers
  refuses the load before Wrangler runs.
- Tests for both loaders (fake aws gains the container); AGENTS.md entry.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d3dbc17-12e2-4df6-910c-374805106b13
Commits

Reviewing files that changed from the base of the PR and between e4e019d and b7acb57.

Files selected for processing: 7
  • AGENTS.md
  • dolphin-maps-loop.tf
  • dolphin-maps-musickit.tf
  • scripts/test-dolphin-maps-prod.py
  • scripts/test-workers-stage-secrets.py
  • scripts/workers-prod-secrets.sh
  • scripts/workers-stage-secrets.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T06:22:17.729829Z b7acb57 Manual request
🔒 Security Review 🔄 Running since 2026-10-28T06:22:10.512338Z b7acb57 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13fb6bf417

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dolphin-maps-musickit.tf Outdated
Comment on lines +71 to +73
resource "aws_iam_role_policy_attachment" "dolphin_maps_musickit_dev" {
role = aws_iam_role.dev_server.name
policy_arn = aws_iam_policy.dolphin_maps_musickit_dev.arn

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reuse an existing managed policy for the MusicKit grant

With the checked-in defaults (enable_wbox = true), dev-server-role already has 20 managed-policy attachments; this adds a 21st, exceeding IAM's maximum of 20 per role. The existing constraint is also documented in dev-ai-services.tf:489-490, where another grant was folded into assume-constellation-terraform for precisely this reason. Applying this change will fail at the attachment, leaving the metal boxes unable to populate the MusicKit secret. Add these scoped permissions to an existing managed policy with sufficient space, or consolidate existing policies before attaching another.

AGENTS.md reference: AGENTS.md:L1636-L1638

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RED-VERIFIED: right, dev-server-role is at 20 attachments. b7acb57 drops the separate policy and attachment and adds the MusicKit put/describe statement to dev-dolphin-maps-pems's document (description unchanged, so the policy is updated in place, not replaced).

dev-server-role is at IAM's 20 managed-policy attachments (Codex on #715): the
PutSecretValue/DescribeSecret statement on dolphin-maps/musickit moves into
dev-dolphin-maps-pems's document instead of a policy and attachment of its own.
The policy's description is unchanged (a change would replace it).

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex security review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant