{"id":27656,"library":"cloudformation-cli","title":"cloudformation-cli (cfn-cli)","description":"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.","status":"active","version":"0.2.39","language":"python","source_language":"en","source_url":"https://github.com/aws-cloudformation/cloudformation-cli","tags":["aws","cloudformation","cli","resource-type","provider"],"install":[{"cmd":"pip install cloudformation-cli","lang":"bash","label":"default"},{"cmd":"pip install cloudformation-cli[local-testing]","lang":"bash","label":"with local testing dependencies"}],"dependencies":[{"reason":"Required for credential management and AWS API calls if not using boto3 directly.","package":"awscli","optional":true},{"reason":"Required for contract tests that run lambda-like environments.","package":"docker","optional":true}],"imports":[{"wrong":"from cloudformation_cli_python_lib import BaseResourceHandler, exceptions","symbol":"BaseResourceHandler","correct":"from rpdk import BaseResourceHandler"},{"wrong":"from cloudformation_cli_python_lib import BaseResourceHandler, exceptions","symbol":"exceptions","correct":"from rpdk import exceptions"}],"quickstart":{"code":"import os\nimport json\n\n# Initialize a new resource type project\nos.system('cfn init')\n\n# Example: simple resource handler (Java in README, Python equivalent)\n# Usually generated; here's a minimal Python handler placeholder\nfrom cloudformation_cli_python_lib import BaseResourceHandler, exceptions\n\nclass MyResource(BaseResourceHandler):\n    def create(self, request):\n        # model = request.desiredResourceState\n        # ... implement create logic\n        return {\"resourceModel\": request.desiredResourceState}\n    \n    def read(self, request):\n        pass\n    \n    def update(self, request):\n        pass\n    \n    def delete(self, request):\n        pass\n\n# To run contract tests:\n# os.system('cfn test')","lang":"python","description":"Initialize a CloudFormation resource type project and implement a basic resource handler using the Python library."},"warnings":[{"fix":"Install Docker Desktop and start the daemon before running `cfn test`.","message":"When running `cfn test`, ensure Docker is installed and the daemon is running, as contract tests spin up a local Lambda-like container.","severity":"gotcha","affected_versions":"all"},{"fix":"Run `aws configure` or set environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION.","message":"The `cfn submit` command requires valid AWS credentials with permissions to register resource types. Many users fail to configure credentials, leading to `AccessDenied` errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure you are in the project root with a valid `resource-role.yaml` or schema file before running `cfn generate`.","message":"In v0.2.30+, the `cfn generate` command requires the CloudFormation resource schema to be present; omitted schema leads to `FileNotFoundError`.","severity":"breaking","affected_versions":">=0.2.30"},{"fix":"Upgrade to Python 3.7 or later (recommend 3.9+).","message":"Python 3.6 support ended with v0.2.33; the latest versions require Python >=3.7.","severity":"deprecated","affected_versions":">=0.2.33"}],"env_vars":null,"search_vec":"'-4':65 '0.2.39':34 '3':64 'allow':36 'aw':15,22,70 'build':18 'cadenc':60 'cfn':5,10 'cfn-cli':4,9 'cli':3,6,8,11,72 'cloudform':2,7,23,41,56,71 'cloudformation-c':1 'contract':49 'creat':39 'current':31 'custom':40 'develop':37 'hook':29 'irregular':62 'java':45 'minor':66 'modul':27 'offici':14 'per':68 'provid':26,76 'publish':21 'python':47 'registri':57 'releas':59,67 'resourc':24,42,74 'resource-typ':73 'run':48 'submit':52 'test':19,50 'tool':16 'type':25,43,75 'use':44 'version':32 'year':69","created_at":"2026-05-09T05:51:22.993600+00:00","updated_at":"2026-05-09T05:51:22.993600+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'BaseResourceHandler' from 'rpdk' (unknown location)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"cfn","cli_version":"cfn 0.2.39","type":"library","homepage":"https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html","github":"https://github.com/aws-cloudformation/aws-cloudformation-rpdk","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cloudformation-cli/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["aws","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}