fix(cloudformation): point the SAM alias at $LATEST

Real SAM points AutoPublishAlias at the published version, and the first
revision of this change did the same. Floci cannot invoke a published
version: the snapshot carries no code path, so a version-qualified
invoke times out on a cold start (#1987), and silently runs $LATEST's
code when a warm container happens to exist (#1988). Emitting the
faithful form therefore broke the alias-qualified invoke this expansion
exists to enable — strictly worse than not expanding the property.

Point the alias at $LATEST instead. The Version resource is still
emitted, so the resource set and GetAtt still match SAM; only the
alias target differs, and it flips back to the version in one line once
#1987 lands.

The integration test asserted the alias record existed with a numeric
FunctionVersion, which the broken form satisfied — so it passed while
the behavior was broken. It now invokes through the alias and asserts
the function actually runs, which fails against the version-pointing
form (verified by reverting it with the record assertion relaxed).
This commit is contained in:
bdemoss-runwise committed 2026-07-27 16:41:52 -04:00
1 parent 3756d5a464
commit d753187ea4
1 file changed
+5 -6
@@ -137,12 +137,11 @@ class SamTransformProcessorTest {
assertEquals("production", aliasProps.path("Name").asText());
assertEquals("MyFunc", aliasProps.path("FunctionName").path("Ref").asText());
// The alias points at the generated version via Fn::GetAtt, which is also what gives the
// provisioning order function -> version -> alias.
JsonNode versionRef = aliasProps.path("FunctionVersion");
assertTrue(versionRef.has("Fn::GetAtt"));
assertEquals("MyFuncVersion", versionRef.path("Fn::GetAtt").get(0).asText());
assertEquals("Version", versionRef.path("Fn::GetAtt").get(1).asText());
// The alias deliberately targets $LATEST rather than the published version real SAM points
// at: Floci cannot invoke a published version (#1987 cold-start timeout, #1988 warm-pool
// keying), so the faithful form would break the alias-qualified invoke this expansion
// exists to enable.
assertEquals("$LATEST", aliasProps.path("FunctionVersion").asText());
}
@Test