Skip to content

feat: make runner AMIs private and single-region (us-east-2) - #89

Merged
kaio6fellipe merged 2 commits into
mainfrom
feat/private-single-region-ami
Jul 2, 2026
Merged

kaio6fellipe merged 2 commits into
mainfrom
feat/private-single-region-ami

Conversation

@kaio6fellipe

@kaio6fellipe kaio6fellipe commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

jit-runners is single-tenant (only we use it), so the public "community AMI" distribution and the second distribution region (us-east-1) added EBS-snapshot cost and Packer/CI complexity for no benefit. This makes runner AMIs private and built in us-east-2 only.

Changes

  • Packer (infra/packer/variables.pkr.hcl): ami_groups default ["all"] → [] (private). ami_regions stays [].
  • CI (.github/workflows/ami-build.yml): removed the distribute input, AMI_DISTRIBUTION_REGIONS, the block-public-access toggling, and the us-east-1 copy+publish steps. Non-PR builds now produce a private us-east-2 AMI; the post-build prune targets us-east-2 only. PR builds unchanged.
  • Prune (infra/scripts/ami-prune.sh): drop the is-public filter so it prunes the now-private AMIs by name prefix (the legacy --ensure-free/--quota public-quota options are retained but no longer used by CI).
  • Makefile: removed ami.build-distribute and ami.copy; ami.build is now private; ami.prune targets us-east-2 only. (GCP image.* targets untouched.)
  • Docs: docs/ami-prebaked.md, CLAUDE.md, README.md, docs/getting-started-aws.md, docs/troubleshooting.md updated to the private, single-region-by-design model.

Companion one-time AWS cleanup (already applied)

Converged the live account to match: 13 AMIs / 16 snapshots across us-east-1+us-east-2 → 2 private AMIs / 2 snapshots in us-east-2 (kept ami-03771658b57568961 live DefaultAMI + latest rollback). us-east-1 fully evacuated; block-public-access enabled in both regions as a guard. Live DefaultAMI verified intact.

Cost

Removes ongoing multi-region public-AMI snapshot retention and simplifies the build pipeline. Complements the broader jit-runners FinOps pass (t3 credit mode, spot diversification, instance-family right-sizing).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • AMI builds now stay private in us-east-2 instead of being copied and published across regions.
    • PR builds use a dedicated private AMI naming pattern and no longer set public sharing settings.
    • AMI cleanup now targets the current private AMI flow and runs only in us-east-2.
  • Documentation

    • Updated setup, build, troubleshooting, and AMI docs to match the new private-only build process.

Drop the public "community AMI" distribution and the us-east-1 copy.
jit-runners is single-tenant (only we use it), so publishing public AMIs
and maintaining a second distribution region only added EBS-snapshot cost
and Packer/CI complexity for no benefit.

- packer: ami_groups now defaults to [] (private); ami_regions stays []
- ami-build.yml: remove `distribute` input, AMI_DISTRIBUTION_REGIONS,
  block-public-access toggling, and the us-east-1 copy+publish steps;
  post-build prune now targets us-east-2 only
- ami-prune.sh: prune private AMIs (drop the is-public filter)
- Makefile: drop ami.build-distribute and ami.copy; ami.build is now
  private; ami.prune targets us-east-2 only
- docs: document the private, single-region-by-design model

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Kaio Fellipe <kaio6fellipe@gmail.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation jit-runners github-actions feature labels Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kaio6fellipe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eae911b4-7b31-4183-9754-aac51c76b8bb

📥 Commits

Reviewing files that changed from the base of the PR and between ac617a6 and 207960b.

📒 Files selected for processing (3)
  • docs/ami-prebaked.md
  • docs/getting-started-aws.md
  • infra/scripts/ami-prune.sh
📝 Walkthrough

Walkthrough

This PR removes public AMI distribution across regions, switching to a private, single-region (us-east-2) AMI build model. The ami-build.yml workflow drops distribution logic, the Makefile and Packer variables default to private AMIs, the prune script targets all self-owned AMIs regardless of visibility, and documentation is updated accordingly.

Changes

Private-only AMI build and prune

Layer / File(s) Summary
CI workflow: remove distribution logic
.github/workflows/ami-build.yml
Removes the distribute input, AMI_DISTRIBUTION_REGIONS env var, pre-build public-access steps, and post-build distribution-to-us-east-1 steps; updates PR build args, summary output to always report us-east-2 (private), and narrows the prune job to us-east-2 only.
Makefile and Packer variable defaults
Makefile, infra/packer/variables.pkr.hcl
Removes AMI_DISTRIBUTION_REGIONS/SOURCE_REGION, updates ami.build, ami.build-test, ami.prune targets and drops ami.build-distribute/ami.copy; changes Packer ami_groups default from ["all"] to [] and updates ami_regions description.
Prune script targeting
infra/scripts/ami-prune.sh
Removes the is-public=true filter from describe-images, so pruning now considers all self-owned jit-runner AMIs regardless of visibility; header comments updated accordingly.
Documentation updates for private-only AMIs
CLAUDE.md, README.md, docs/ami-prebaked.md, docs/getting-started-aws.md, docs/troubleshooting.md
Updates AMI build/distribution instructions, retention policy, and workflow descriptions to reflect private, single-region (us-east-2) AMI behavior, removing references to distribution/copy commands and multi-region retention.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Trigger
  participant AmiBuildWorkflow
  participant Packer
  participant PruneJob

  Trigger->>AmiBuildWorkflow: push/pull_request/workflow_dispatch
  AmiBuildWorkflow->>Packer: build AMI (private, ami_name_prefix=jit-runner-pr for PRs)
  Packer-->>AmiBuildWorkflow: AMI ID (private, us-east-2)
  AmiBuildWorkflow->>PruneJob: prune --regions us-east-2 (self-owned AMIs, no is-public filter)
Loading

Possibly related PRs

  • devopsfactory-io/jit-runners#6: Both PRs modify the same AMI privacy/permission logic in ami-build.yml PR-vs-non-PR branching and the ami_groups default in infra/packer/variables.pkr.hcl.
  • devopsfactory-io/jit-runners#84: Both PRs modify infra/scripts/ami-prune.sh targeting logic and the related CI/Make prune workflow.
  • devopsfactory-io/jit-runners#87: Both PRs touch the AMI build/distribution flow relying on infra/scripts/ami-prune.sh, with this PR removing the us-east-1 distribute/copy behavior entirely.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, but it does not follow the repo template and omits required sections like purpose, users, issues, checklist, and AI summary. Add the template sections: What is this feature, Why/Who, Related issues, Notes, Checklist, and AI Summary with scope/type/key files.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change to private, single-region runner AMIs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/private-single-region-ami

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

OpenSSF Scorecard — 8.3/10 ✅

Check Score Details
Binary-Artifacts 10/10 no binaries found in the repo
CI-Tests 10/10 23 out of 23 merged PRs checked by a CI test -- score normalized to 10
Code-Review 0/10 Found 0/30 approved changesets -- score normalized to 0
Dangerous-Workflow 10/10 no dangerous workflow patterns detected
License 10/10 license file detected
Pinned-Dependencies 6/10 dependency not pinned by hash detected -- score normalized to 6
Security-Policy 10/10 security policy file detected
Token-Permissions 10/10 GitHub workflow tokens follow principle of least privilege
Vulnerabilities 10/10 0 existing vulnerabilities detected

Threshold: 7 | Full report

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/ami-prebaked.md`:
- Line 31: The AMI sharing note is incorrect: `ami_groups` only accepts
`["all"]`, while cross-account AWS account IDs should be specified via
`ami_users`. Update the wording in the AMI documentation to use the correct
field, and in the relevant guidance about `ami_groups`/`ami_users` either state
cross-account sharing with `ami_users` if intended or remove the aside about
account IDs.

In `@docs/getting-started-aws.md`:
- Line 153: The AMI guidance in getting-started-aws.md incorrectly mentions
AWS_DEFAULT_REGION for make ami.build, which does not control the build. Update
the AMI region note to either state that the pre-baked AMI/build flow is tied to
us-east-2 by default or explain that the Packer source region is controlled by
var.aws_region; refer to the DefaultAMI and make ami.build guidance when
revising the text.

In `@infra/scripts/ami-prune.sh`:
- Around line 62-65: The AMI pruning logic in ami-prune.sh is currently matching
both release and PR test images because the NAME_PREFIX filter is too broad.
Update the image selection used by the prune flow so the list built in the AWS
describe-images call excludes jit-runner-pr-* AMIs, and ensure the filtering
logic in ami.prune only counts release AMIs when determining the newest-2 set.
Keep DefaultAMI protection intact while preventing PR test AMIs from affecting
deletion decisions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ac9d80ba-2022-49a9-8bb5-23096d7baf2a

📥 Commits

Reviewing files that changed from the base of the PR and between 55076a7 and ac617a6.

📒 Files selected for processing (9)
  • .github/workflows/ami-build.yml
  • CLAUDE.md
  • Makefile
  • README.md
  • docs/ami-prebaked.md
  • docs/getting-started-aws.md
  • docs/troubleshooting.md
  • infra/packer/variables.pkr.hcl
  • infra/scripts/ami-prune.sh

Comment thread docs/ami-prebaked.md Outdated
Comment thread docs/getting-started-aws.md Outdated
Comment thread infra/scripts/ami-prune.sh
@kaio6fellipe

Copy link
Copy Markdown
Contributor Author

CI status note (automated babysitter):

  • ✅ AWS ami-build build job passed (14m58s) — produced the private, single-region (us-east-2) AMI that is the actual target of this PR.
  • ❌ GCP gce-image build job failed — twice, on the identical transient error: The zone 'projects/jit-runners/zones/us-central1-c' does not have enough resources available to fulfill the request. This is a Google Cloud capacity flake in us-central1-c, completely unrelated to this AWS-scoped change. I re-ran --failed once and it hit the same GCP-side capacity shortage.

No code in this PR affects GCE provisioning behavior in a way that would cause this. It can be re-run later (or the Packer GCE zone adjusted) as separate infra housekeeping, independent of this PR.

Treating this PR as ready-for-review — the only remaining gate is human review approval / branch protection (mergeStateStatus: BLOCKED).

- ami-prune.sh: exclude jit-runner-pr* test AMIs from the prune set so
  transient PR-build AMIs never count toward release retention (regression
  from dropping the is-public filter, which previously excluded them)
- docs/ami-prebaked.md: correct cross-account sharing note (account IDs use
  ami_users / modify-image-attribute, not ami_groups)
- docs/getting-started-aws.md: region is Packer's var.aws_region, not
  AWS_DEFAULT_REGION

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Kaio Fellipe <kaio6fellipe@gmail.com>
@kaio6fellipe
kaio6fellipe merged commit 2ede98c into main Jul 2, 2026
13 of 14 checks passed
@kaio6fellipe
kaio6fellipe deleted the feat/private-single-region-ami branch July 2, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature github-actions jit-runners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant