Skip to main content

No project description provided

Project description

AWS CloudFormation CLI

The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.

Usage

Documentation

Primary documentation for the CloudFormation CLI can be found at the AWS Documentation site.

Installation

This tool can be installed using pip from the Python Package Index (PyPI). It requires Python 3. The tool requires at least one language plugin. The language plugins are also available on PyPI and as such can be installed all at once:

pip install cloudformation-cli cloudformation-cli-java-plugin cloudformation-cli-go-plugin cloudformation-cli-python-plugin

Command: init

To create a project in the current directory, use the init command. A wizard will guide you through the creation.

cfn init

Command: generate

To refresh auto-generated code, use the generate command. Usually, plugins try to integrate this command in the native build flow, so please consult a plugin's README to see if this is necessary.

cfn generate

Command: submit

To register a resource provider in your account, use the submit command.

cfn submit
cfn submit --dry-run #prepares schema handler package without submitting for registration

Command: test

To run the contract tests, use the test command.

cfn test
cfn test -- -k contract_delete_update #to run a single test
cfn test --tb=long #exhaustive, informative traceback formatting
cfn test --enforce-timeout 60 #set the RL handler timeout to 60 seconds and CUD handler timeout to 120 seconds.
cfn test --enforce-timeout 60 -- -k contract_delete_update # combine args

Command: build-image

To build an image. This image provides a minimalistic execution environment for the handler that does not depend on AWS Lambda in anyway. This image can be used during cfn invoke and cfn test instead of using sam cli.

cfn build-image
cfn build-image --image-name my-handler --executable target/myjar.jar

The resulting image can be run in a container by executing the following command:

docker run IMAGE_NAME HANDLER_ENTRYPOINT PAYLOAD
docker run my-test-resource com.my.test.resource.ExecutableHandlerWrapper PAYLOAD_JSON # Example for a java based-project

Development

For developing, it's strongly suggested to install the development dependencies inside a virtual environment. (This isn't required if you just want to use this tool.)

python3 -m venv env
source env/bin/activate
pip install -e . -r requirements.txt
pre-commit install

You will also need to install a language plugin, such as the Java language plugin, also via pip install. For example, assuming the plugin is checked out in the same parent directory as this repository:

pip install -e ../cloudformation-cli-java-plugin

Linting and running unit tests is done via pre-commit, and so is performed automatically on commit. The continuous integration also runs these checks. Manual options are available so you don't have to commit):

# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files
# run unit tests only. can also be used for other hooks, e.g. black, flake8, pylint-local
pre-commit run pytest-local

If you want to generate an HTML coverage report afterwards, run coverage html. The report is output to htmlcov/index.html.

Plugin system

New language plugins can be independently developed. As long as they declare the appropriate entry point and are installed in the same environment, they can even be completely separate codebases. For example, a plugin for Groovy might have the following entry point:

entry_points={
    "rpdk.v1.languages": ["groovy = rpdk.groovy:GroovyLanguagePlugin"],
},

Plugins must provide the same interface as LanguagePlugin (in plugin_base.py). And they may inherit from LanguagePlugin for the helper methods - but this is not necessary. As long as the class has the same methods, it will work as a plugin.

Supported plugins

Language Status Github PyPI
Java Available cloudformation-cli-java-plugin cloudformation-cli-java-plugin
Go Available cloudformation-cli-go-plugin cloudformation-cli-go-plugin
Python Available cloudformation-cli-python-plugin cloudformation-cli-python-plugin

License

This library is licensed under the Apache 2.0 License.

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

cloudformation-cli-0.1.13.tar.gz (61.5 kB view details)

Uploaded Source

Built Distribution

cloudformation_cli-0.1.13-py3-none-any.whl (78.4 kB view details)

Uploaded Python 3

File details

Details for the file cloudformation-cli-0.1.13.tar.gz.

File metadata

  • Download URL: cloudformation-cli-0.1.13.tar.gz
  • Upload date:
  • Size: 61.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.1

File hashes

Hashes for cloudformation-cli-0.1.13.tar.gz
Algorithm Hash digest
SHA256 818a359e74ee3934c5e31c1633150636125bc516b3b32c82386eca9db21badf4
MD5 611b8f065e5e597cc32e9cab54950bf1
BLAKE2b-256 396b141196ead8841ce65d853ffaad0ebdc63068617c930518a939159bb346d2

See more details on using hashes here.

File details

Details for the file cloudformation_cli-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: cloudformation_cli-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 78.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.1

File hashes

Hashes for cloudformation_cli-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 95e98f13b204ee6e7e19ccfba27973248ac9493f8ac6599ed3b705e093ee1343
MD5 e37c0c92a90322c7b2a139ac86155995
BLAKE2b-256 0d8e5b10a7ac913fe93567db2d44b4ceb0e3f4d19b81e8223b53be0924e7987b

See more details on using hashes here.

Supported by

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