Skip to content

feat(ci): weekly workflow moves the bootstrap's pinned AWS CLI by PR (#1495) - #1501

Merged
scttfrdmn merged 4 commits into
mainfrom
feat/1495-awscli-pin-bump
Nov 2, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
feat/1495-awscli-pin-bump

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1495

What

A weekly scheduled workflow, .github/workflows/awscli-pin.yml, moves the AWS CLI v2 pin that the Linux bootstrap installs (awsCLIVersion, awsCLISHA256x86_64 and awsCLISHA256aarch64 in pkg/launcher/bootstrap.go, from #1490) by opening a PR when a newer release exists. This PR does not move the pin, and the published bootstrap body is unchanged. go run . bootstrap-body | sha256 gives 63421a2d…3d23 both before and after, the v0.155.0 value. The only change to bootstrap.go is in the Go comment above the constants.

Design

  • scripts/bump-awscli-pin.sh does the work, in this order:
    1. Key: imports scripts/awsclipin/aws-cli-team.asc into a throwaway GNUPGHOME and requires exactly one primary key, readonly AWSCLI_KEY_FPR=FB5DB77FD5C118B80511ADA8A6310ACC4672475C. It fails the run while the key is expired or within 60 days of its expiry. This check runs first, so a week with no new release still goes red.
    2. Version source: the newest 2.N.N tag of github.com/aws/aws-cli, read with git ls-remote. It needs no token and has no API rate limit, and AWS tags every v2 release there; the public CHANGELOG.rst is built from the same history. The tag is never trusted for the bytes. It only names the version to fetch, and only a version newer than the pin (sort -V) and of the form 2.x is accepted, so it cannot downgrade the pin. If a tag's zip is not uploaded yet (HTTP 403/404), the run logs a ::warning:: and the next week's run retries.
    3. Bytes: downloads both zips and their .sig files and runs gpg --verify. It also requires a VALIDSIG status line whose primary-key fingerprint is the pinned one, because a good signature alone is not enough. Then it computes the sha256s.
    4. Edit: scripts/awsclipin (Go, in the scripts module) rewrites the three constants by name with go/parser. Each must be declared exactly once as a string literal, or the tool fails. It also adds a ### Changed entry under ## [Unreleased], because the bump changes the published bootstrap body; the entry includes the deploy-the-orchestrator note.
  • Workflow: permissions: {} at the top level, and contents: write, pull-requests: write and issues: write on its single job. It uses only GITHUB_TOKEN. Actions are SHA-pinned (checkout v7.0.1 and setup-go v7.0.0, both already in scripts/action-pins.txt), with cache: false on setup-go in this write-token job. The workflow does no curl itself, so TestWorkflowsVerifyWhatTheyDownload does not apply. The script's downloads are verified with gpg rather than sha256sum -c, because a new release's hash cannot be known in advance, and nothing downloaded is ever executed. A rerun skips a branch (bot/awscli-<version>) that already exists.
  • End-to-end run (local): with awsCLIVersion set back to 2.39.2, the script picked 2.39.3, verified both signatures and computed exactly the two sha256s bootstrap: INSTANCE_ID is empty on Ubuntu (no ec2-metadata), so every tag read and the --command once-marker use an empty ID #1490 committed by hand. It restored bootstrap.go byte for byte, leaving only the CHANGELOG entry. With the real pin it prints AWS CLI pin 2.39.3 is current. A temporary WARN_DAYS=300 gave ::error:: ... expires in 241 days with rc=1, and now set past expiry gave ... expired with rc=1.

Refused PRs fall back to an issue

gh api repos/spore-host/spawn/actions/permissions/workflow returns can_approve_pull_request_reviews: false for both org and repo, so GitHub refuses PR creation by GITHUB_TOKEN.

  • After pushing bot/awscli-<version>, the run tries gh pr create. If gh's output is GitHub's refusal (not permitted to create or approve pull requests, matched by go -C scripts run ./awsclipin pr-refused), the run opens an issue titled AWS CLI pin bump available: <old> → <new>, or updates the open one with that exact title. The issue holds the compare link, the verified version, both sha256s and the signing fingerprint, plus a note that the owner opens the PR from the link.
  • Any other gh failure fails the run with ::error::. So does a failed push (the step's bash -e) or a signature that does not verify (the bump script).
  • The job's permissions are now exactly contents: write, pull-requests: write and issues: write. The workflow-level permissions are still {}.
  • A PR that does get opened with GITHUB_TOKEN does not trigger CI. Close and reopen it to run the checks.
  • The key expires 2027-07-01. Follow-up: AWS CLI signing key expires 2027-07-01: replace scripts/awsclipin/aws-cli-team.asc before the weekly pin workflow goes red (~2027-05-02) #1500.

Gates and revert evidence

Every revert below compiled (go vet was clean), and the gate failed against it:

  • The rewrite targets the constants that exist (TestPinConstantsExistInBootstrap, TestBumpCoversEveryAWSCLIPin, TestRewriteChangesOnlyThePins). The tests read the real pkg/launcher/bootstrap.go. The coverage test discovers every awsCLI* string const in pkg/launcher whose value is a 2.N.N or a sha256, and requires the set to equal what the bump moves.
    • Renaming awsCLISHA256aarch64 to awsCLISHA256arm64 across pkg/launcher: 3 tests fail (no const awsCLISHA256aarch64: the bump would move nothing, const awsCLISHA256arm64 = "f6eb…" looks like an AWS CLI pin the bump does not move).
    • Adding a fourth constant, awsCLISHA256riscv64: found 4 AWS CLI pin constants in pkg/launcher, want 3.
    • Making the rewrite a no-op (range order[:0]): after rewrite awsCLIVersion = "2.39.3", want "2.40.1", and the same for both sha256s.
  • The key file's fingerprint is the pinned one (TestCommittedKeyIsTheAWSCLITeamKey). The fingerprint is computed in Go (RFC 4880 v4: SHA-1 over 0x99, the length and the key packet), so the test needs no gpg and runs anywhere. The expected value is written out in the test, so changing the constant cannot satisfy it.
    • Swapping the file for a throwaway RSA key: fingerprint = 2762EB6C9A0AD57A992901654F2DCE5E078DEA6E, want FB5DB77F…. That is also the fingerprint gpg printed for that key, an independent check of the Go implementation.
  • The script pins the same fingerprint (TestBumpScriptPinsTheSameFingerprint). It matches the readonly AWSCLI_KEY_FPR= assignment, not the bare value.
    • Changing one hex digit: bump-awscli-pin.sh pins FB5DB77ED5…, want FB5D B77F ….
  • Fallback decision (TestPRRefusedOnlyForGitHubsRefusal, TestPRRefusedSubcommand, TestFallbackIssueHoldsTheVerifiedPin). GitHub's refusal text falls back. Other errors (a 401, Resource not accessible by integration, no commits, PR already exists, a network error, a different "not permitted to push" message) do not. The issue body must contain the compare link, the version, both sha256s and the fingerprint, and a body with a missing hash, swapped hashes or no compare link is refused.
    • prRefused returning true always: prRefused("HTTP 401: …") = true: a real failure would open an issue.
  • Workflow wiring (TestAWSCLIPinWorkflowRunsTheBumpWithOnlyPRPermissions; it also requires gh issue create/edit to come after the anchored pr-refused check, whose else-branch must exit 1), root module, read as YAML with comment lines dropped). It checks that the workflow has a schedule, {} at the top level, exactly one job invoking the script, that job's permissions exactly contents: write and pull-requests: write, and no secrets..
    • Changing the step to run: echo scripts/bump-awscli-pin.sh: 0 jobs run scripts/bump-awscli-pin.sh, want 1.
    • Adding actions: write, or dropping issues: write: permissions = …, want exactly map[contents:write issues:write pull-requests:write].
    • Removing exit 1 from the non-refusal branch, or replacing the pr-refused check with if false: opens an issue without first checking awsclipin pr-refused and failing otherwise.
  • The changelog insertion is tested against an empty Unreleased section, one that already has a Changed group, one with Fixed only, one with Added only, and the real CHANGELOG.md. Each must have exactly one Changed group holding the entry, placed before Fixed, and the only difference from the input must be one inserted block.

internal/iamcoverage's TestEveryMainPackageIsAPrincipal now lists scripts/awsclipin as a non-principal, because it calls no AWS API.

Checks

These pass:

  • make check, run from /private/tmp.
  • make lint: 0 issues in all 10 modules.
  • semgrep scan --config=auto --error ., with one bare // nosemgrep above the SHA-1 call. SHA-1 is what defines a v4 PGP fingerprint.
  • actionlint .github/workflows/awscli-pin.yml: clean. Run over all workflows, actionlint reports one SC2001 style note in ci.yml:98, which is already there on main.
  • shellcheck scripts/bump-awscli-pin.sh
  • scripts/refresh-action-pins.sh --check

@scttfrdmn
scttfrdmn force-pushed the feat/1495-awscli-pin-bump branch from 6af65f7 to c622037 Compare November 2, 2026 19:23
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit b1b1b41 into main Nov 2, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the feat/1495-awscli-pin-bump branch November 2, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bootstrap: nothing moves the pinned AWS CLI version/sha256 the Linux bootstrap installs

1 participant