Skip to content

spawn-pipeline-orchestrator's CloudFormation template is not in the repo #754

Closed

Description

@scttfrdmn

Found while deploying #752's fix to that Lambda.

What

spawn-pipeline-orchestrator is a live CloudFormation stack in the infra account
(UPDATE_COMPLETE, last updated 2026-01-30) managing four resources:

PipelineOrchestrationTable        AWS::DynamoDB::Table
PipelineOrchestratorLogGroup      AWS::Logs::LogGroup
PipelineOrchestratorFunction      AWS::Lambda::Function   (arm64, provided.al2023)
PipelineOrchestratorFunctionRole  AWS::IAM::Role

There is no template for it anywhere in the repo. The only pipeline-ish YAML
is examples/workflow-ci-pipeline.yaml, which is an unrelated user-facing
example. So the infrastructure definition for a production Lambda, its IAM role
and its DynamoDB table exists only inside AWS.

Why it matters

  • Unreviewable. No PR has ever shown a change to that role's permissions or
    the table's configuration, because there is no file to diff.
  • Unreproducible. If the stack is deleted or the region is lost, the only
    recovery path is reconstructing it from describe-stacks output.
  • It nearly caused a silent revert. The template pins the function's Code
    to a fixed S3 object:
    S3Bucket: spawn-pipelines-us-east-1
    S3Key:    0c1e7fa6cac480d1a5910327d6122446
    
    An aws lambda update-function-code — the obvious way to ship a code fix, and
    what the sibling spawn-sweep-orchestrator script does — would have worked and
    then been silently reverted by the next CFN update of this stack. I only
    avoided that because the role name looked CloudFormation-generated and I
    checked.

I deployed #752's fix by retrieving the live template, swapping the S3Key, and
executing a change set that showed exactly one in-place Modify touching only
Code. Drift detection afterwards: IN_SYNC, 0 drifted resources. That is the
right method, but it should not require pulling the template out of AWS each time.

Related

This is the same class as spawn-sweep-orchestrator, which has no stack at
all
— a hand-deployed Lambda whose only record is
scripts/deploy-sweep-orchestrator.sh. #731 hardened that script (account
assertion, no env wipe, CodeSha256 verification) but the function remains
undeclared infrastructure. Both are instances of the "leave no trace" note's
second open subject: nothing reaps the lambdas, their roles, or their tables,
partly because nothing declares them either.

Suggested fix

  1. Commit the template. aws cloudformation get-template returns the
    processed CFN, which is deployable as-is — good enough to version-control
    today, and honest about being a capture rather than hand-written SAM.
  2. Add a deploy script matching scripts/deploy-sweep-orchestrator.sh's
    post-fix(scripts): make the hand-written Lambda deploys safe and verifiable #731 discipline — assert the account, never pass Variables={} (this
    function carries ENVIRONMENT and SPAWN_PIPELINE_ORCHESTRATION_TABLE, so a
    wipe would break it), build arm64 (its sibling is x86_64 — easy to get
    wrong), upload under a dated key, and update via change set rather than
    update-function-code.
  3. Consider a gate: a test asserting every Lambda directory under lambda/
    has either a committed template or a committed deploy script. There are 12
    nested modules and at least two have neither.

(3) is the durable part. The first two fix these two functions; the gate stops
the next one shipping undeclared.

Activity

  1. added
    bug
    on Oct 8, 2026
  2. scttfrdmn commented on Oct 8, 2026

    @scttfrdmn
    ContributorAuthor

    Correction: the template is in the repo. The real bug is three Makefile targets that name a function that does not exist.

    I filed this and the central claim is wrong. Verified today:

    lambda/pipeline-orchestrator/template.yaml (157 lines) is a SAM template
    (Transform: AWS::Serverless-2016-10-31) and it defines every live resource:

    live stack resource repo template
    PipelineOrchestrationTable AWS::DynamoDB::Table, same logical ID
    PipelineOrchestratorLogGroup AWS::Logs::LogGroup, same logical ID
    PipelineOrchestratorFunction AWS::Serverless::Function, same logical ID
    PipelineOrchestratorFunctionRole SAM-implicit, from the 7 entries under Policies:

    The role match is exact, not approximate: the live role carries
    PipelineOrchestratorFunctionRolePolicy0…Policy6 — SAM's generated naming —
    and the repo template has exactly 7 Policies: entries. It has no explicit
    RoleName
    (CFN-generated), so CAPABILITY_IAM is sufficient and the
    CAPABILITY_NAMED_IAM recorded on the stack is surplus, not a requirement.

    There is also a deploy path — lambda/pipeline-orchestrator/Makefile:

    deploy: build
    	sam deploy --template-file template.yaml \
    	  --stack-name spawn-pipeline-orchestrator \
    	  --capabilities CAPABILITY_IAM \
    	  --parameter-overrides Environment=production --resolve-s3
    

    So "unreviewable" and "unreproducible" are both false. My search missed it
    because nothing in the path or filename says pipeline except the directory,
    and I grepped for pipeline-ish YAML.

    What is actually broken

    Three targets name spawn-pipeline-orchestrator-production, which does not exist.
    The template sets FunctionName: spawn-pipeline-orchestrator — no suffix:

    • Makefile:51 update-code → aws lambda update-function-code --function-name spawn-pipeline-orchestrator-production
    • Makefile:56 logs → aws logs tail /aws/lambda/spawn-pipeline-orchestrator-production
    • Makefile:61 invoke-test → --function-name spawn-pipeline-orchestrator-production

    Verified against the infra account: list-functions returns only
    spawn-pipeline-orchestrator; get-function …-production is a
    ResourceNotFoundException; the only log group is
    /aws/lambda/spawn-pipeline-orchestrator. None of those three targets has ever
    worked.
    The mistake is confined to this Makefile (ttl-reaper and
    autoscale-orchestrator use deploy-production as a target name, which is
    unrelated).

    This also corrects the "it nearly caused a silent revert" paragraph above. The
    conclusion was right for the wrong reason: make update-code would not have
    worked-then-been-reverted, it would have failed outright on the wrong name.
    A correctly-named update-function-code would be reverted by the next
    sam deploy, so the method I used was still the right one.

    Two smaller traps

    packaged.yaml is committed, dated May 29, and was never packaged. It still
    has Transform and AWS::Serverless::Function and carries no S3 pin at all,
    so it is a stale copy of template.yaml wearing the name of a deploy artifact.
    The S3Bucket: spawn-pipelines-us-east-1 / S3Key: 0c1e7fa6… I quoted in the
    issue body came from the live stack, not from this file.

    The live stack's template is now the expanded form. get-template --template-stage Original returns no Transform and an explicit
    AWS::Lambda::Function + AWS::IAM::Role — because my #752 deploy retrieved
    the live template, swapped the S3Key, and submitted that. The same deploy
    replaced SAM's content-hashed key with a hand-named one
    (pipeline-orchestrator-20261008082158.zip). So get-template and the repo now
    disagree in form, though not in substance.

    Re-converging with make deploy should be a no-op on resources — all four
    logical IDs are identical, so SAM re-expands onto the same ones with no
    replacement — but that is a prediction, and this stack is production. It gets
    proven with sam deploy --no-execute-changeset and a read of the change set
    before anything executes.

    Scope, revised

    • fix the three -production function/log-group names
    • remove the stale packaged.yaml (it is not an input to any target)
    • converge the live stack back to the SAM form, change-set-reviewed first
    • commit the missing template — already present

    Stack snapshot for the record: UPDATE_COMPLETE, last updated
    2026-10-08T15:22:39Z, Environment=production the only parameter, no stack tags.

  3. scttfrdmn commented on Oct 8, 2026

    @scttfrdmn
    ContributorAuthor

    Correcting one claim in my comment above: packaged.yaml was genuinely
    sam packaged.
    I said it "carries no S3 pin at all" — it does:

    CodeUri: s3://spawn-pipelines-us-east-1/45e91af14a5ec3a062876f030fc2d549

    My grep looked for S3Key/S3Bucket, which is the expanded form. A packaged
    SAM template keeps AWS::Serverless::Function and rewrites CodeUri to an
    s3:// URL, so the pin was there and I looked for the wrong key.

    What survives: the file is from May 29, its object hash matches neither the
    0c1e7fa6… in the issue body nor the key now live
    (pipeline-orchestrator-20261008082158.zip), and nothing in the repo
    references it
    — --resolve-s3 means make deploy repackages every time. So it
    is a superseded build artifact that reads like an input, and removing it is still
    the right call; my reason for it was just wrong.

    The rest of the comment stands as verified.

  4. scttfrdmn commented on Oct 8, 2026

    @scttfrdmn
    ContributorAuthor

    Makefile fix merged in #762 (4dc05f5): the three -production names now resolve to spawn-pipeline-orchestrator from a single definition, update-code warns that make deploy reverts it, and the stale packaged.yaml is gone.

    Remaining, and the reason this stays open: the live stack still carries the expanded, Transform-less template. Converging it back to the SAM form needs a sam deploy --no-execute-changeset and a read of the change set before anything executes, because it is production. Expected result is zero resource changes — the four logical IDs are identical, so SAM re-expands onto the same resources — but that is a prediction, not a verification.

  5. scttfrdmn commented on Oct 8, 2026

    @scttfrdmn
    ContributorAuthor

    Converged. The live stack is SAM-form again, change-set reviewed.

    Method: sam deploy --no-execute-changeset → read the change set → execute.

    The change set was not what I predicted

    I said to expect zero resource changes. There were three — and the summary
    table alone would have been misleading, because a Metadata-scope modification
    on a production DynamoDB table looks exactly like a dangerous one until you read
    the scope:

    resource scope RequiresRecreation
    PipelineOrchestrationTable Metadata only Never
    PipelineOrchestratorLogGroup Metadata only Never
    PipelineOrchestratorFunction Metadata + Properties: Code Never

    The Metadata entries are SAM re-annotating resources with its own SamResourceId
    — the signature of restoring the Transform. No table property was touched: no
    billing mode, no key schema, no PITR. Replacement: False throughout.

    PipelineOrchestratorFunctionRole does not appear in the change set at all.
    That is the cleanest available proof that template.yaml's 7 Policies: entries
    reproduce the deployed role exactly — the thing this issue claimed was
    unreviewable because no file existed to diff.

    Before → after

    check before after
    template form expanded, no Transform Transform: AWS::Serverless-2016-10-31 + AWS::Serverless::Function
    drift IN_SYNC, 0 drifted IN_SYNC, 0 drifted
    parameters Environment=production unchanged
    capabilities IAM + NAMED_IAM IAM
    physical IDs (all 4) — identical, incl. role suffix yOhTwpzmumP5
    DynamoDB 3 items, PITR ENABLED 3 items, PITR ENABLED, original 2026-01-30 creation date
    function CodeSha AQnWWWKx… /ad06i8RU…, State: Active, LastUpdateStatus: Successful

    Capabilities dropping NAMED_IAM is expected and harmless — the role sets no
    explicit RoleName, so CAPABILITY_IAM is sufficient; the extra was surplus
    recorded by an earlier deploy.

    The deployed package was verified byte-for-byte, not assumed: downloaded via
    get-function, one entry (bootstrap), sha256 identical to the local build.

    This also shipped #755, unavoidably

    sam deploy always repackages, and the running code predated #755 — that commit
    landed 16:30Z, the function's code was attached 15:22Z. So the convergence
    necessarily carried #755's change to this Lambda, which is this:

    -  Tags: []ec2types.Tag{
    -    {Key: aws.String("spawn:pipeline-id"), ...},
    -    {Key: aws.String("Name"), ...},
    -  }
    +  Tags: append(spawnaws.LifecycleTags(sgName, "pipeline", time.Now()),
    +    ec2types.Tag{Key: aws.String("spawn:pipeline-id"), ...})

    Until now this Lambda created security groups and placement groups with no
    spawn:managed tag
    , so the reaper was not permitted to touch them — its delete
    grants are conditioned on that tag. It was an active source of uncollectable
    orphans. Confirmed live in the deployed binary (grep -a): spawn:created,
    spawn:managed and spawn:reaper-first-seen are all compiled in.

    Closing. The Makefile fix landed in #762; make deploy is now the documented and
    exercised path, and get-template and the repo agree again.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions