Skip to main content

cfn-lint rules for projects using cfn-handler custom resources

Project description

cfn-lint-cfn-handler

PyPI version Python versions License

A cfn-lint rule plugin for projects using cfn-handler custom resource handlers.

It catches misconfigurations specific to cfn-handler-based custom resources — the kind of issues cfn-lint cannot know about generically because they depend on knowing the consumer ships cfn-handler semantics.

0.x is pre-1.0; the rule set is still expanding. See the rule catalogue below for what currently ships.

Install

pip install cfn-lint cfn-lint-cfn-handler
# or with uv
uv add cfn-lint-cfn-handler

Use

cfn-lint v1+ does not auto-discover plugins. Opt in explicitly via the -a/--append-rules flag. Put the template path before -a, otherwise argparse greedily absorbs it as another rule path:

cfn-lint template.yaml -a cfn_lint_cfn_handler.rules

Or in .cfnlintrc:

append_rules:
  - cfn_lint_cfn_handler.rules

Rule catalogue

ID Severity Description Status
E9101 Error Custom resource references a Lambda whose Timeout is < 30 s (cfn-handler safety margin) shipping
E9106 Error Lambda Timeout exceeds custom resource ServiceTimeout — CFN gives up before Lambda finishes shipping
E9108 Error ServiceTimeout absent or > 900 s (Lambda's hard ceiling). Opt out per-resource for polling handlers. shipping
E9102 Error Polling-using handler has ServiceTimeout below a sensible polling minimum planned
E9103 Error Lambda lacks IAM permissions for events:* / lambda:*Permission when polling planned
W9104 Warning ServiceToken does not look like a Lambda Function ARN planned
W9105 Warning cfn-handler Layer ARN doesn't match the region the stack is being deployed to planned

Severity is encoded by the first letter of the rule ID, per cfn-lint convention (E* → error, W* → warning, I* → informational).

Configuring rules

Standard cfn-lint mechanisms work as expected. Mute a rule entirely via .cfnlintrc:

ignore_checks:
  - E9108

Or per-resource via the Metadata block (universal escape hatch — works for any rule):

Resources:
  MyCustomResource:
    Type: Custom::LongRunningJob
    Metadata:
      cfn-lint:
        config:
          ignore_checks: [E9108]
    Properties:
      ServiceToken: !GetAtt Handler.Arn
      ServiceTimeout: 3600

E9108 polling opt-in (recommended for polling handlers)

E9108 fires by default when ServiceTimeout is unset or above Lambda's 900 s ceiling. For polling-based custom resource handlers (which legitimately need wall-clock windows beyond a single Lambda invocation), add the polling: true marker per-resource:

Resources:
  MyLongRunningResource:
    Type: Custom::Provisioner
    Metadata:
      cfn-lint:
        config:
          configure_rules:
            E9108:
              polling: true
    Properties:
      ServiceToken: !GetAtt Handler.Arn
      ServiceTimeout: 3600

For multiple polling resources, the template-level form is concise:

Metadata:
  cfn-lint:
    config:
      configure_rules:
        E9108:
          polling_resources: [MyResource1, MyResource2]

The polling: true marker conveys intent — once polling-aware detection lands (alongside E9102/E9103), the rule will validate the claim against the Lambda's IAM perms.

To override a rule's severity, see cfn-lint's per-rule config.

Compatibility

  • Python: 3.10+
  • cfn-lint: 1.43+

Contributing

See CONTRIBUTING.md. Larger changes go through the OpenSpec workflow in openspec/.

License

Apache-2.0. See LICENSE and NOTICE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfn_lint_cfn_handler-0.2.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfn_lint_cfn_handler-0.2.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file cfn_lint_cfn_handler-0.2.0.tar.gz.

File metadata

  • Download URL: cfn_lint_cfn_handler-0.2.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cfn_lint_cfn_handler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 11cf6606535300ceaae37e7c3a34ac8047bb1f2ce0511bda7598124c3a2c890c
MD5 7912caabe10246ec801a52c7f42ea34f
BLAKE2b-256 b9960af47944dc3ef1a7c6d08e7c23649fdb288f632bdb41693e3cc08fdffb0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfn_lint_cfn_handler-0.2.0.tar.gz:

Publisher: release.yml on igorlg/cfn-lint-cfn-handler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cfn_lint_cfn_handler-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cfn_lint_cfn_handler-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40c68423cf44d2ca32ac7c58a71ea6f65759a9345f540acc70b91876fd274724
MD5 e07f488929c63f74f929911082ce90d1
BLAKE2b-256 d137a34dd9de615a668067abcfa4bc92a3d00cf2a3c8bc7e5cc27ee023cab3a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfn_lint_cfn_handler-0.2.0-py3-none-any.whl:

Publisher: release.yml on igorlg/cfn-lint-cfn-handler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page