Registry / aws / cloudformation-cli

cloudformation-cli

JSON →
library0.2.39pypypiunverified

CloudFormation CLI (cfn-cli) is the official AWS tool for building, testing, and publishing AWS CloudFormation resource type providers, modules, and hooks. The current version is 0.2.39. It allows developers to create custom CloudFormation resource types using Java or Python, run contract tests, and submit them to the CloudFormation registry. The release cadence is irregular, with 3-4 minor releases per year.

pip install cloudformation-cli
INSTALL
IMPORT
SIG · CLOUDFORMATION-CLI
C
cloudformation-cli
awspythonv0.2.39
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BaseResourceHandler
✓ from rpdk import BaseResourceHandler
✗ from cloudformation_cli_python_lib import BaseResourceHandler, exceptions
exceptions
✓ from rpdk import exceptions
✗ from cloudformation_cli_python_lib import BaseResourceHandler, exceptions

Initialize a CloudFormation resource type project and implement a basic resource handler using the Python library.

import os import json # Initialize a new resource type project os.system('cfn init') # Example: simple resource handler (Java in README, Python equivalent) # Usually generated; here's a minimal Python handler placeholder from cloudformation_cli_python_lib import BaseResourceHandler, exceptions class MyResource(BaseResourceHandler): def create(self, request): # model = request.desiredResourceState # ... implement create logic return {"resourceModel": request.desiredResourceState} def read(self, request): pass def update(self, request): pass def delete(self, request): pass # To run contract tests: # os.system('cfn test')
cfn --version
Debug
Known issues
gotchaWhen running `cfn test`, ensure Docker is installed and the daemon is running, as contract tests spin up a local Lambda-like container.
fix
Install Docker Desktop and start the daemon before running `cfn test`.
affects: all
gotchaThe `cfn submit` command requires valid AWS credentials with permissions to register resource types. Many users fail to configure credentials, leading to `AccessDenied` errors.
fix
Run `aws configure` or set environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION.
affects: all
breakingIn v0.2.30+, the `cfn generate` command requires the CloudFormation resource schema to be present; omitted schema leads to `FileNotFoundError`.
fix
Ensure you are in the project root with a valid `resource-role.yaml` or schema file before running `cfn generate`.
affects: >=0.2.30
deprecatedPython 3.6 support ended with v0.2.33; the latest versions require Python >=3.7.
fix
Upgrade to Python 3.7 or later (recommend 3.9+).
affects: >=0.2.33
Upgrade
Version history
0.2.39latest on PyPI · released Mar 31, 2025
Audit
Dependencies
awsclioptionalRequired for credential management and AWS API calls if not using boto3 directly.
dockeroptionalRequired for contract tests that run lambda-like environments.
Agent activity
25 hits · last 30 days
node
24
Amazon
1
Resources
cloudformation-cli — pip install cloudformation-cli · libregistry