# l1-ecs-service — ECS Fargate service primitive (multi-resource L1) An L1 module for an ECS Fargate service (task definition + service). Substrate-agnostic (the IR types are `aws:ecs:task_definition` and `aws:ecs:service`, not Terraform resource types). This is a multi-resource L1: the interface declares the group's inputs/outputs plus a `resources` array listing the IR types it emits. The IR instance (Phase 14/15) will have multiple `resources` entries all with `module: "l1-ecs-service@1.0.0"`. ## Interface (the IR-typed contract) See `interface.json`: inputs `image` (string, ECR image URL), `port` (number), `cpu` (number, default 256), `memory` (number, default 512), `env` (optional JSON map string), `cluster_arn` (arn, ref to l1-ecs-cluster), `subnets` (string, ref to l1-vpc), `security_group` (string), `lb_target_group_arn` (arn, optional, ref to l1-alb), `region` (string); outputs `service_arn` (arn) + `task_def_arn` (arn); no NFRs. The `resources` array lists the emitted IR types: - `aws:ecs:task_definition` — Fargate task definition. The adapter jsonencodes `image`/`port`/`env` into `container_definitions`. - `aws:ecs:service` — Fargate service running the task definition in the cluster + subnets (+ optional ALB target group wiring). ## IR → Terraform mapping (performed by the adapter) The Terraform adapter (`adapters/terraform/adapter.py`) translates each emitted IR resource to Terraform: | IR | Terraform | |----|-----------| | `resource.type = aws:ecs:task_definition` | `resource "aws_ecs_task_definition" "" { ... }` | | `resource.inputs.image` + `port` + `env` | `container_definitions = jsonencode(...)` (adapter-built) | | `resource.inputs.cpu` | `cpu = ` arg | | `resource.inputs.memory` | `memory = ` arg | | `resource.outputs.task_def_arn` | `output "task_def_arn" { value = aws_ecs_task_definition..arn }` | | `resource.type = aws:ecs:service` | `resource "aws_ecs_service" "" { ... }` | | `resource.inputs.cluster_arn` | `cluster = ` arg (identity) | | `resource.inputs.subnets` | `network_configuration { subnets = [...] }` (emit as-is) | | `resource.inputs.security_group` | `network_configuration { security_groups = [...] }` (emit as-is) | | `resource.inputs.lb_target_group_arn` | `load_balancer { target_group_arn = }` (emit as-is) | | `resource.outputs.service_arn` | `output "service_arn" { value = aws_ecs_service..id }` | The adapter is a thin layer (ARCHITECTURE.md §12.2); it does not own L1 content — it only translates. The `container_definitions` JSON is built by the adapter from the IR `image`/`port`/`env` inputs (the one transformation the adapter owns for ECS task definitions). ## Versioning (W3.D) `1.0.0` — interface MAJOR, behavior MINOR, lifecycle PATCH. MAJOR bumps require a new registry entry (immutable publication); old entries enter a 12-month deprecation window.