Python 3.6 and 3.7 language support for the CloudFormation CLI
Project description
DEVELOPER PREVIEW
We're excited to share our progress with adding new languages to the CloudFormation CLI! This plugin is an early preview, and not ready for production use.
AWS CloudFormation Resource Provider Python Plugin
The CloudFormation Resource Provider Development Kit (RPDK) allows you to author your own resource providers that can be used by CloudFormation.
This plugin library helps to provide runtime bindings for the execution of your providers by CloudFormation.
Installation
Because this is a developer preview, you can't install it from pypi (the version there will not work) You can still install the plugin using pip from GitHub.
pip install git+https://github.com/aws-cloudformation/aws-cloudformation-rpdk-python-plugin.git#egg=cloudformation-cli-python-plugin
Howto
The support library, cloudformation-cli-python-lib
must be packaged and present in the project's directory. Packaging can be done by running the package_lib.sh
script. Example run:
$ cfn init
Initializing new project
What's the name of your resource type?
(Organization::Service::Resource)
>> Foo::Bar::Baz
Select a language for code generation:
[1] java
[2] csharp
[3] python36
[4] python37
(enter an integer):
>> 4
Use docker for platform-independent packaging (Y/n)?
This is highly recommended unless you are experienced
with cross-platform Python packaging.
>> y
Initialized a new project in <>
$ cp ../cloudformation-cli-python-lib-0.0.1.tar.gz .
$ cfn submit --dry-run
$ cat <<EOT > test.json
{
"credentials": {
"accessKeyId": "",
"secretAccessKey": "",
"sessionToken": ""
},
"action": "CREATE",
"request": {
"clientRequestToken": "ecba020e-b2e6-4742-a7d0-8a06ae7c4b2b",
"desiredResourceState": {
"Title": "This_Is_The_Title_For_My_Example",
"TestCode": "NOT_STARTED"
},
"previousResourceState": null,
"logicalResourceIdentifier": null
},
"callbackContext": null
}
EOT
$ sam local invoke TestEntrypoint --event test.json
Development
For changes to the plugin, a Python virtual environment is recommended. The development requirements can be sourced from the core repository:
python3 -m venv env
source env/bin/activate
pip install -e . -e src/ \
-r https://raw.githubusercontent.com/aws-cloudformation/aws-cloudformation-rpdk/master/requirements.txt
pre-commit install
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
License
This library is licensed under the Apache 2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cloudformation-cli-python-plugin-2.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68a68e54d20884364cc253cbfd7623f713fd1856af597131288aec42319d14a6 |
|
MD5 | 1bc64379f11a8fd0f0b6c9ec29deef92 |
|
BLAKE2b-256 | 1d79cdee3927805842750af796d82b3c359541617db6e781ffcf442ffacfc679 |
Hashes for cloudformation_cli_python_plugin-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d848aff58e1f2d756ee9657d5c174525aa28da497fe24c3034852cfdbfd19d6c |
|
MD5 | 3c9a138a9ceeb55efd2ef7cc75b172ae |
|
BLAKE2b-256 | b014a2769a1dd8cf3758eb5cc0ce090f5b920f8b7a5fd82b3a483725028d44ec |