@crvouga/mockingbird-service-ecs

中文文档
1.11.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 3020

AWS ECS Fargate RunTask acceptance and failure emulator.

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Controls and state
  4. Verification
  5. Deliberately not modelled
  6. API

@crvouga/mockingbird-service-ecs

Local emulators. Real API contracts. Part of Mockingbird.

WIP AWS ECS Fargate RunTask control-plane emulator. It records task acceptance; it never starts containers. Wire contract follows RunTask.

Install

bun add @crvouga/mockingbird-service-ecs

Usage

import { ECSClient, RunTaskCommand } from "@aws-sdk/client-ecs"
import { createServer } from "@crvouga/mockingbird-service-ecs/server"

// Test setup: the ECS client your application already uses, pointed at the emulator.
const server = await createServer()
const ecs = new ECSClient({
  endpoint: server.url,
  region: "us-east-1",
  credentials: { accessKeyId: "fixture", secretAccessKey: "fixture" },
})

// Application code, unchanged. Cluster default and task definition fixture:1 are the fixtures.
const { tasks, failures } = await ecs.send(
  new RunTaskCommand({
    cluster: "default",
    taskDefinition: "fixture:1",
    launchType: "FARGATE",
    networkConfiguration: { awsvpcConfiguration: { subnets: ["subnet-fixture"] } },
  }),
)
// tasks[0].lastStatus === "PROVISIONING"; failures is []

await server.close()

CLI: mockingbird-ecs serve --port 12129. Point the application factory's endpoint_url or AWS_ENDPOINT_URL_ECS at the server. POST / with X-Amz-Target AmazonEC2ContainerServiceV20141113.RunTask accepts AWS JSON 1.1. The default fixtures are cluster default and task definition fixture:1 with container app. Send launchType FARGATE, taskDefinition, count (1–10), networkConfiguration.awsvpcConfiguration and optional overrides.containerOverrides. Responses separate tasks from failures. Cluster name/ARN and task-definition ARN/family:revision/latest active family resolve seeded resources. Missing clusters return ClusterNotFoundException; absent definitions return ClientException. Overrides are retained only in task state, not the request journal. Use synthetic fixture values only.

Controls and state

Options clusters and taskDefinitions replace the default fixtures. Their records are the exported Cluster and TaskDefinition types. The shared /__admin/state routes also seed these collections. Read accepted tasks from tasks and request metadata (network configuration, task ARNs, failures) from requests. Seed placementFailures with AWS Failure objects to script partial placement: each RunTask takes up to count failures in insertion order and accepts the remaining task count. Failures persist until deleted/reset; this is a test control, not a capacity simulator. Tasks remain PROVISIONING with desiredStatus RUNNING; createdAt uses the emulator clock. Identical clientToken retries within a cluster return the same result for 24 hours; changed parameters return ConflictException with associated resourceIds. Tokens are resettable state.

Shared /__admin provides health, UI, state, reset, Timeline checkpoints, clock, journal and metrics. Namespace carriers: x-mockingbird-namespace, /__admin/ns/name and SigV4 access-key mappings via PUT /__admin/credentials. Signature verification and IAM policy evaluation are not performed. Journal entries omit bodies and credentials. No webhooks are emitted. Presets: access_denied (AWS 400), throttled (400), rate_limited (explicit HTTP 429 test fault), internal_error (500), connection_drop. Shared faults also support deterministic latency.

Verification

bun test runs acceptance and OpenAPI-driven self-parity with divergence detection. bun scripts/sdk.ts uses uv to install and run exact boto3 1.43.56 against the served emulator: successful RunTask, preserved overrides, idempotency, missing resources and SDK exceptions. This proves SDK compatibility, not live AWS equivalence. bun run parity exits 2 because this package only models a billable compute-creating operation; no live request is issued implicitly. Live validation needs an authorized isolated ECS account/cluster and explicit execution approval.

Deliberately not modelled

Real container execution, task lifecycle progression, eventual consistency, network provisioning, IAM/signature evaluation, infrastructure deployment, EC2/EXTERNAL/capacity-provider launch modes, task-definition or cluster mutations and other ECS operations. Nested overrides outside names, commands and environment are passed through, not comprehensively validated. No subnet reachability, image validity or resource-capacity simulation. Fargate is the only modeled launch type. Task ids and platformVersion LATEST are local stand-ins, not exact AWS-generated ids/resolved versions. The idempotency lifetime is 24 hours while emulator tasks remain uncompleted; shorter post-stop expiry and task-stop response rewriting are outside this surface.

API

Main runtime exports: ECSAPI, ECS_NAMESPACE, DEFAULT_CLUSTER, DEFAULT_TASK_DEFINITION, createRuntime, ECS_PRESETS, document, operationIds, supportedOperationIds. Types: Cluster, TaskDefinition, Failure, Task, ECSAPIOptions, ECSRuntimeOptions, ECSRuntime. Server entry: createServer, DEFAULT_PORT, serveTarget; type ECSServerOptions. CLI entry executes serve and exports no runtime values.

版本与发布记录

@crvouga/mockingbird-service-ecs 共发布 22 个版本,首次发布于 2026/10/05;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.11.0latest2026/11/11今天
1.10.92026/11/038 天前
1.10.82026/11/038 天前
1.10.72026/11/038 天前
1.10.62026/11/038 天前
1.10.52026/11/038 天前

关于 @crvouga/mockingbird-service-ecs 的常见问题

@crvouga/mockingbird-service-ecs 是什么?

AWS ECS Fargate RunTask acceptance and failure emulator.

如何安装 @crvouga/mockingbird-service-ecs?

在项目目录运行 npm install @crvouga/mockingbird-service-ecs,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-ecs,可以用 npx mockingbird-ecs 直接运行。

@crvouga/mockingbird-service-ecs 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crvouga/mockingbird-service-ecs 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@crvouga/mockingbird-service-ecs 可以商用吗?

@crvouga/mockingbird-service-ecs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crvouga/mockingbird-service-ecs 的下载量有多少?

根据 npm 官方下载统计,@crvouga/mockingbird-service-ecs 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,020 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crvouga/mockingbird-service-ecs 还在维护吗?

最新版本 1.11.0 发布于 2026/11/11(今天);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。