Skip to content

fix(E1010): Resolve GetAtt to SAM generated resources - #4646

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4644
Aug 18, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4644

Conversation

@kddejong

Copy link
Copy Markdown
Contributor

Issue #, if available

Fixes #4644

Description of changes

!GetAtt <Function>.Version.FunctionArn on an AWS::Serverless::Function produced a false positive E1010 since v1.54.0 (regression from removing the SAM translator in #4491):

E1010 'Version.FunctionArn' is not one of ['SnapStartResponse', 'SnapStartResponse.ApplyOn', 'SnapStartResponse.OptimizationStatus', 'Arn']

Root cause: SAM's generated Version/Alias resources are modeled as synthetic resources whose logical id contains a . (MyFn.Version, type AWS::Lambda::Version), injected when AutoPublishAlias/DeploymentPreference is present. A GetAtt shorthand is split on the first ., so MyFn.Version.FunctionArn was validated as attribute Version.FunctionArn on the function itself instead of resolving against the synthetic MyFn.Version resource.

Fix: In E1010, re-associate the longest logical-id prefix that matches a known resource before validating the attribute, keeping the dotted synthetic id intact. Ordinary two-segment GetAtts and unresolved (Ref/Sub) resource names are unaffected.

Verified against the real aws-sam-translator:

  • With AutoPublishAlias: SAM emits AWS::Lambda::Version and rewrites the GetAtt to it → now passes.
  • Without it: SAM generates no Version resource and leaves the GetAtt on the plain function, which CloudFormation rejects at deploy → E1010 still (correctly) fires. The minimal template in the issue falls in this second case.

Tests

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

SAM generated resources (a function's Version/Alias) are modeled as
synthetic resources whose logical id contains a "." (MyFn.Version). A
GetAtt shorthand is split on the first ".", so
!GetAtt MyFn.Version.FunctionArn was resolved against the function
itself rather than the synthetic Version resource, producing a false
positive E1010.

Re-associate the longest logical-id prefix that matches a known
resource before validating the attribute, so the dotted synthetic id
stays intact. Ordinary two-segment GetAtts and unresolved (Ref/Sub)
resource names are left unchanged. A function without AutoPublishAlias
still errors, since SAM generates no Version resource and the template
would not deploy.

aws-cloudformation#4644
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.61%. Comparing base (1a58c98) to head (39b307f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4646   +/-   ##
=======================================
  Coverage   94.61%   94.61%           
=======================================
  Files         432      432           
  Lines       15426    15437   +11     
  Branches     2991     2995    +4     
=======================================
+ Hits        14595    14606   +11     
  Misses        453      453           
  Partials      378      378           
Flag Coverage Δ
unittests 94.61% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit b9bfa87 into aws-cloudformation:main Aug 18, 2026
21 checks passed
@kddejong
kddejong deleted the fix/issue/4644 branch August 18, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant