mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
* feat(ec2): DescribeImages synthesizes an AMI for an unmatched wildcard name lookup CDK MachineImage.lookup is a synth-time context provider that queries by a name wildcard and aborts cdk deploy on an empty response. When a wildcard name filter matches no seeded AMI, synthesize a deterministic one satisfying the name/owner/architecture filters so the lookup resolves — the exact id is a runtime detail. Fixes #2008 * fix(ec2): synthesized lookup AMI id must be 17 hex chars (was substring OOB) * fix(ec2): a synthesized lookup AMI must satisfy the request that produced it The synthesized name was built by truncating the pattern at its first wildcard, so an infix pattern like ubuntu-*-20.04-* produced "ubuntu-20260101", which does not satisfy it. Each wildcard is now substituted instead, and the scalar fields a request can filter on (architecture, owner alias, state, root device, virtualization type, hypervisor) take the requested value rather than a hardcoded one. Synthesis is also no longer unconditional: the result is checked against the full filter set before being returned, and withheld when it cannot satisfy it. An empty result is what the caller would otherwise have got, and it is better than an AMI that contradicts the request without the caller being able to tell. * fix(ec2): a name filter reads ? as the single-character wildcard AWS defines AWS filter values take two wildcards, * for any run of characters and ? for exactly one. wildcardMatches expanded only *, quoting everything else, so a pattern like ubuntu-? matched nothing. wildcardToRegex further down the same file already read both, so the two disagreed on the same syntax. That half is not specific to lookup synthesis and affects any name filter. Synthesis in turn substituted * and left ? in place, which handed back a name carrying a literal ? that the requesting filter no longer matches once the matcher reads ? properly. It now substitutes a single character for each one. * fix(ec2): a synthesized lookup image resolves its owner and faces the owner scope Owner.N takes aliases, and synthesizeLookupImage wrote the requested value through verbatim, so Owner.1=self with no owner-id filter produced an image owned by the literal "self". Ec2Service matches self by comparing the image owner against the account id, so nothing resolves that. It now maps self to the account id and passes anything else through. The guard below it only re-checked Filter.N, so the image never faced the owner scope that produced it and a foreign Owner.N still got an AMI back. matchesImageOwners already existed privately on Ec2Service and is now exposed next to imageMatchesFilters, rather than restating the rule in the handler. Two tests, neither of which passed before, since nothing in the suite sent Owner.N. * fix(ec2): DescribeImages owner aliases resolve to the accounts they name Resolving only self left amazon and aws-marketplace written through verbatim, so a synthesized lookup image came back owned by the literal alias. The owner check added alongside it then accepted that by string equality, which made the result self-consistently wrong rather than merely unmatched. Both aliases now resolve to their accounts in the synthesized image, and matchesImageOwners resolves them too, so Owner.1=amazon matches an Amazon-owned image rather than only one owned by the literal string. * fix(ec2): the seeded Amazon Linux images carry their owner matchesImageOwners learning the amazon alias only helped registered images. The catalog matches on its own owner metadata, and five of the ten seeded entries carry none, so Owner.1=amazon omitted Amazon Linux 2 and 2023 regardless. Both now carry ownerId 137112412989 and the amazon alias, matching how the Canonical entries are already seeded. Debian, Alpine and Windows Server are still without owner metadata, which is the same pre-existing gap and needs their real account ids rather than a guess. * fix(ec2): lookup synthesis reads the wildcard value, not the first one A filter's values are an OR, and the name pattern was taken with findFirst on the list, so an exact value ahead of a wildcard meant the wildcard check failed and synthesis never ran. The lookup then got an empty set that one of its own values could have been satisfied by. It now picks the first value carrying a wildcard. This predates the ? support, which only widened which values qualify. * fix(ec2): a synthesized image's owner id and alias agree with each other The alias defaulted to amazon whatever the owner resolved to, so Owner.1=self reported account 000000000000 beside imageOwnerAlias amazon. The alias is now derived from the resolved account, and an account with no alias emits no element at all, which is what AWS does. The mirror was wrong too and is fixed with it. An owner-alias filter names an account as much as Owner.N does, but was consulted by nothing, so filtering on owner-alias alone left the id at the Amazon default and reported that account beside someone else's alias. Owner resolution now reads the owner-id filter, then Owner.N, then the owner-alias filter, then the default. Asserted as a pair across all four owner scopes rather than per field. Each half was confirmed by reverting the source change with the test in place and watching it fail on the exact contradiction.