Skip to content

CloudFormation: don't propagate stack tags to launch templates - #10200

Open
Mide69 wants to merge 3 commits into
getmoto:masterfrom
Mide69:cloudformation-launch-template-no-stack-tags
Open

CloudFormation: don't propagate stack tags to launch templates#10200
Mide69 wants to merge 3 commits into
getmoto:masterfrom
Mide69:cloudformation-launch-template-no-stack-tags

Conversation

@Mide69

@Mide69 Mide69 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Closes #10168.

AWS::EC2::LaunchTemplate exposes tags via TagSpecifications (nested under LaunchTemplateData), not a top-level Tags property, so real CloudFormation does not auto-propagate the stack's tags to it the way it does for other taggable EC2 resources (AWS docs).

Root cause: LaunchTemplate inherits TaggedEC2Resource, so the generic tag-propagation loop in ResourceMap.create() (moto/cloudformation/parsing.py) was calling create_tags(...) on it just like any other taggable EC2 resource. Excludes LaunchTemplate from that loop.

Note: describe_launch_templates's Tags field wasn't actually showing the leak (it's a snapshot taken at construction time, before the CFN tag loop runs), the leaked tags were only visible via the generic describe_tags API on the launch template's resource id. Test reflects that, and also verifies a normal taggable resource (VPC) still gets stack tags as a regression guard.

Mide69 added 3 commits August 22, 2026 22:16
AWS::EC2::LaunchTemplate exposes tags via TagSpecifications (nested
under LaunchTemplateData), not a top-level Tags property, so real
CloudFormation does not auto-tag it with the stack's tags the way it
does for other taggable EC2 resources. Excludes LaunchTemplate from
the generic tag-propagation loop in the stack resource map.

Closes getmoto#10168.
The regression-guard VPC lookup filtered by CidrBlock (10.0.0.0/16),
a value reused across many tests in the suite. That's harmless under
mock_aws's per-test isolation, but server-mode tests share one
long-lived backend across the whole run, so the filter could match a
different test's VPC instead of this stack's own one. Read the
physical resource id from the stack's own resources instead.
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.31%. Comparing base (35e6424) to head (3f3b04c).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10200   +/-   ##
=======================================
  Coverage   93.31%   93.31%           
=======================================
  Files        1341     1341           
  Lines      122557   122558    +1     
=======================================
+ Hits       114361   114362    +1     
  Misses       8196     8196           
Flag Coverage Δ
servertests 27.91% <50.00%> (+<0.01%) ⬆️
unittests 93.28% <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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

CloudFormation: Creating a launch template through CF add the CFT tags

1 participant