fix: address Phase-5 code review (4 findings)

Reviewer flagged two security-relevant items and two operational bugs
on the external-DB + Terraform module merge.

1. Terraform: `enable_execute_command = true` was hardcoded on the app
   and embedder services. Production attack surface (anyone with
   `ecs:ExecuteCommand` on the service gets a container shell) AND
   non-functional today since the task roles have no `ssmmessages:*`
   permission. Added a new `enable_execute_command` boolean input
   variable defaulting to `false`; when flipped on, the SSM messages
   policy is conditionally attached to both task roles so the feature
   actually works. README's variable description tells operators to
   flip on for incidents, off afterward.

2. Terraform: `secret_arns` output was not marked `sensitive`. The ARNs
   themselves aren't secrets, but the embedded secret names print to
   `terraform apply` stdout and CI logs. Marked sensitive on both the
   module output and the example output. Operators wanting the values
   can still `terraform output -json secret_arns`.

3. Terraform: embedder task definition was missing `HOST=0.0.0.0` and
   `PORT=8080`. Fargate awsvpc tasks each get their own ENI; default
   Node HTTP servers bind 127.0.0.1, which would make every
   app→embedder Service Connect call time out. Added both vars to
   `embedder_environment`. Also added `NEXT_TELEMETRY_DISABLED=1` to
   `app_environment` per the spec's hardening checklist.

4. Compose: docker-compose.external-db.yml uses the `!override` YAML
   tag, which requires Docker Compose >= 2.24.0. Silently ignored on
   older Compose, causing the `db` dependency to survive the merge and
   startup to fail. Documented the minimum version in the override
   file's header AND in the main README prerequisites with a deep
   link to the External Postgres section.

terraform fmt + validate (module + examples/basic) both clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 09:48:04 -07:00
co-authored by Claude Opus 4.7
parent a92504d799
commit d1d4c60f2d
7 changed files with 72 additions and 4 deletions
+9 -2
View File
@@ -61,6 +61,7 @@ locals {
{ name = "EMBEDDER_URL", value = "http://embedder:${local.embedder_port}" },
{ name = "EMBEDDING_MODEL", value = var.embedding_model },
{ name = "EMBEDDING_DIM", value = tostring(var.embedding_dim) },
{ name = "NEXT_TELEMETRY_DISABLED", value = "1" },
]
# `secrets` block format that ECS expects: name = env-var name, valueFrom
@@ -73,6 +74,12 @@ locals {
]
embedder_environment = [
# awsvpc network mode gives every task its own ENI — bind to 0.0.0.0
# explicitly so Service Connect reaches the embedder on the task's
# ENI address. Default Node servers often bind 127.0.0.1, which
# would silently make every app→embedder call time out.
{ name = "HOST", value = "0.0.0.0" },
{ name = "PORT", value = tostring(local.embedder_port) },
{ name = "LOG_LEVEL", value = var.log_level },
{ name = "EMBEDDING_MODEL", value = var.embedding_model },
{ name = "EMBEDDING_DIM", value = tostring(var.embedding_dim) },
@@ -272,7 +279,7 @@ resource "aws_ecs_service" "embedder" {
task_definition = aws_ecs_task_definition.embedder.arn
desired_count = var.embedder_desired_count
launch_type = "FARGATE"
enable_execute_command = true
enable_execute_command = var.enable_execute_command
network_configuration {
subnets = var.private_subnet_ids
@@ -322,7 +329,7 @@ resource "aws_ecs_service" "app" {
task_definition = aws_ecs_task_definition.app.arn
desired_count = var.app_desired_count
launch_type = "FARGATE"
enable_execute_command = true
enable_execute_command = var.enable_execute_command
network_configuration {
subnets = var.private_subnet_ids