Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Boilerplate showing how to create a native Pulumi provider from OpenAPI specs using pulschema.

License

Notifications You must be signed in to change notification settings

cloudy-sky-software/pulumi-provider-boilerplate

 
 

Repository files navigation

🛑 DEPRECATED: USE https://github.com/cloudy-sky-software/pulumi-provider-template INSTEAD. 🛑

Pulumi Native Provider Boilerplate

This repository is a boilerplate showing how to create and locally test a native Pulumi provider generated from an OpenAPI 3.0 spec.

Authoring a Pulumi Native Provider

This boilerplate lets you create a working native Pulumi provider named xyz. You'll need to update provider/pkg/provider/provider.go and implement the necessary CRUD functions from Pulumi's ResourceProviderServer interface.

Prerequisites

Prerequisites for this repository are already satisfied by the Pulumi Devcontainer if you are using Github Codespaces, or VSCode.

If you are not using VSCode, you will need to ensure the following tools are installed and present in your $PATH:

Build & test the boilerplate XYZ provider

  1. Create a new Github CodeSpaces environment using this repository.
  2. Open a terminal in the CodeSpaces environment.
  3. Run make build install to build and install the provider.
  4. Run make gen_examples to generate the example programs in examples/ off of the source examples/yaml example program.
  5. Run make up to run the example program in examples/yaml.
  6. Run make down to tear down the example program.

Creating a new provider repository

Pulumi offers this repository as a GitHub template repository for convenience. From this repository:

  1. Click "Use this template".
  2. Set the following options:
    • Owner: pulumi
    • Repository name: pulumi-xyz-native (replace "xyz" with the name of your provider)
    • Description: Pulumi provider for xyz
    • Repository type: Public
  3. Clone the generated repository.

From the templated repository:

  1. Search-replace xyz with the name of your desired provider.

Build the provider and install the plugin

$ make build install

This will:

  1. Create the SDK codegen binary and place it in a ./bin folder (gitignored)
  2. Create the provider binary and place it in the ./bin folder (gitignored)
  3. Generate the dotnet, Go, Node, and Python SDKs and place them in the ./sdk folder
  4. Install the provider on your machine.

A brief repository overview

You now have:

  1. A provider/ folder containing the building and implementation logic
    1. cmd/pulumi-resource-xyz/main.go - holds the provider's sample implementation logic.
  2. deployment-templates - a set of files to help you around deployment and publication
  3. sdk - holds the generated code libraries created by pulumi-gen-xyz/main.go
  4. examples a folder of Pulumi programs to try locally and/or use in CI.
  5. A Makefile and this README.

Additional Details

This repository depends on pulschema library to handle generating a Pulumi schema from an OpenAPI 3.x spec. For a successful schema generation, you should ensure that your OpenAPI spec is valid and that it conforms to certain expectations. Learn more at https://github.com/cloudy-sky-software/cloud-provider-api-conformance.

Build Examples

Create an example program using the resources defined in your provider, and place it in the examples/ folder.

You can now repeat the steps for build, install, and test.

Configuring CI and releases

  1. Follow the instructions laid out in the deployment templates.

References

Other resources/examples for implementing providers:

About

Boilerplate showing how to create a native Pulumi provider from OpenAPI specs using pulschema.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • Go 42.5%
  • Python 25.9%
  • C# 11.9%
  • TypeScript 11.9%
  • Makefile 7.8%