Skip to content

No check that a deploy script grants IAM to the role its function actually uses #860

Open

Description

@scttfrdmn

Found while fixing #835. scripts/deploy-custom-dns.sh created and granted permissions to SpawnDNSLambdaRole:

$ aws iam get-role --role-name SpawnDNSLambdaRole
An error occurred (NoSuchEntity): The role with name SpawnDNSLambdaRole cannot be found.

$ aws lambda get-function-configuration --function-name spawn-dns-updater \
    --region us-east-1 --query Role --output text
arn:aws:iam::966362334030:role/SpawnDNSLambdaExecutionRole

So every put-role-policy the script made went to a role it had just created for the purpose and nothing used, while the function kept running under a different role whose policies exist only in the account. The script reported success either way, and the create path would have attached the wrong role to a fresh function.

Fixed for that one script in #858. Nothing detects the next one. This is the IAM-side twin of #790's "reconstructing an identifier from a convention": a role name in a script is an assertion about the live account, and nothing checks it.

Why CI can't gate it

The property is a comparison against live AWS, so it belongs with scripts/lambda-deploy-census.sh and make lambda-versions-deployed rather than in make check.

Proposed check

For each lambda-deploying script, discovered rather than listed (per rule 4, failing on an empty discovery):

  1. extract its FUNCTION_NAME default and its ROLE_NAME / ROLE_ARN;
  2. read the live function's Role;
  3. report any mismatch, and any role name the script references that does not exist.

It would also catch the inverse — a role that exists, is granted to, and is attached to nothing.

Scope note

A quick scan suggests this is worth running across all of scripts/ and lambda/*/deploy.sh before writing the checker, since the count of affected scripts is unknown; deploy-custom-dns.sh is simply the one that surfaced. Not measured yet — deliberately not claiming a number here.

Activity

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

    @scttfrdmn
    ContributorAuthor

    Measured, filling the scope note. 1 of 8 was wrong, and #858 fixed it — so this checker is purely preventive, not a cleanup. Adjusting the priority down accordingly.

    Discovery: every *.sh under scripts/, lambda/ and deployment/ containing aws lambda create-function or update-function-code (8 scripts), each script's ROLE_NAME compared against the live function's Role:

    script function role in script live role verdict
    lambda/dashboard-api/deploy.sh spawn-dashboard-api SpawnDashboardLambdaRole SpawnDashboardLambdaRole ok
    lambda/dashboard-api/scripts/deploy.sh spawn-dashboard-api (none) SpawnDashboardLambdaRole ok
    lambda/dashboard-websocket-processor/deploy.sh spawn-dashboard-websocket-processor SpawnDashboardLambdaRole SpawnDashboardLambdaRole ok
    lambda/dashboard-websocket/deploy.sh spawn-dashboard-websocket SpawnDashboardLambdaRole SpawnDashboardLambdaRole ok
    scripts/deploy-cost-history-collector.sh spawn-cost-history-collector SpawnDashboardLambdaRole SpawnDashboardLambdaRole ok
    scripts/deploy-custom-dns.sh spawn-dns-updater SpawnDNSLambdaExecutionRole SpawnDNSLambdaExecutionRole ok (after #858; was SpawnDNSLambdaRole, nonexistent)
    scripts/deploy-scheduler-handler.sh scheduler-handler SpawnSchedulerHandlerExecutionRole SpawnSchedulerHandlerExecutionRole ok
    scripts/deploy-sweep-orchestrator.sh spawn-sweep-orchestrator SpawnSweepOrchestratorRole SpawnSweepOrchestratorRole ok

    A methodology note, because it nearly went in the issue as fact: my first pass used grep -oE and reported one MISMATCH and one ROLE MISSING that were both artefacts of my own parsing — a trailing } left on ${SPAWN_LAMBDA_ROLE:-SpawnDashboardLambdaRole} and several FUNCTION_NAME values unresolved, which rendered as (no such function). Both looked exactly like real findings. The checker this issue proposes has to resolve ${VAR:-default} properly, and anything it reports as absent needs confirming by a second route before anyone acts on it.

    Two things the table shows that are worth keeping:

  3. modified the milestones: Later, Hardening on Nov 8, 2026
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions