Skip to content

Approval-gated CI deploy of code-only Lambda changes after a release (OIDC role, production environment) #1445

Closed

Description

@scttfrdmn

Split from #1444, part 2. The design was approved by the owner on 2026-10-30.

Approval-gated deploy of code-only Lambda changes after a release.

  • A workflow job runs after the release job is green, behind a GitHub production environment that requires the owner's review. The deploy is one click on the component list from Release does not deploy the operated Lambdas: detect which components a release changed, and auto-deploy code-only changes #1444; it never runs unattended.
  • Credentials: an OIDC role in 966362334030 only, trusted solely for repo:spore-host/spawn:environment:production, from the GitHub OIDC provider. Permissions:
    • lambda:UpdateFunctionCode, GetFunctionConfiguration, TagResource and ListTags on the named operated functions;
    • s3:GetObject for the bootstrap-body check;
    • no IAM, CloudFormation, event-source mapping or stack-parameter changes.
    • It must respect the account trust boundary: nothing referencing any other account.
  • The pipeline orchestrator gets code-only updates directly on the function (not sam deploy, which would need CloudFormation execute rights and iam:PassRole). The stack is used only when its parameters change, and that stays manual. Note that SAM drift is then the expected state for Code and must be documented.
  • Verification, each step failing the job:
    • CodeSha256 equals the built zip;
    • the config diff against a pre-deploy snapshot is empty;
    • spawn:version is stamped;
    • the deploy record is posted on the release PR.
  • Stays manual, flagged by Release does not deploy the operated Lambdas: detect which components a release changed, and auto-deploy code-only changes #1444: role scripts, inline policies, event-source mappings, template parameters.

Creating the OIDC role is a live IAM change: simulate it allow and deny, plus one real PutRolePolicy. It is done by hand with owner confirmation, not by CI.

Activity

  1. added this to the v0.152.0 milestone on Oct 30, 2026
  2. added
    enhancement
    on Oct 30, 2026
  3. scttfrdmn commented on Oct 30, 2026

    @scttfrdmn
    ContributorAuthor

    CI deploy role created (2026-10-30), owner-approved

    The role half shipped in #1449 (merged as 894f731). The workflow half of this issue is still to do.

    1. GitHub environment production (spore-host/spawn), created before the role:

      • required reviewer scttfrdmn;
      • can_admins_bypass: false;
      • deployment policy: tags v* only.

      The repo uses the default OIDC subject format (use_default: true), so a job in this environment presents sub = repo:spore-host/spawn:environment:production.

    2. Dry run of scripts/setup-lambda-deploy-ci-role.sh through a recording shim captured the exact trust and policy documents. simulate-custom-policy on that policy, 20 cases, all as intended:

      • 6 allow: UpdateFunctionCode on sweep-orchestrator, ttl-reaper and scheduler-handler; GetFunctionConfiguration; TagResource with the spawn:* keys.
      • 14 deny:
        • UpdateFunctionCode on spore-bot, on lagotto-capacity-poller, and on the same function name in us-west-2;
        • UpdateFunctionConfiguration, UntagResource, CreateFunction, AddPermission, PublishVersion;
        • TagResource with a non-spawn key, and on a non-operated function;
        • iam:PutRolePolicy, iam:PassRole, DeleteEventSourceMapping, cloudformation:ExecuteChangeSet.
    3. Real run from main (the script is byte-identical to the dry-run copy): created role GitHubActions-spawn-lambda-deploy, put inline policy DeployOperatedLambdaCode (9 functions). That PutRolePolicy is the real one.

    4. Live verification:

      • the trust and inline policy read back from IAM are identical to the dry-run documents;
      • MaxSessionDuration 3600;
      • tags spawn:managed/purpose/created-by;
      • no attached policies, one inline policy.

      simulate-principal-policy on the live role, 9 cases, all as intended. Allowed: UpdateFunctionCode on sweep-orchestrator and dns-updater, TagResource with spawn:* keys, ListTags. Denied: spore-rest-api, UpdateFunctionConfiguration, a non-spawn tag key, iam:PutRolePolicy, sts:AssumeRole into another account.

    Deleter: AWS_PROFILE=spore-host-infra scripts/setup-lambda-deploy-ci-role.sh --delete.

    Not yet exercised: an actual AssumeRoleWithWebIdentity from a workflow run. That happens with the first run of the deploy job (the remaining half of this issue).

  4. scttfrdmn commented on Oct 31, 2026

    @scttfrdmn
    ContributorAuthor

    First live dry run: v0.152.0 (2026-10-31), then LAMBDA_DEPLOY_MODE=live

    Release run 41153565390. The owner instructed the approval; I approved the production deployment at 04:43Z. The record is posted on #1455.

    Record: DRY RUN (nothing was changed).

    • Targets: spawn-pipeline-orchestrator and spawn-sweep-orchestrator, both code-only through pkg/aws.
    • Before SHAs 47CKmNc9… and JvlMv3fs…. These are exactly what the manual v0.151.0 deploy left (record on Release v0.151.0 #1440).
    • Built pKFMXwHf… and YUR4m3e4….
    • Bootstrap body for v0.152.0 verified (925521a3…).
    • The SAM drift note is present on pipeline-orchestrator.
    • Not deployed: 7 unchanged Lambdas, plus setup-lambda-deploy-ci-role.sh as manual (already applied).

    Independent verification:

    • Live state: both functions' CodeSha256, LastModified (2026-10-30 14:3x, the manual deploy) and spawn:version=0.151.0 are unchanged.
    • CloudTrail, every event for user deploy-lambdas: 2× GetFunctionConfiguration, 2× GetFunction, 1× GetCallerIdentity, 4× KMS Decrypt (Lambda returning function details). All ReadOnly=true. Zero UpdateFunctionCode and zero TagResource.
    • First real AssumeRoleWithWebIdentity: role GitHubActions-spawn-lambda-deploy, subject repo:spore-host/spawn:environment:production, no error.

    Result: LAMBDA_DEPLOY_MODE=live was set at 2026-10-31T04:48Z. From the next release on, the approved deploy job ships code-only changes for real.

    Note: this dry run deployed nothing. Both orchestrators still run v0.151.0 code until either a workflow_dispatch of deploy-lambdas.yaml on v0.152.0 with dry_run=false (needs approval) or the next release.

  5. scttfrdmn commented on Oct 31, 2026

    @scttfrdmn
    ContributorAuthor

    First LIVE CI deploy: v0.152.0 (2026-10-31)

    The owner dispatched deploy-lambdas.yaml on v0.152.0 with dry_run=false and approved it in production: run 41170756282, success.

    Function CodeSha256 before → after (= built) Config diff spawn:version
    spawn-pipeline-orchestrator 47CKmNc9… → pKFMXwHf… empty 0.151.0 → 0.152.0
    spawn-sweep-orchestrator JvlMv3fs… → YUR4m3e4… empty 0.151.0 → 0.152.0

    Independent verification:

    • Builds: identical to the dry run's builds, so they are reproducible.
    • Config: compared against snapshots I took before dispatch, excluding code and update-status fields: zero drift. RuntimeVersionConfig is unchanged. Both functions are Active/Successful.
    • Tags: the other spawn:* tags are untouched.
    • CloudTrail, every deploy-lambdas event since 05:00Z: per function, exactly 1 UpdateFunctionCode and 1 TagResource, plus GetFunction×2, GetFunctionConfiguration×4, GetCallerIdentity, and KMS Decrypt (Lambda returning details). No errors, and no call on any other function.
    • Bootstrap body for v0.152.0 verified, and verify-spored.sh 0.152.0: fail=0 across 231 objects.
    • Expected drift: stack spawn-pipeline-orchestrator still has Version=0.151.0. The next make -C lambda/pipeline-orchestrator deploy reconciles it.

    This was the deployer's first real write path. Rollback was not exercised, because nothing failed. Release-triggered deploys are live from v0.153.0 on (LAMBDA_DEPLOY_MODE=live).

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

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions