Skip to content

fix(cdk): agent stack template at 98.4% of the CloudFormation 1 MB limit #735

Closed

Description

@dreamorosi

Observed (live deploy, 2026-08-06, ADR-021 P2 smoke run)

With the Lambda MicroVMs backend + image configured, the synthesized backgroundagent-dev template measured 983,796 bytes of the 1,000,000-byte CloudFormation limit (98.4%) and 486 of 500 resources. Roughly one more construct of headroom before deploys start failing for reasons unrelated to whatever change triggers it.

Impact

Any feature adding a handful of resources (P3 suspend/resume wiring is next in line) can push the stack over either limit, failing deploys with confusing errors.

Proposal

  • Short term: measure per-construct contribution (cdk synth | wc -c bisection) and prune obvious weight (duplicated policy statements, verbose metadata)
  • Structural: split the stack (nested stacks or a second stack for optional backends), which also helps the 500-resource ceiling
  • Add a synth-time size/resource-count warning at e.g. 90% so the next increment is caught at build time, not deploy time

Found during ADR-021 P2 verification (#645); not MicroVM-specific.

Activity

  1. krokoko commented on Sep 21, 2026

    @krokoko
    Contributor

    The template-size remediation is included in #912, pending review and merge.

    All parent and nested templates now use compact JSON. The normal build enforces a shared 800,000-byte budget across 90 deployment profiles, including configured MicroVM images, Gateway, Registry, the Linear vault, and both network topologies. It also fails on CDK template-size warnings.

    The managed-Blueprint offline census measured a maximum application template of 709,799 bytes with inline networking and 655,784 bytes with split networking. All 90 profiles synthesized twice without differences; the final repository build passed real bundled synthesis and the full profile guard suite.

    #912 includes the measurements, reproduction command through the census task, and validation limitations, and will close this issue on merge.

  2. krokoko commented on Nov 20, 2026

    @krokoko
    Contributor

    Triage: this looks resolved on main.

    The template is no longer near the limit: on main at 3dbfada the offline census gives 631,226 bytes (63.1% of 1,000,000) and 439 resources for the Lambda MicroVM backend with a configured image, and 729,682 bytes and 482 resources for the widest inline profile. #854 (38ff380) removed the template indentation and 30 console test-invoke permissions, #912 (cd9bc54) made every template compact and added the optional network stack (networkTopology=split), and #904 (e4fbf8a) moved the MicroVM and scheduled-maintenance resources into nested stacks. The guard asked for here is in place: production synthesis fails above 490 resources per template (cdk/src/main.ts), and the build audits 142 deployment profiles against 490 resources and 800,000 bytes per template and fails on any CDK template-size warning (cdk/test/synthesis/deployment.test.ts, cdk/src/synthesis/budgets.ts); mise //cdk:census reproduces the measurements. The migration of existing inline stacks to the split topology and the remaining resource-count headroom are tracked in #852.

    Posted from an automated sweep of the open issues. Each pull request, commit and file named above was checked against main at 3dbfada1. The issue is left open for a maintainer to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions