GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Feature request: Parser schema for `ECS Task State Change` EventBridge events · Issue #5927 · aws-powertools/powertools-lambda-typescript

Feature request: Parser schema for ECS Task State Change EventBridge events #5927

New issue
Copy link
New issue
Copy link
Closed
Feature
#5946
Closed
Feature request: Parser schema for ECS Task State Change EventBridge events#5927
Feature
#5946
Copy link
Assignees
svozza

Description

@garysassano
garysassano
opened on Nov 8, 2026
Issue body actions

Use case

Amazon ECS sends an ECS Task State Change event to EventBridge whenever a task changes state. A common pattern is a rule on stopped tasks that invokes a Lambda function to alert on, enrich, or record why the task stopped.

The Parser has EventBridgeSchema and EventBridgeEnvelope, but detail is z.unknown(), so each such function writes its own schema for the ECS payload. That is easy to get wrong, because the available sources disagree about which fields a stopped task's event has:

  • Docs: the two example events in the ECS developer guide, both RUNNING tasks.
  • Registry: the aws.ecs@ECSTaskStateChange schema in the EventBridge schema registry.
  • Real events: 7 stopped Fargate tasks captured in eu-central-1.
Field Docs Registry Real events
stopCode, stoppedReason, stoppedAt Not shown Optional Always
containers[].exitCode Not shown Optional Only when the container started
group Shown Optional Always
enableExecuteCommand, ephemeralStorage Shown Missing Always
capacityProviderName Shown Missing Absent for tasks run with launchType
computeId Not shown Missing Always

aws/containers-roadmap#2907 has the full comparison and asks ECS to document the fields and update the registry schema.

Solution/User Experience

A new packages/parser/src/schemas/ecs.ts, laid out like the Amazon Connect Outbound Campaigns schema (#5502), exporting:

Export Use
EcsTaskStateChangeDetailSchema The detail object, with EventBridgeEnvelope
EcsTaskStateChangeSchema The whole event: EventBridgeSchema.extend() with source: z.literal('aws.ecs'), 'detail-type': z.literal('ECS Task State Change'), and the detail
import { parse } from '@aws-lambda-powertools/parser';
import { EventBridgeEnvelope } from '@aws-lambda-powertools/parser/envelopes/eventbridge';
import { EcsTaskStateChangeDetailSchema } from '@aws-lambda-powertools/parser/schemas/ecs';

export const handler = async (event: unknown) => {
  const task = parse(event, EventBridgeEnvelope, EcsTaskStateChangeDetailSchema);
  if (task.lastStatus === 'STOPPED') {
    // task.stopCode, task.stoppedReason, task.containers[0]?.exitCode, ...
  }
};

Proposed field rules:

  • Required: the fields the registry schema requires, which every real event had: clusterArn, containers, createdAt, desiredStatus, lastStatus, overrides, taskArn, taskDefinitionArn, updatedAt, version.
  • Optional: everything else, including the stop fields, since a RUNNING task's event has none of them.
  • Timestamps: z.iso.datetime(), like EventBridgeSchema's time.
  • Unknown fields: a plain z.object(), not .strict(), so a field the schema doesn't list, such as computeId today, doesn't fail parsing.

Test events would be the two documented examples (Fargate and EC2) plus captured stopped-task events: an essential container that exited with code 1, an image that couldn't be pulled, and a secret that couldn't be fetched.

Because this would be the first schema for an AWS service event delivered through EventBridge rather than a direct Lambda trigger, it's worth agreeing where such schemas live before adding more. ECS Container Instance State Change and ECS Deployment State Change would be natural follow-ups in the same file.

I'm happy to open the PR once the approach is agreed.

Alternative solutions

  • A schema in each function, passed with EventBridgeEnvelope. It works, but repeats a field list that is easy to get wrong.
  • EventBridge code bindings (aws schemas get-code-binding-source). They generate TypeScript types from the registry schema, but give no runtime validation and inherit its missing fields.

Acknowledgment

  • This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
  • Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Activity

  1. dreamorosi
    assigned
    svozza
    on Nov 10, 2026
  2. dreamorosi
    added the
    Feature
    issue type on Nov 10, 2026
  3. dreamorosi
    closed this as completedin #5946on Nov 10, 2026
  4. powertools-for-aws-oss-automation commented on Nov 10, 2026

    @powertools-for-aws-oss-automation
    powertools-for-aws-oss-automationBot
    on Nov 10, 2026 – with Powertools for AWS - OSS Automation
    More actions

    Warning

    This issue is now closed. Please be mindful that future comments are hard for our team to see.
    If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

  5. powertools-for-aws-oss-automation
    added
    pending-releaseThis item has been merged and will be released soon
    on Nov 10, 2026
  6. powertools-for-aws-oss-automation
    removed
    pending-releaseThis item has been merged and will be released soon
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @svozza
    svozza

Labels

No labels
No labels

Type

Feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.