fix(ec2): guard seeded AMIs, reseed on restore, persist image criteria, lazy read#1967
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
DeregisterImage/ModifyImageAttributehad no owner guard, so a caller could remove or mutate the seeded amazon/Canonical-owned public AMIs in its own account — permanently breakingdata.aws_ami { owners=["amazon"] }(the exact thing the catalogue exists for). Now reject ops on an AMI owned by another owner withAuthFailure, matching AWS. User-registered AMIs (owner_id == None) are still freely deregistered/modified.aws_amireturned empty. On restore, idempotently reseed the public catalogue into every restored account (deterministic ids → no-op for already-seeded).ReplaceImageCriteriaInAllowedImagesSettingswas a write-succeeds/read-default stub. Now persists theImageCriterionImageProvidersand emits them fromGetAllowedImagesSettings.DescribeImageseagerly built the (now seed-heavier) throwawayEc2Stateon every read; use a deferred fallback so it's constructed only for a not-yet-created account.Test plan
ec2_ami_catalogue: seeded-AMI deregister/modify rejected (AuthFailure) + user AMI deregister OK;ReplaceImageCriteria→GetAllowedImagesSettingsround-trip (verified the real wire shapeImageCriterion.N.ImageProvider.Mvia the aws CLI against a live server); catalogue survivesstart_persistent→ restart.cargo clippy -p fakecloud-ec2 --all-targets -- -D warningsclean;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
Performance
Written for commit 473935e. Summary will update on new commits.