feat(ecs): awslogs -> CloudWatch Logs + EventBridge task state change#727
Merged
vieiralucas merged 1 commit intomainfrom Apr 24, 2026
Merged
feat(ecs): awslogs -> CloudWatch Logs + EventBridge task state change#727vieiralucas merged 1 commit intomainfrom
vieiralucas merged 1 commit intomainfrom
Conversation
Batch 2 of the ECR+ECS tightening pass. Closes the two deferred ECS observability integrations from last week so tasks are actually debuggable without `docker logs` and so downstream rules can react to task lifecycle events end-to-end. - New `fakecloud_logs::ingest` helper appends events directly into `SharedLogsState`, creating the group + stream on demand. Same-process call path — no `AwsRequest`/HTTP round-trip — so ECS can forward synchronously after a task exits. - `EcsRuntime` gains two optional builder methods: `with_delivery_bus` and `with_logs`. Left unwired a runtime behaves exactly as before (test-friendly) — with them wired, every state transition emits `aws.ecs` / `ECS Task State Change` on the default bus and every task whose container definition declares `logDriver=awslogs` has its captured stdout/stderr streamed into the corresponding log group. - The EventBridge detail payload matches AWS's task-state-change shape: `taskArn`, `clusterArn`, `launchType`, `group`, `taskDefinitionArn`, `lastStatus`, `desiredStatus`, `stopCode`, `stoppedReason`, and a `containers` array with `exitCode` / `reason`. Rules matching `source: aws.ecs` get the same fan-out treatment as S3 / SES events via the existing `EventBridgeDelivery` trait. - Server rewires `EcsRuntime` construction to happen after the delivery bus setup so it can inject both the EventBridge delivery and the shared logs state. - Two new E2E tests cover the loop end-to-end: `awslogs_forwards_to_cloudwatch` (runs a task, asserts captured stdout appears via `GetLogEvents`) and `state_change_emits_eventbridge` (puts a rule -> SQS target, runs a task, asserts an SQS message with `lastStatus=STOPPED` for the right task ARN). - Docs updated to call out both integrations and the expected `logConfiguration` shape.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch 2 of the ECR+ECS tightening pass. Closes the two deferred ECS observability integrations from last week.
logDriver=awslogsstream captured stdout/stderr into fakecloud-logs via a newfakecloud_logs::ingest::append_eventssame-process helper (no HTTP round-trip).source: aws.ecs/ECS Task State Changeevents on the default bus, with AWS-shaped detail (taskArn,clusterArn,lastStatus,stopCode, per-containerexitCode, ...). Reuses the existingEventBridgeDeliverytrait /DeliveryBuspattern (same as S3 notifications).EcsRuntime:with_delivery_bus+with_logs. Unwired runtime behaves exactly as before — keeps unit tests simple.ecs_observabilitytest file. One test runs a task withawslogsconfig and assertsGetLogEventsreturns the container stdout. Another puts an EventBridge rule -> SQS target and asserts the STOPPED event arrives for the right task ARN.website/content/docs/services/ecs.mddocuments both integrations and the expectedlogConfigurationshape.Test plan
cargo test -p fakecloud-logs --lib ingest— ingest helper unit tests passcargo test -p fakecloud-e2e --test ecs_observability— both E2E tests pass on local dockercargo test -p fakecloud-e2e --test ecs --test lambda --test ecr_cross_service— no regressionscargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanSummary by cubic
Adds CloudWatch Logs integration for ECS
awslogsand emits EventBridge task state change events. Tasks now stream container stdout/stderr to Logs, and lifecycle events can trigger EventBridge targets.awslogsoutput to CloudWatch Logs via same-processfakecloud-logs::ingest::append_events(auto-creates group/stream; visible viaDescribeLogStreams/GetLogEvents).aws.ecs/ "ECS Task State Change" events on the default EventBridge bus with AWS-shaped detail (task/container fields). Uses the existingDeliveryBuspattern; routes to SQS and other targets.EcsRuntimeaddswith_delivery_busandwith_logs. When unwired, behavior is unchanged.logConfigurationshape.Written for commit 9228bd6. Summary will update on new commits.