Skip to content

fix(ec2): guard seeded AMIs, reseed on restore, persist image criteria, lazy read#1967

Merged
vieiralucas merged 1 commit into
mainfrom
worktree-worktree-ec2-seed-fixes
Jun 26, 2026
Merged

fix(ec2): guard seeded AMIs, reseed on restore, persist image criteria, lazy read#1967
vieiralucas merged 1 commit into
mainfrom
worktree-worktree-ec2-seed-fixes

Conversation

@vieiralucas

@vieiralucas vieiralucas commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

Bug-hunt 2026-06-26 cycle 3, batch 2 of 3 — fixes three regressions the cycle-3 AMI-seed work (#1964/#1965) introduced, plus a pre-existing stub.

Test plan

  • New e2e ec2_ami_catalogue: seeded-AMI deregister/modify rejected (AuthFailure) + user AMI deregister OK; ReplaceImageCriteriaGetAllowedImagesSettings round-trip (verified the real wire shape ImageCriterion.N.ImageProvider.M via the aws CLI against a live server); catalogue survives start_persistent → restart.
  • ec2 image conformance (register/modify/deregister/get-allowed-images/replace) — 5/5 green.
  • cargo clippy -p fakecloud-ec2 --all-targets -- -D warnings clean; cargo fmt.

Batch 1 = #1966 (S3 aws-chunked). Batch 3 = bedrock InvokeGuardrailChecks. Report: bug-hunt-reports/2026-06-26-cycle3.md.


Summary by cubic

Block DeregisterImage/ModifyImageAttribute on seeded amazon/Canonical AMIs and reseed the public AMI catalogue on snapshot restore. Persist allowed-image criteria and make DescribeImages lazy to reduce read overhead.

  • Bug Fixes

    • Reject deregister/modify on AMIs owned by other accounts with AuthFailure; user-registered AMIs still allowed.
    • On snapshot restore, reseed the public AMI catalogue for each account; deterministic ids make this idempotent.
    • Persist ImageCriterion providers from ReplaceImageCriteriaInAllowedImagesSettings and return them via GetAllowedImagesSettings.
  • Performance

    • DescribeImages now builds the default seeded state only when the account doesn’t exist, reducing work on reads.

Written for commit 473935e. Summary will update on new commits.

Review in cubic

…a, lazy read

Bug-hunt 2026-06-26 cycle 3, batch 2 — fixes three regressions from the cycle-3
AMI-seed work (#1964/#1965) plus a pre-existing stub.

- #2 (MEDIUM): DeregisterImage / ModifyImageAttribute had no owner guard, so a
  caller could remove or mutate the seeded amazon/Canonical-owned public AMIs in
  its own account — permanently breaking `data.aws_ami { owners=["amazon"] }`
  (the exact thing the catalogue exists for). Now reject ops on an AMI owned by
  another owner with AuthFailure, matching AWS. A user-registered AMI
  (owner_id == None) is still freely deregistered/modified.
- #5 (LOW): a snapshot written by a pre-#1964 binary restored an account whose
  images map lacked the seeds, and the read-path fallback only seeds ABSENT
  accounts — so after upgrade+restart `aws_ami` returned empty. On restore,
  idempotently reseed the public catalogue into every restored account
  (deterministic ids -> no-op for already-seeded).
- #4 (LOW): ReplaceImageCriteriaInAllowedImagesSettings was a write-succeeds/
  read-default stub. Now persist the ImageCriterion ImageProviders on state and
  emit them from GetAllowedImagesSettings (round-trips).
- #6 (LOW): DescribeImages eagerly built the (now seed-heavier) throwaway
  Ec2State on every read; use a deferred fallback so it's constructed only for a
  not-yet-created account.

Tests: new e2e ec2_ami_catalogue (seed deregister/modify rejected + user AMI ok;
ReplaceImageCriteria round-trip; catalogue survives restart). ec2 image
conformance (register/modify/deregister/get-allowed/replace) green.
@vieiralucas vieiralucas merged commit f8b04e9 into main Jun 26, 2026
103 checks passed
@vieiralucas vieiralucas deleted the worktree-worktree-ec2-seed-fixes branch June 26, 2026 14:26
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.

1 participant