Files
floci/src/main/java/io/github/hectorvent
Priamo Germosen 527615bdf0 fix(iam): seed the full AWS managed policy catalog (#2194)
* fix(iam): seed the full AWS managed policy catalog

AttachRolePolicy and GetPolicy resolved arn:aws:iam::aws:policy/* against a
hand-maintained list of 59 entries, so any policy outside it returned
NoSuchEntity even though AWS publishes it. Real Terraform and CloudFormation
configurations failed for a reason unrelated to the user's setup — attaching
AmazonEC2ReadOnlyAccess or service-role/AmazonElasticMapReduceRole was enough
to break a stack — and the list could only be extended one policy per PR.

The catalog now carries the full published list (1566 entries), loaded from
iam/managed-policies.yaml following the existing ec2/image-catalog.yaml
pattern. AwsManagedPolicies keeps its POLICIES and ManagedPolicyDef surface,
so callers and tests are unaffected.

Unknown ARNs still return NoSuchEntity/404. That matters as much as the
additions: resolving every well-formed ARN would accept typos that real AWS
rejects and would stop CloudFormation rolling a stack back on a bad
attachment. Seeding the real catalog is what makes the check faithful in both
directions rather than trading one wrong answer for another.

The catalog is a union with the previously seeded entries, so a policy AWS has
since retired but which Floci already resolved — AWSLambdaFullAccess — keeps
working. Curated descriptions are preserved.

seedAwsManagedPolicies no longer mirrors the catalog into the account store.
That copy was never read back, since listPolicies filters AWS-managed ARNs out
of the local scan and serves them from the catalog, and writing 1566 entries on
every start cost ~1.4 MB of persisted state and ~3.7s of persistent-mode
startup.

Policy names and paths derive from the public AWS managed policy list via
https://github.com/iann0036/iam-dataset (MIT); only names and paths are used.
Regenerate against a real account with `aws iam list-policies --scope AWS`.

* fix(iam): register the managed-policy catalog for native image builds

AwsManagedPolicies reads iam/managed-policies.yaml through
ClassLoader#getResourceAsStream, which Quarkus's static resource analysis
cannot see. Without an explicit registration the file is absent from the
native image, the stream comes back null and IAM aborts startup — taking the
whole application with it.

Registered in both places the EC2 image catalog already uses:
quarkus.native.resources.includes in application.yml, and the resources
pattern in META-INF/native-image/resource-config.json.

Verified against the native binary rather than the build alone, since a
successful build does not prove the resource is embedded: the native image
starts, ListPolicies(Scope=AWS) reports all 1566 entries, previously missing
policies attach, and a misspelled ARN still returns NoSuchEntity.

Reported by Greptile on #2194.
2026-08-12 17:49:57 -05:00
..