Repository navigation
fcvm-fleet: the wall's broadcast on Amazon IVS #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c237d6f
fcvm-fleet: the wall's broadcast on Amazon IVS
ejc3 6121d44
Merge remote-tracking branch 'origin/main' into fcvm-fleet-broadcast
ejc3 6480462
test-fcvm-fleet: the dual-stack gate covers the broadcast; the broadc…
ejc3 67742d0
fix: keep broadcast grant within IAM quota and order rollout
ejc3 156ae9a
style: format broadcast rollout dependencies
ejc3 6d321c8
Keep broadcast disabled until admission-capable fleet images run
ejc3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # fcvm-fleet-broadcast.tf | ||
| # | ||
| # The wall's broadcast (ejc3/fcvm docs/fleet/ARCHITECTURE.md, "Broadcast mode"): past the direct-mode capacity (500 | ||
| # viewers, ejc3/fcvm fleet/renderer/README.md "Viewers per renderer"), viewers watch one composite of the whole wall that | ||
| # the coordinator encodes and pushes to an Amazon IVS low-latency channel. Measured 2026-10-27 (ejc3/fcvm#1384): 1.79 s | ||
| # glass to glass at the median, 0.21 s to the first frame. | ||
| # | ||
| # - One IVS channel in us-east-1 (IVS is not offered in us-east-2), STANDARD (IVS transcodes the 720p input into 720p, | ||
| # 480p, 360p and 160p), LOW latency, private: a playback request needs a token signed with the channel's playback key | ||
| # pair. The coordinator holds the private key and signs a token per /live connection; /live is behind Cloudflare | ||
| # Access on staging, so only Access-authenticated viewers get one. | ||
| # - The secret fcvm-fleet/broadcast (us-east-2, with the fleet's other secrets): the ingest URL with the stream key, the | ||
| # playback URL, the channel ARN and the playback private key. Only the coordinator's task role reads it. | ||
| # - The coordinator's task grows to 2 vCPU and 4 GB for the decode and the 720p encode (1.69 cores measured on a Xeon), | ||
| # and runs with --broadcast-listen, --broadcast-secret and --direct-capacity (fcvm-fleet.tf). | ||
| # | ||
| # Cost: $2.00 an hour while the channel is live (the coordinator pushes only while the fleet is awake, and the fleet | ||
| # sleeps after 10 minutes with no viewer), $0.072 per viewer-hour at 720p and $0.036 at 480p (North America, first | ||
| # 10,000 hours a month), and the larger task about $43 a month. | ||
| # | ||
| # The gate: local.fcvm_fleet_broadcast. Keep it off until admission-enforcing host and tile AMIs are pinned and | ||
| # running (ejc3/aws#722). Enabling also needs a coordinator image with --broadcast-listen (ejc3/fcvm#1385 and its stack). | ||
|
|
||
| locals { | ||
| fcvm_fleet_broadcast = false | ||
| # The broadcast aggregator's private listener (layout and stats) inside the coordinator's task. | ||
| fcvm_fleet_broadcast_port = 20310 | ||
| # Seats for direct streams; the rest watch the broadcast. | ||
| fcvm_fleet_direct_capacity = 500 | ||
| } | ||
|
|
||
| resource "aws_ivs_channel" "fcvm_fleet_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet_east1 | ||
| name = "fcvm-fleet-stage-broadcast" | ||
| latency_mode = "LOW" | ||
| type = "STANDARD" | ||
| authorized = true | ||
| tags = { Project = "fcvm-fleet", Purpose = "fcvm-fleet-broadcast" } | ||
| } | ||
|
|
||
| # The channel's default stream key (IVS makes one with the channel). | ||
| data "aws_ivs_stream_key" "fcvm_fleet_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet_east1 | ||
| channel_arn = aws_ivs_channel.fcvm_fleet_broadcast[0].arn | ||
| } | ||
|
|
||
| # The playback key pair: IVS keeps the public half; the private half signs viewers' tokens (ES384). | ||
| resource "tls_private_key" "fcvm_fleet_broadcast_playback" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| algorithm = "ECDSA" | ||
| ecdsa_curve = "P384" | ||
| } | ||
|
|
||
| resource "aws_ivs_playback_key_pair" "fcvm_fleet_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet_east1 | ||
| name = "fcvm-fleet-stage-broadcast" | ||
| public_key = tls_private_key.fcvm_fleet_broadcast_playback[0].public_key_pem | ||
| tags = { Project = "fcvm-fleet" } | ||
| } | ||
|
|
||
| resource "aws_secretsmanager_secret" "fcvm_fleet_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet | ||
| name = "fcvm-fleet/broadcast" | ||
| description = "The wall's IVS broadcast: ingest URL with stream key, playback URL, channel ARN, playback private key (JSON). Written by fcvm-fleet-broadcast.tf." | ||
| recovery_window_in_days = 7 | ||
| tags = { Name = "fcvm-fleet/broadcast", Project = "fcvm-fleet" } | ||
| } | ||
|
|
||
| resource "aws_secretsmanager_secret_version" "fcvm_fleet_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet | ||
| secret_id = aws_secretsmanager_secret.fcvm_fleet_broadcast[0].id | ||
| # ejc3/fcvm src/fleet/coord/broadcast.rs, BroadcastSecret. | ||
| secret_string = jsonencode({ | ||
| ingest_url = "rtmps://${aws_ivs_channel.fcvm_fleet_broadcast[0].ingest_endpoint}:443/app/${data.aws_ivs_stream_key.fcvm_fleet_broadcast[0].value}" | ||
| playback_url = aws_ivs_channel.fcvm_fleet_broadcast[0].playback_url | ||
| channel_arn = aws_ivs_channel.fcvm_fleet_broadcast[0].arn | ||
| playback_key_pem = tls_private_key.fcvm_fleet_broadcast_playback[0].private_key_pem_pkcs8 | ||
| }) | ||
| } | ||
|
|
||
| # The coordinator's inline policies already fill its aggregate 10 KiB budget. This | ||
| # managed policy grants only this secret read without changing those permissions. | ||
| resource "aws_iam_policy" "fcvm_fleet_coordinator_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet | ||
| name = "fcvm-fleet-coordinator-broadcast-secret" | ||
| policy = jsonencode({ | ||
| Version = "2012-10-17" | ||
| Statement = [{ | ||
| Sid = "BroadcastSecret" | ||
| Effect = "Allow" | ||
| Action = "secretsmanager:GetSecretValue" | ||
| Resource = aws_secretsmanager_secret.fcvm_fleet_broadcast[0].arn | ||
| }] | ||
| }) | ||
| } | ||
|
|
||
| resource "aws_iam_role_policy_attachment" "fcvm_fleet_coordinator_broadcast" { | ||
| count = local.fcvm_fleet_broadcast ? 1 : 0 | ||
| provider = aws.fcvm_fleet | ||
| role = aws_iam_role.fcvm_fleet_coordinator_task.name | ||
| policy_arn = aws_iam_policy.fcvm_fleet_coordinator_broadcast[0].arn | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.