Learn about the concepts behind Pulumi Packages.
Follow this link to see an architecture diagram for Pulumi.
A Pulumi Resource Provider:
- is a gRPC server which allows for the Pulumi engine to create resources in a specific cloud
- holds the lifecycle logic for these cloud resources
- holds a pulumi JSON schema that describes the provider
- provides language-specific SDKs so resources can be created in whichever language you prefer
When we speak of a "native" provider, we mean that all implementation is native to Pulumi.
Ensure the following tools are installed and present in your $PATH
:
pulumictl
- Go 1.17 or 1.latest
- NodeJS 14.x. We recommend using nvm to manage NodeJS installations.
- Yarn
- TypeScript
- Python (called as
python3
). For recent versions of MacOS, the system-installed version is fine. - .NET
$ make build install
This will:
- Create the SDK codegen binary and place it in a
./bin
folder (gitignored) - Create the provider binary and place it in the
./bin
folder (gitignored) - Generate the dotnet, Go, Node, and Python SDKs and place them in the
./sdk
folder - Install the provider on your machine.
$ cd examples/simple
$ yarn link @pulumi/esxi-native
$ yarn install
$ pulumi stack init test
$ pulumi up
You now have:
- A
provider/
folder containing the building and implementation logiccmd/
pulumi-gen-esxi-native/
- generates language SDKs from the schemapulumi-resource-esxi-native/
- holds the package schema, injects the package version, and starts the gRPC server
pkg
provider
- holds the gRPC methods (and for now, the sample implementation logic) required by the Pulumi engineversion
- semver package to be consumed by build processes
sdk
- holds the generated code libraries created bypulumi-gen-esxi-native/main.go
examples
a folder of Pulumi programs to try locally and/or use in CI.- A
Makefile
and thisREADME
.
The JSON schema file is used by pulumi-gen-esxi-native
to create language-specific SDKs.
It is, therefore, a central requirement for any resource provider.
Provider schemas can be handwritten, or alternatively machine-generated by combining API specification with pulumi-specific logic.
This repository provides the esxi-native schema to get you started. Refer to the package schema documentation for additional details when writing the schema.
Once you have a schema that describes all the resources and metadata for your provider, you will need to implement the desired gRPC methods.
You will find a mostly blank implementation of these in pkg/provider/provider.go
.
Note that these methods do not link 1:1 to the Pulumi CLI commands.
The struct and creation of the provider are implemented already, the main functionalities are provided in the following methods:
- Check - validates resource Inputs
- Diff - calculates the differences between the actual and the desired state of a resource
- Create - creates a new instance of a resource from an Input
- Update - updates a resource in-place (i.e. without deleting/recreating)
- Read - reads current inputs and state for a resource
- Delete - deletes a resource and its corresponding state
Resource lifecycle methods are documented here.
The following methods are necessary for every provider and are already implemented:
- GetPluginInfo - returns generic information about this plugin, like its version
- GetSchema - returns the Pulumi schema to the provider
Create an example program using the resources defined in the provider, and place it in the examples/
folder.
You can now repeat the steps for build, install, and test.
Please follow this guide to add documentation to the provider.