Skip to content

fix(E3009): require command in cfn-init commands entries - #4914

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
moneytool:fix/cfn-init-command-required
Nov 5, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
moneytool:fix/cfn-init-command-required

Conversation

@moneytool

@moneytool moneytool commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available: Fixes #4874

Description of changes:

The cfn_init.json schema had no required list for commands entries, so an entry without command passed lint, then failed at cfn-init time on the instance. Add required: ["command"] and a regression test.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@blacksoxx blacksoxx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the diff against main. I did not run the suite here, so these are reading notes.

The schema change matches the cfn-init reference: in the commands section command is the only required key, and env, cwd, test, ignoreErrors and waitAfterCompletion stay optional, so with additionalProperties: false already on the entry, required was the one missing piece. The new case's schema_path follows the existing patternProperties chain in cfn_init.json, and the valid-command case keeps the happy path covered. I also scanned the good fixture templates that use AWS::CloudFormation::Init commands and found none without command, so the snapshot results should be unchanged.

@OKAN-SOFTWARE OKAN-SOFTWARE left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated commit b9c495a locally using Python 3.12.14.

The new missing-command regression test fails with the current main-branch schema and passes with this change.

python -m pytest -q test/unit/rules/resources — 1,355 passed.

Additional checks covered empty command entries, mixed valid/invalid entries, multiple configuration blocks, Ref, Fn::Sub, Fn::If, and an AWS::NoValue branch. Valid inputs remained accepted, and missing commands were reported at the corresponding entry.

No blocking issues found within this review’s scope. Validation covered local rule behavior and unit tests; no AWS deployment was performed.

@kddejong
kddejong force-pushed the fix/cfn-init-command-required branch 2 times, most recently from 07f7028 to 2407485 Compare November 3, 2026 22:52
The cfn_init.json schema had no `required` list for `commands`
entries, so an entry without `command` passed lint, then failed at
cfn-init time on the instance. Add `required: ["command"]` and a
regression test.

Fixes aws-cloudformation#4874
@kddejong
kddejong force-pushed the fix/cfn-init-command-required branch from 2407485 to a9e47b5 Compare November 4, 2026 20:32
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.80%. Comparing base (c4746e8) to head (a9e47b5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4914   +/-   ##
=======================================
  Coverage   94.80%   94.80%           
=======================================
  Files         441      441           
  Lines       16165    16165           
  Branches     3135     3135           
=======================================
  Hits        15326    15326           
  Misses        463      463           
  Partials      376      376           
Flag Coverage Δ
unittests 94.80% <ø> (ø)

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 5fe79a1 into aws-cloudformation:main Nov 5, 2026
25 checks passed
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.

E3009: AWS::CloudFormation::Init commands entry without command is not reported

4 participants