Repository navigation
Conversation
CloudFormation doesn't evaluate intrinsic functions in the template
Description, Parameters or Mappings, or in the parameters it passes to
a macro through Fn::Transform, so a "${...}" there is plain text and
the Fn::Sub that E1029 asks for can't be added. Skip those places, but
keep checking the AWS::Include Location, which can use Fn::Sub.
Parameters were skipped before (aws-cloudformation#1256) until the aws-cloudformation#2031 rework.
The TemplateBody exception (aws-cloudformation#2057) only looked at the key directly
above the string, so a TemplateBody wrapped in Fn::If was still
reported. Step over Fn::If branches, nested ones too, before checking
the exception.
Fixes aws-cloudformation#4758
kddejong
force-pushed
the
fix/e1029-sections-without-sub
branch
from
October 21, 2026 17:42
c083de1 to
b5f50b4
Compare
kddejong
approved these changes
Oct 21, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4759 +/- ##
==========================================
- Coverage 94.68% 94.67% -0.02%
==========================================
Files 439 439
Lines 15910 15934 +24
Branches 3079 3085 +6
==========================================
+ Hits 15065 15086 +21
- Misses 463 466 +3
Partials 382 382
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 #4758
Description of changes:
E1029 reported
${...}text in places where CloudFormation never evaluates intrinsic functions, so theFn::Subit asks for can't be added:Description, which has to be a literal string (docs)Parameters, where no intrinsic functions are supported (docs). Don't alert on E1029 when in parameters since Sub can't be used there #1256 skipped this section, and the check was lost in the Update rule E1029 to only alert when its a valid ref or getatt #2031 rework.Mappings, which can't contain parameters, pseudo parameters or intrinsic functions (docs)Fn::Transform, which CloudFormation hands to the macro without evaluating them (docs). TheAWS::IncludeLocationis still checked, since it can useFn::Sub.Following the advice doesn't work either: wrapping the first three in
!Submakes cfn-lint report E1004, E2001 and E7001.It also reported a
TemplateBodywrapped inFn::If. TheTemplateBodyexception from #2057 only looked at the key right above the string, which forTemplateBody: !If [...]is the branch index.Changes in
SubNeeded:Description,ParametersandMappingssections, and macro parameters underFn::Transform(not theAWS::IncludeLocation).Fn::Ifbranches (nested ones too) before checking it against theTemplateBodyexception.Resource properties are checked as before: a bare
${AWS::Region}in a property, and one inside anFn::Ifthat isn't underTemplateBody, are still reported.Tests: the template from the issue is a new good fixture, with an extra nested
Fn::IfTemplateBody. Onmainit gets 11 E1029 findings (the 8 from the issue plus 3 from the nested case); with this change it gets none. The bad fixture gains the two cases above that must still be reported, plus a bare${...}in anAWS::IncludeLocationand in a resourceDescription(11 findings, was 7). The full test suite passes (2972 passed, Python 3.13),pre-commit runon the changed files passes, and no snapshot undertest/fixtures/resultscontains E1029, so none change.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.