Package: pulumi-render
Pulumi Native Provider for RenderThis repository is a boilerplate showing how to create a native Pulumi provider.BackgroundThis repository is part of theguide for authoring and publishing a Pulumi Package.Learn about the concepts behindPulumi Packages.Follow this link to seean architecture diagram for Pulumi.A Pulumi Resource Provider:is a gRPC server which allows for the Pulumi engine to create resources in a specific cloudholds the lifecycle logic for these cloud resourcesholds a pulumi JSON schema that describes the providerprovides language-specific SDKs so resources can be created in whichever language you preferWhen we speak of a "native" provider, we mean that all implementation is native to Pulumi, as opposed
toTerraform based providers.Authoring a Pulumi Native ProviderThe following instructions assume that the provider is written for the Pulumi organisation.
In the future, we will add instruction for providers published and maintained by the Pulumi community, referred to as "third-party" providers.This boilerplate creates a working Pulumi-owned provider namedxyz.
It implements a random number generator that you canbuild and test out for yourselfand then replace the Random code with code specific to your provider.PrerequisitesEnsure the following tools are installed and present in your$PATH:pulumictlGo 1.17or 1.latestNodeJS14.x.  We recommend usingnvmto manage NodeJS installations.YarnTypeScriptPython(called aspython3).  For recent versions of MacOS, the system-installed version is fine..NETCreating and Initializing the RepositoryPulumi offers this repository as aGitHub template repositoryfor convenience.  From this repository:Click "Use this template".Set the following options:Owner: pulumiRepository name: pulumi-xyz-native (replace "xyz" with the name of your provider)Description: Pulumi provider for xyzRepository type: PublicClone the generated repository.From the templated repository:Search-replacexyzwith the name of your desired provider.Build the provider and install the plugin$makebuildinstallThis will:Create the SDK codegen binary and place it in a./binfolder (gitignored)Create the provider binary and place it in the./binfolder (gitignored)Generate the dotnet, Go, Node, and Python SDKs and place them in the./sdkfolderInstall the provider on your machine.Test against the example$cdexamples/simple
$yarnlink@pulumi/xyz
$yarninstall
$pulumistackinittest$pulumiupNow that you have completed all of the above steps, you have a working provider that generates a random string for you.A brief repository overviewYou now have:Aprovider/folder containing the building and implementation logiccmd/pulumi-gen-xyz/- generates language SDKs from the schemapulumi-resource-xyz/- holds the package schema, injects the package version, and starts the gRPC serverpkgprovider- holds the gRPC methods (and for now, the sample implementation logic) required by the Pulumi engineversion- semver package to be consumed by build processesdeployment-templates- a set of files to help you around deployment and publicationsdk- holds the generated code libraries created bypulumi-gen-xyz/main.goexamplesa folder of Pulumi programs to try locally and/or use in CI.AMakefileand thisREADME.Writing the schemaTheJSON schema fileis used bypulumi-gen-xyzto 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.When writing the schema by hand, it is helpful to associate the JSON schema in your IDE for completion or Intellisense features to work:Visual Studio Code: the easiest option is tomap the schema filein your User Settings which enables it for all your provider projects:"json.schemas":[{"fileMatch":["/provider/cmd/pulumi-*/schema.json"],"url":"https://raw.githubusercontent.com/pulumi/pulumi/master/pkg/codegen/schema/pulumi.json"}]This repository provides thexyz example schemato get you started.The AWS Native Provider schemaprovides a much larger example.Refer to thepackage schema documentationfor additional details when writing the schema.Implementing the gRPC methodsOnce 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 inpkg/provider/provider.go.
Note that these methods do not link 1:1 to the Pulumi CLI commands.Basic FunctionalityThe struct and creation of the provider are implemented already:// provider/pkg/provider.gotypexyzProviderstruct{host*provider.HostClientnamestringversionstringschema[]byte}funcmakeProvider(host*provider.HostClient,name,versionstring,pulumiSchema[]byte)(pulumirpc.ResourceProviderServer,error){// Return the new providerreturn&xyzProvider{host:host,name:name,version:version,schema:pulumiSchema,},nil}You need to provide the following methods:Check - validates resource InputsDiff - calculates the differences between the actual and the desired state of a resourceCreate - creates a new instance of a resource from an InputUpdate - updates a resource in-place (i.e. without deleting/recreating)Read - reads current inputs and state for a resourceDelete - deletes a resource and its corresponding stateResource 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 versionGetSchema - returns the Pulumi schema to the providerAdditional MethodsTheresource provider serviceincludes a few more gRPC methods that you may need to implement and can read more about.Build ExamplesCreate an example program using the resources defined in your provider, and place it in theexamples/folder.You can now repeat the steps forbuild, install, and test.DocumentationPleasefollow this guide to add documentation to your provider.Configuring CI and releasesFollow the instructions laid out in thedeployment templates.ReferencesOther resources for learning about the Pulumi resource model:Pulumi Kubernetes providerPulumi Terraform Remote State providerDynamic Providers