Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions deploy/nix/deployment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@
# which names it "/${name_prefix}-${environment}/guest".
guestLogGroup = "/CHANGE-ME-production/guest";

# Guest telemetry: what a guest reports through wit/telemetry. `xray`
# exports each guest invocation as one X-Ray trace, attributed to its
# tenant; `metricsNamespace` publishes guest metrics to CloudWatch under that
# namespace (not under `AWS/`), or "" for none. Each needs the instance
# role's grant — `deploy/tofu` gives it when `telemetry` is set there.
#
# Measured by PCR0 like everything here, so a client can tell from an
# attestation whether an enclave ships its traces off the box. What a trace
# carries is the guest's own text plus the tenant id; see
# runtime/src/telemetry.
xray = false;
metricsNamespace = "";

# The guest is not here either. The runtime fetches it from
# `guest/guest.wasm` in `rootsBucket` (`bucketPrefix` is not applied) and
# measures it into PCR16 before it asks KMS for a key, so changing the guest
Expand Down
44 changes: 44 additions & 0 deletions deploy/tofu/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,50 @@ resource "aws_iam_role_policy" "push" {
policy = data.aws_iam_policy_document.push[0].json
}

# Guest telemetry, as the image names it (`xray` and `metricsNamespace` in
# deploy/nix/deployment.nix), and only what the runtime calls. X-Ray takes no
# resource-level scoping, so trace segments are account-wide; metrics are held to the
# image's one namespace by condition. Nothing when telemetry is off.
locals {
telemetry_on = var.telemetry.xray || var.telemetry.metrics_namespace != ""
}

data "aws_iam_policy_document" "telemetry" {
count = local.telemetry_on ? 1 : 0

dynamic "statement" {
for_each = var.telemetry.xray ? [1] : []
content {
sid = "PutGuestTraces"
effect = "Allow"
actions = ["xray:PutTraceSegments"]
resources = ["*"]
}
}

dynamic "statement" {
for_each = var.telemetry.metrics_namespace != "" ? [1] : []
content {
sid = "PutGuestMetrics"
effect = "Allow"
actions = ["cloudwatch:PutMetricData"]
resources = ["*"]
condition {
test = "StringEquals"
variable = "cloudwatch:namespace"
values = [var.telemetry.metrics_namespace]
}
}
}
}

resource "aws_iam_role_policy" "telemetry" {
count = local.telemetry_on ? 1 : 0
name = "${local.name}-telemetry"
role = aws_iam_role.parent.id
policy = data.aws_iam_policy_document.telemetry[0].json
}

# For a shell without opening port 22.
resource "aws_iam_role_policy_attachment" "ssm" {
role = aws_iam_role.parent.name
Expand Down
9 changes: 9 additions & 0 deletions deploy/tofu/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ variable "push_app_id" {
default = ""
}

variable "telemetry" {
description = "Guest telemetry, as the image names it (xray and metricsNamespace in deployment.nix). With xray the parent's role may put X-Ray trace segments; with a metrics_namespace it may publish CloudWatch metrics to that namespace and no other."
type = object({
xray = optional(bool, false)
metrics_namespace = optional(string, "")
})
default = {}
}

variable "pool_size_gib" {
type = number
default = 32
Expand Down
Loading
Loading