Files
floci/src/main/java/io/github/hectorvent
Hector Ventura 7095641e25 fix(cloudformation): set Fn::GetAtt attributes the schemas declare (#2761)
* fix(cloudformation): set Fn::GetAtt attributes the schemas declare

An attribute a provisioner never sets is invisible at runtime: GetAtt
resolution returns the literal "LogicalId.Attr" when a resource has no such
attribute, so a template referencing one receives that string as a value
instead of failing. Auditing every migrated type against its registry
schema found 24 such attributes across 15 types.

Sets the three whose correct value is unambiguous:

  AWS::SNS::Topic gains TopicArn, the attribute aws-sns-topic.json actually
  declares. Arn stays alongside it, since templates written against earlier
  releases reference it.

  AWS::S3::Bucket gains DualStackDomainName, in the same form as the
  RegionalDomainName it already builds.

  AWS::CodePipeline::Pipeline gains Arn, which the schema describes as the
  pipeline's ARN and which is constructible from the region, account and
  name already in hand.

The remaining 21 are recorded in getatt-attribute-gaps.tsv, each with a
reason. Most are attributes Floci cannot set because it does not emulate
the behaviour behind them, such as VPC CIDR associations or pipe lifecycle
timestamps. A few are simply undecidable from the schema alone, and
inventing a value would be worse than leaving the gap recorded.

CfnSchemaCoverageTest makes the set a ratchet rather than a snapshot:
closing a gap requires deleting its row, introducing one requires adding a
row with a reason where a reviewer sees it, and a row that stops being real
fails until it is removed.

* test(cloudformation): await the async stack operations in the VPC gateway test

The test asserted the results of CreateStack and DeleteStack immediately.
Both are asynchronous: CloudFormationService submits them to a background
executor and the HTTP call returns as soon as the work is queued, so each
assertion only passed while the executor happened to win the race.

The delete assertion lost that race on CI. Adding a test class elsewhere in
the suite re-partitioned the deterministic CI shards, which moved this class
to different neighbours and changed the timing it had been relying on.

Both assertions now poll to a deadline, matching the awaitStackStatus
pattern the other CloudFormation integration tests use. A genuinely
unperformed detach still fails, just ten seconds later, so this removes the
timing sensitivity without hiding a real regression.

* fix(cloudformation): scope the GetAtt coverage scan per resource type

The scan read each provisioner as a whole file, so a class serving
several types credited every one of them with what any single arm sets.
That is a false negative in the only direction that matters: the gap the
ratchet exists to record stops being reported.

It was hiding a real one. Ec2NetworkAclCfnProvisioner sets Id for
NetworkAcl and never for NetworkAclEntry, whose schema declares Id as its
primaryIdentifier and sole readOnlyProperty, so Fn::GetAtt on it resolved
to the literal "LogicalId.Id" while the audit reported clean. Set it to
the composite physical id so the attribute agrees with Ref.

The scan now walks the switch on getResourceType() in provision, takes
each arm plus the same-class methods it transitively calls, and adds
whatever provision writes outside the switch to every type, since that is
the shared path. Two shapes need the care:

- Only a switch in statement position is a dispatch. A switch expression
  such as `boolean ingress = switch (r.getResourceType())` picks a value
  on one shared path. Reading its arms as per-type paths reported
  SecurityGroupIngress and SecurityGroupEgress Id as gaps when both are
  set after the switch.
- A class with a dispatch switch but no arm for a type it owns now fails
  the scan, so an unrecognised shape cannot quietly fall back to the
  class-wide reading it replaced.

Raised by pgermosen in review.
2026-09-01 22:50:12 -05:00
..