This repository is a Cookiecutter project for creating new dynamic providers in Python. You must ensure Cookiecutter is installed:
pip install cookiecutter
Then, use the following command to create a new dynamic provider project:
cookiecutter gh:nuage-studio/pulumi-dynamic-provider-python
Cookiecutter will then prompt you for a number of inputs:
project_slug |
The name of the project in snake_case , e.g. pulumi_snowflake |
project_display_name |
The friendly name of the project, e.g. "Pulumi Snowflake Dynamic Provider" |
project_url |
The URL of the project, e.g. https://github.com/nuage-studio/pulumi-snowflake |
use_github_actions_workflow |
If "yes", a Github Actions workflow is included which will run style checkers and unit tests when pushing to master. |
github_repo_username |
The Github username for the repo, which is used for an Actions build status badge in the README. Ignored if not using Actions. |
github_repo_name |
The Github repository name, which is used for an Actions build status badge in the README. Ignored if not using Actions. |
backend_provider |
If an option other than "none" is chosen, then backend provider dependencies are included. Currently, only "aws" is supported. |
aws_region |
The AWS region to be used in the config, e.g. "eu-west-1". If AWS is not being used, enter "none". |
use_default_base_class |
If "yes", an empty base class for dynamic providers is created to keep shared functionality. This should be the default option. |
initial_resource_slug |
The name of the first resource in snake_case , e.g. table |
For example, consider the following example. We wish to write a dynamic provider for a service called "ACME". One of the resources which we can create through the ACME service is a "database". Thus, we might give the following input:
$ cookiecutter gh nuage-studio/pulumi-dynamic-provider-python
project_slug: pulumi_acme
project_display_name: Pulumi Dynamic Provider for ACME service
project_url: https://github.com/acme/pulumi-acme
Select use_github_actions_workflow:
1 - yes
2 - no
Choose from 1, 2 [1]: 1
github_repo_username: acme
github_repo_name: pulumi-acme
Select backend_provider:
1 - none
2 - aws
Choose from 1, 2 [1]: 2
aws_region: eu-west-1
Select use_default_base_class:
1 - yes
2 - no
Choose from 1, 2 [1]: 1
initial_resource_slug: database
This will generate a directory with the chosen project name, and the following folder structure:
. Root project directory
├── .github/workflow/on_push.yml The Github Actions workflow
├── example An example Pulumi program which uses this provider package
│ ├── __main__.py
│ ├── Pulumi.dev.yaml
│ ├── Pulumi.yaml
│ └── README.md
├── Makefile
├── pulumi_acme The main package folder with a subfolder for each resource type
│ ├── base_dynamic_provider.py The base class for all dynamic providers (if enabled)
│ ├── database The folder for a particular resource type
│ │ ├── database_provider.py The Dynamic Provider for the resource
│ │ └── database.py The Pulumi resource object
│ └── provider.py
├── README.md
├── requirements_dev.txt
├── setup.cfg
├── setup.py
└── test Unit tests for the dynamic providers
└── database
└── database_provider_tests.py
├── README.md
You need Python 3 (preferably 3.8) installed to start working on this project.
In order to install your virtualenv, just go to the root of the project and:
make install
Nuage recommends Visual Studio Code to work on this project, and some default settings have been configured in the .vscode/settings.json.
These settings merely enforce the code-quality guidelines defined below, but if you use another IDE it's probably worth taking a quick look at it to ensure compliance with the standard.
By default, we recommend:
- Putting your virtualenv in a
venv
folder at the project root - Using a
.env
file to define your environment variables (cf. python-dotenv)
This project has opinionated code-quality requirements:
All of these tools are enforced at the commit-level via pre-commit
You can run the following command to apply code-quality to your project at any point:
make quality
Code quality configuration files:
- IDE-agnostic coding style settings are set in the .editorconfig file
- Python-related settings are set in the setup.cfg file
- Pre-commit-related settings are set in the .pre-commit-config.yaml file
You can run cookiecutter on the local directory with the following command:
cookiecutter .