Skip to main content

Prints out linting errors found in inline cloudformation lambda code

Project description

🚀 cfn-inline-lambda-linter

PyPI - Python Version
PyPI
License
Code Coverage
GitHub Stars

cfn-inline-lambda-linter is a powerful and lightweight tool for linting inline Lambda functions embedded in AWS CloudFormation templates. Optimize your Lambda code, catch potential issues, and enforce best practices effortlessly.

✨ Features

🔍 Automatic Detection: Scans YAML/JSON templates to identify inline Lambda functions.
Lightning-Fast Linting: Validates syntax, enforces standards, and identifies anti-patterns.
🛠 Customizable Rules: Extend with your own linting rules to suit your project needs.
📦 CI/CD Ready: Seamlessly integrate into any CI/CD pipeline.
📈 Future-Proof: Built with extensibility and AWS updates in mind.

🛠 Installation

Install via pip:

pip install cfn-inline-lambda-linter

Or Install the latest development version:

pip install git+https://github.com/saad1998/cfn-inline-lambda-linter.git  

🚀 Quick Start

Lint a CloudFormation Template

cfn_lambda_lint lint template.yaml

Pass args to Lint

cfn_lambda_lint lint template.yaml --args "--max-line-length=88 --ignore=E203,W503"

🎣 Pre-Commit Hook Integration

Ensure your code is always clean and adheres to best practices by integrating cfn-inline-lambda-linter as a pre-commit hook!

Why Use This Hook?

  • Automatic linting: Detect and resolve CloudFormation template issues effortlessly.
  • Error prevention: Catch inline Lambda errors before deployment.
  • Productivity boost: Spend less time debugging and more time building.

Setting Up the Pre-Commit Hook

  1. Install pre-commit globally (if not already installed):

    pip install pre-commit
    
  2. Add the following to your project's .pre-commit-config.yaml file:

    repos:
      - repo: https://github.com/saad1998/cfn-inline-lambda-linter
        rev: v0.1.0  # Replace with the latest version
        hooks:
          - id: cfn-inline-lambda-linter
            files: template.yaml
    
  3. Install the pre-commit hook in your local repository:

    pre-commit install
    
  4. Test it by running pre-commit on all files:

    pre-commit run --all-files
    

How It Works

Once the hook is configured, every time you try to commit changes:

  • The hook will automatically scan your CloudFormation templates containing inline Lambda code.
  • Errors or warnings will be highlighted, ensuring only high-quality configurations are committed.

Customize the Hook

You can pass arguments to the hook by modifying .pre-commit-config.yaml:

repos:
  - repo: https://github.com/saad1998/cfn-inline-lambda-linter
    rev: v0.1.0
    hooks:
      - id: cfn-inline-lambda-linter
        files: template.yaml
        args: ["--args=--max-line-length=88 --ignore=E203,W503"]

🎉 You're All Set!

Your project is now equipped with an automated linter that ensures CloudFormation templates and inline Lambda code are always error-free before committing.

🌟 Why Choose Us?

  • Developer-Friendly: Clean output with actionable messages.
  • AWS Focused: Tailored specifically for AWS Lambda in CloudFormation.
  • Open Source: Free forever, with a growing community of contributors.

🤝 Contributing

We ❤️ contributions! But at the moment it has been paused. It will be resumed when we have published our Contributing.md guide.

🗺 Roadmap

✅ Add support for nested templates. ✅ Add linting support for lambda functions written in other languages. 🚧 Advanced static analysis for Lambda functions. 🔜 Enhanced logging for CI/CD pipelines.

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

🎉 Show Your Support

Give a ⭐ if this project helps you improve your CloudFormation workflows!

📧 Contact

Got questions or suggestions? Open an issue here.

"Code smarter, not harder!"

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_inline_lambda_linter-0.1.4.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

cfn_inline_lambda_linter-0.1.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file cfn_inline_lambda_linter-0.1.4.tar.gz.

File metadata

  • Download URL: cfn_inline_lambda_linter-0.1.4.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for cfn_inline_lambda_linter-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1c1b1be50b1c4467dc6836f98c909ffa6956cc5c7a03a7a611d9199592a380e0
MD5 d50cdf383ab5bd2a6c575707549754ec
BLAKE2b-256 cdeb1657d68e5f092b6d250f53dbe369f06451c9322b314837c8391cecb887f7

See more details on using hashes here.

File details

Details for the file cfn_inline_lambda_linter-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: cfn_inline_lambda_linter-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for cfn_inline_lambda_linter-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 366102f3a861fea7c921f36e0fc2696ddd89aa7d0b6d03835eca206e9ebe7f46
MD5 cd3e60562e8ac619f054cb8c9c563119
BLAKE2b-256 e72d0d347c41ca6546807aeadc7db28ea6c9ca4f95a3431682e9f969e1bf0677

See more details on using hashes here.

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