Skip to content

fix: Allow intrinsics in SAM Globals properties - #4683

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4680
Sep 8, 2026
Merged

fix: Allow intrinsics in SAM Globals properties#4683
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4680

Conversation

@kddejong

@kddejong kddejong commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available

Fixes #4680

Description of changes

Since #4491 the Globals section is validated against globals.json by E3724 (GlobalsTransform). That rule validated the section without enabling intrinsic functions or intrinsic-aware type checking, so any type-constrained Globals property rejected Ref/Fn::ImportValue/Fn::Sub:

E3724 {'Fn::ImportValue': {'Fn::Sub': 'my-iam-${Environment}-lambda-boundary-arn'}} is not of type 'string'

The reporter flagged Function.PermissionsBoundary, but it's broader — e.g. Function.Runtime: !Ref X failed the same way. The same intrinsic on the resource's own Properties was already accepted, so only the Globals path was affected.

Fix: when validating the Globals section, enable functions and use the intrinsic-aware cfn_type, mirroring how resource properties and Outputs values are validated. Malformed literals are still flagged (E3724/E3012), and the merged resource-level validation remains a second layer.

Validated against the real SAM translator (sam validate, aws-sam-translator 1.165.0): it accepts the intrinsic in Globals.Function.PermissionsBoundary and in Globals.Function.Runtime; a non-intrinsic object literal is still rejected by cfn-lint's schema type check.

Testing

  • Added regression cases to test/unit/rules/resources/test_globals_transform.py (intrinsic in PermissionsBoundary/Runtime → no error; non-intrinsic object → still errors).
  • ruff, ruff format, isort, mypy clean.
  • test/unit/rules/resources + test/unit/rules/functions (1482) and serverless integration tests pass.

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

E3724 validates the Globals section against globals.json, but
GlobalsTransform validated it without enabling intrinsic functions or
intrinsic-aware type checking. Any type-constrained Globals property
(e.g. Function.PermissionsBoundary, Function.Runtime) therefore
rejected Ref/Fn::ImportValue/Fn::Sub that CloudFormation and the SAM
translator accept and that the resource-level property already allows.

Enable functions and cfn_type when validating the Globals section,
matching how resource properties and Outputs values are validated.
Malformed literals are still flagged, and the merged resource-level
validation remains a second layer. Verified against the SAM translator
(sam validate 1.165.0).

aws-cloudformation#4680
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.64%. Comparing base (9c6ecc9) to head (48c6720).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4683   +/-   ##
=======================================
  Coverage   94.64%   94.64%           
=======================================
  Files         433      433           
  Lines       15511    15512    +1     
  Branches     3011     3011           
=======================================
+ Hits        14681    14682    +1     
  Misses        453      453           
  Partials      377      377           
Flag Coverage Δ
unittests 94.64% <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 00c36e3 into aws-cloudformation:main Sep 8, 2026
21 checks passed
@kddejong
kddejong deleted the fix/issue/4680 branch September 8, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E3724 rejects an intrinsic in Globals.Function.PermissionsBoundary that CloudFormation and the resource-level property accept

1 participant