Repository navigation
fix(sub): resolve SAM generated Version/Alias references in Fn::Sub - #4798
Merged
kddejong merged 1 commit intoOct 23, 2026
Merged
Conversation
kddejong
approved these changes
Oct 23, 2026
SAM generated resources (a function's Version/Alias when
AutoPublishAlias or DeploymentPreference is set) are modeled as
synthetic resources whose logical id contains a "." (MyFn.Version).
Fn::Sub validated every dotted ${a.b} as a GetAtt, so
${MyFn.Version} and ${MyFn.Alias} were checked as attributes of the
function and reported E1019.
When the full dotted name is a known resource, validate it as a Ref
instead, matching how SAM resolves it. A function without
AutoPublishAlias still errors, since SAM generates no such resource.
Fixes aws-cloudformation#4777
kddejong
force-pushed
the
fix/sub-sam-autopublish-alias
branch
from
October 23, 2026 21:29
b379e85 to
4c459ae
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4798 +/- ##
=======================================
Coverage 94.68% 94.68%
=======================================
Files 439 439
Lines 16004 16004
Branches 3108 3108
=======================================
Hits 15153 15153
Misses 468 468
Partials 383 383
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: Fixes #4777
Description of changes:
Sub._validate_stringvalidates every dotted${a.b}as{"Fn::GetAtt": "a.b"}. SAM's generatedVersion/Aliasresources (whenAutoPublishAliasorDeploymentPreferenceis set) are registered in the context as synthetic resources whose logical id contains a.(MyFunction.Version), so${MyFunction.Version}/${MyFunction.Alias}were checked as attributes of the function and reported E1019.Refinstead of aGetAtt. This mirrors fix(E1010): Resolve GetAtt to SAM generated resources #4646 forFn::GetAtt. A function withoutAutoPublishAliasstill errors, because SAM generates no such resource.test/unit/rules/functions/test_sub.pyforAutoPublishAlias(Version,Alias, and${MyFunction.Version.Version}),DeploymentPreference, and a function without either (still errors). Added the good templatetest/fixtures/templates/good/functions/sub_serverless_function_version.yamltotest_good_templates.py.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.