This project contains a pip packaged named pulumi-snowflake
which allows Snowflake resources to be managed in Pulumi.
NOTE: This package relies on the
snowflake-connector-python
pip package, which has specific setup instructions. Please ensure you check the prerequesits for your platform before using thepulumi-snowflake
package.
An example Pulumi program which uses this package is present in the example
folder.
- Install the package into your Pulumi project using
pip
- Set your Snowflake credentials in your stack config:
pulumi config set snowflakeAccountName [snowflake account name]
pulumi config set --secret snowflakeUsername [snowflake username]
pulumi config set --secret snowflakePassword [snowflake password]
pulumi config set --secret snowflakeRole [snowflake role]
Note:
snowflakeRole
is optional.
Currently this package supports a the following resources:
- The
pulumi_snowflake.fileformat.FileFormat
class is a Pulumi resource for managing Snowflake file format objects. - The
pulumi_snowflake.storage_integration.AWSStorageIntegration
class is a Pulumi resource for managing storage integration objects with AWS parameters. - The
pulumi_snowflake.stage.Stage
class is a Pulumi resource for managing Snowflake staging areas
The directory structure is as follows:
├── example # An example of a Pulumi program using this package with AWS
├── pulumi_snowflake # The main package source
│ ├── baseprovider # The dynamic provider base class and related classes
│ │ └── attribute
│ ├── fileformat # The File Format resource and dynamic provider
│ ├── stage # The Stage resource and dynamic provider
│ └── storageintegration # The Storage Integration resource and dynamic provider
└── test # Unit tests
├── fileformat
├── provider
│ └── attribute
├── stage
└── storageintegration
- To run the unit tests (you may also want to instantiate a virtual environment in the root directory):
python setup.py test
The dynamic providers for each object type are build on top of some generic classes which make it straightforward to support new object types in the future. The Provider
class handles the create
, diff
and delete
methods based on a few parameters which define the Snowflake object. These objects take a Snowflake connection, the object name, and a list of attributes in their constructor. For example, the file format object provider is defined like so:
class FileFormatProvider(Provider):
def __init__(self, connection_provider: ConnectionProvider):
super().__init__(connection_provider, "FILE FORMAT", [
KeyValueAttribute("type"),
KeyValueAttribute("comment")
])
Notice how the attributes list is used to define the structure of CREATE
and UPDATE
calls to the object in a manner that matches the documentation. The values in the attribute list are all subclasses of BaseAttribute
, which define properties of the attributes and the way they are turned into SQL fragments.