mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
* fix(cloudformation): expand SAM AutoPublishAlias
AutoPublishAlias was read nowhere in the codebase, so the SAM transform
silently dropped it: the stack reached CREATE_COMPLETE, the function
deployed with only $LATEST, and an alias-qualified invoke then failed
with "Alias not found" far from the deploy that caused it. The
"Unsupported SAM resource type" debug arm only covers unknown resource
types, not unknown properties, so nothing was logged either.
Expand it into the AWS::Lambda::Version + AWS::Lambda::Alias pair real
SAM generates, and provision those two types. Both halves are needed:
the transform alone emits resources the provisioner ignores, and the
provisioner alone is unreachable from a SAM template.
The Lambda service already implements publishVersion and the alias APIs,
so this is plumbing rather than new service behavior. The new types go
through CfnResourceProvisioner rather than the legacy switch, following
the registry migration. Ref/GetAtt on the emitted properties give the
function -> version -> alias ordering that topologicalSort already
follows, so no explicit DependsOn is needed.
An intrinsic alias name (e.g. !Ref StageName) is passed through to Name
for the engine to resolve at provision time; only the generated logical
id needs a literal and drops the suffix in that case.
* test(cloudformation): cover Version/Alias provisioner directly
The SAM integration test drives provisioning end to end but cannot reach
two paths: the already-exists fallback (createAlias conflicting with an
alias that outlived a stack delete) and delete(), which its @AfterEach
invokes but never asserts on — a broken delete was silent.
Add LambdaVersionAliasCfnProvisionerTest alongside the existing Sqs and
Rds provisioner tests: attribute wiring for both types, the conflict
fallback, non-conflict failures still propagating, alias delete parsed
out of the ARN, delete idempotency when the alias is already gone,
version delete as a no-op, and a physical id that is not an alias ARN
(the generic fallback's shape on stacks predating this provisioner).
Also stop pinning the alias's FunctionVersion to a literal "1" in the
integration test: assert it is a number and not $LATEST, which is what
the assertion is actually for. Pinning the first version fails
confusingly when an earlier run leaks the function and its counter.
* 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).
* fix(cloudformation): point the SAM alias at $LATEST
Restores the change d753187e was supposed to carry. That commit landed
only its unit-test half — the main-code change and the integration
test's invoke assertion were lost to a `git checkout --` used to undo a
verification experiment, leaving a test asserting $LATEST against code
still emitting the version pointer.
Real SAM points AutoPublishAlias at the published version. 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 broke the alias-qualified invoke this
expansion exists to enable.
The Version resource is still emitted, so the resource set and GetAtt
match SAM; only the alias target differs, and it flips back in one line
once #1987 lands.
The integration test now invokes through the alias instead of only
asserting the alias record exists — the record assertion was satisfied
by the broken form. Verified load-bearing by re-applying the version
pointer with the record assertion relaxed: the invoke fails at the
function timeout.
* fix(cloudformation): sanitize the generated alias logical id
The AutoPublishAlias expansion built the alias resource's logical id by
concatenating the alias name raw. Lambda alias names may contain '-' and
'_', neither of which is valid in a CloudFormation logical id, so
`AutoPublishAlias: blue-green` emitted `MyFuncAliasblue-green`.
Route the suffix through the sanitize() helper this file already uses
for every other derived logical id. The alias name sent to Lambda is
untouched -- only the logical id changes.
Also corrects the expandAutoPublishAlias javadoc: with FunctionVersion a
literal $LATEST there is no version -> alias ordering edge, only
function -> version and function -> alias. None is needed, since the
alias does not reference the version; the edge returns with the GetAtt
form once #1987 lands.