Pulumi-aws-iam - Reusable IAM modules for AWS

xyz Pulumi Component Provider (Go)

This repo is a boilerplate showing how to create a Pulumi component provider written in Go. You can search-replace xyz with the name of your desired provider as a starting point for creating a component provider for your component resources.

An example StaticPage component resource is available in provider/pkg/provider/staticPage.go. This component creates a static web page hosted in an AWS S3 Bucket. There is nothing special about StaticPage -- it is a typical component resource written in Go.

The component provider makes component resources available to other languages. The implementation is in provider/pkg/provider/provider.go. Each component resource in the provider must have an implementation in the Construct function to create an instance of the requested component resource and return its URN and state (outputs). There is an initial implementation that demonstrates an implementation of Construct for the example StaticPage component.

A code generator is available which generates SDKs in TypeScript, Python, Go and .NET which are also checked in to the sdk folder. The SDKs are generated from a schema in schema.yaml. This file should be kept aligned with the component resources supported by the component provider implementation.

An example of using the StaticPage component in TypeScript is in examples/simple.

Note that the generated provider plugin (pulumi-resource-xyz) must be on your PATH to be used by Pulumi deployments. If creating a provider for distribution to other users, you should ensure they install this plugin to their PATH.

Prerequisites

  • Go 1.15
  • Pulumi CLI
  • Node.js (to build the Node.js SDK)
  • Yarn (to build the Node.js SDK)
  • Python 3.6+ (to build the Python SDK)
  • .NET Core SDK (to build the .NET SDK)

Build and Test

# Build and install the provider (plugin copied to $GOPATH/bin)
make install_provider

# Regenerate SDKs
make generate

# Test Node.js SDK
$ make install_nodejs_sdk
$ cd examples/simple
$ yarn install
$ yarn link @pulumi/xyz
$ pulumi stack init test
$ pulumi config set aws:region us-east-1
$ pulumi up

Naming

The xyz provider's plugin binary must be named pulumi-resource-xyz (in the format pulumi-resource-<provider>).

While the provider plugin must follow this naming convention, the SDK package naming can be customized. TODO explain.

Example component

Let's look at the example StaticPage component resource in more detail.

Schema

The example StaticPage component resource is defined in schema.yaml:

resources:
  xyz:index:StaticPage:
    isComponent: true
    inputProperties:
      indexContent:
        type: string
        description: The HTML content for index.html.
    requiredInputs:
      - indexContent
    properties:
      bucket:
        "$ref": "/aws/v4.0.0/schema.json#/resources/aws:s3%2Fbucket:Bucket"
        description: The bucket resource.
      websiteUrl:
        type: string
        description: The website URL.
    required:
      - bucket
      - websiteUrl

The component resource's type token is xyz:index:StaticPage in the format of <package>:<module>:<type>. In this case, it's in the xyz package and index module. This is the same type token passed to RegisterComponentResource inside the implementation of NewStaticPage in provider/pkg/provider/staticPage.go, and also the same token referenced in Construct in provider/pkg/provider/provider.go.

This component has a required indexContent input property typed as string, and two required output properties: bucket and websiteUrl. Note that bucket is typed as the aws:s3/bucket:Bucket resource from the aws provider (in the schema the / is escaped as %2F).

Since this component returns a type from the aws provider, each SDK must reference the associated Pulumi aws SDK for the language. For the .NET, Node.js, and Python SDKs, dependencies are specified in the language section of the schema:

language:
  csharp:
    packageReferences:
      Pulumi: 3.*
      Pulumi.Aws: 4.*
  go:
    generateResourceContainerTypes: true
    importBasePath: github.com/pulumi/pulumi-xyz/sdk/go/xyz
  nodejs:
    dependencies:
      "@pulumi/aws": "^4.0.0"
    devDependencies:
      typescript: "^3.7.0"
  python:
    requires:
      pulumi: ">=3.0.0,<4.0.0"
      pulumi-aws: ">=4.0.0,<5.0.0"

For the Go SDK, dependencies are specified in the sdk/go.mod file.

Implementation

The implementation of this component is in provider/pkg/provider/staticPage.go and the structure of the component's inputs and outputs aligns with what is defined in schema.yaml:

// The set of arguments for creating a StaticPage component resource.
type StaticPageArgs struct {
    IndexContent pulumi.StringInput `pulumi:"indexContent"`
}

// The StaticPage component resource.
type StaticPage struct {
    pulumi.ResourceState

    Bucket     *s3.Bucket          `pulumi:"bucket"`
    WebsiteUrl pulumi.StringOutput `pulumi:"websiteUrl"`
}

// NewStaticPage creates a new StaticPage component resource.
func NewStaticPage(ctx *pulumi.Context, name string, args *StaticPageArgs, opts ...pulumi.ResourceOption) (*StaticPage, error) {
    ...
}

The provider makes this component resource available in the construct function in provider/pkg/provider/provider.go. When construct is called and the typ argument is xyz:index:StaticPage, we create an instance of the StaticPage component resource and return its URN and state.

func constructStaticPage(ctx *pulumi.Context, name string, inputs provider.ConstructInputs,
    options pulumi.ResourceOption) (*provider.ConstructResult, error) {

    // Copy the raw inputs to StaticPageArgs. `inputs.CopyTo` uses the types and `pulumi:` tags
    // on the struct's fields to convert the raw values to the appropriate Input types.
    args := &StaticPageArgs{}
    if err := inputs.CopyTo(args); err != nil {
        return nil, errors.Wrap(err, "setting args")
    }

    // Create the component resource.
    staticPage, err := NewStaticPage(ctx, name, args, options)
    if err != nil {
        return nil, errors.Wrap(err, "creating component")
    }

    // Return the component resource's URN and state. `NewConstructResult` automatically sets the
    // ConstructResult's state based on resource struct fields tagged with `pulumi:` tags with a value
    // that is convertible to `pulumi.Input`.
    return provider.NewConstructResult(staticPage)
}
Similar Resources

Pulumi provider for Proxmox

Terraform Bridge Provider Boilerplate This repository contains boilerplate code for building a new Pulumi provider which wraps an existing Terraform p

Nov 28, 2021

Pulumi provider for Vultr (based on the Terraform one), not official

Vultr Resource Provider The Vultr Resource Provider lets you manage Vultr resources. Installing This package is currently not available for most langu

Apr 23, 2022

A boilerplate showing how to create a native Pulumi provider

xyz Pulumi Provider This repo is a boilerplate showing how to create a native Pu

Dec 29, 2021

Sample Hello World Pulumi Program for Azure

Overview This is a standard hello world style Pulumi program for Azure straight from the Pulumi docs. This is a sample repo used to test Pulumi's Auto

Jan 13, 2022

An Oracle Cloud (OCI) Pulumi resource package, providing multi-language access to OCI

Oracle Cloud Infrastructure Resource Provider The Oracle Cloud Infrastructure (OCI) Resource Provider lets you manage OCI resources. Installing This p

Dec 2, 2022

Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider.

dredger Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider. Dredger is made of dark magic and cannot full

Aug 25, 2022

Dependency management solution for Hashicorp Terraform modules

TERRADEP This is the module dependency solution for implementing terraform's modules dependency. Using this, users can now manage dependencies both fr

Dec 21, 2021

Terraform-in-Terraform: Execute Modules directly from the Terraform Registry

Terraform-In-Terraform Provider This provider allows running Terraform in Terraform. This might seem insane but there are some edge cases where it com

Dec 25, 2022
Comments
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • provider/go.mod (gomod)
    • sdk/go.mod (gomod)
    • sdk/nodejs/package.json (npm)
    • sdk/dotnet/Pulumi.Xyz.csproj (nuget)
    • sdk/python/setup.py (pip_setup)

    Configuration

    🔡 Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 7 Pull Requests:

    Update dependency Microsoft.SourceLink.GitHub to v1.1.1
    • Schedule: ["at any time"]
    • Branch name: renovate/microsoft.sourcelink.github-1.x
    • Merge into: main
    • Upgrade Microsoft.SourceLink.GitHub to 1.1.1
    Update module github.com/pulumi/pulumi-aws/sdk/v4 to v4.38.1
    Update module github.com/pulumi/pulumi/pkg/v3 to v3.47.1
    Update module github.com/pulumi/pulumi/sdk/v3 to v3.47.1
    Update module go to 1.19
    • Schedule: ["at any time"]
    • Branch name: renovate/go-1.x
    • Merge into: main
    • Upgrade go to 1.19
    Update dependency @​pulumi/aws to v5
    • Schedule: ["at any time"]
    • Branch name: renovate/pulumi-aws-5.x
    • Merge into: main
    • Upgrade @pulumi/aws to ^5.0.0
    • Upgrade pulumi-aws to >=5.21.1,<5.22.0
    Update dependency typescript to v4
    • Schedule: ["at any time"]
    • Branch name: renovate/typescript-4.x
    • Merge into: main
    • Upgrade typescript to ^4.0.0

    🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or spam the project. See docs for prhourlylimit for details.


    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

Pulumi-tencentcloud - Pulumi provider for tencentcloud

Terraform Bridge Provider Boilerplate This repository contains boilerplate code

Dec 30, 2021
Pulumi-hcp - A Pulumi provider for interacting with the Hashicorp Cloud Platform

Terraform Bridge Provider Boilerplate This repository contains boilerplate code

Dec 5, 2022
Go-gke-pulumi - A simple example that deploys a GKE cluster and an application to the cluster using pulumi

This example deploys a Google Cloud Platform (GCP) Google Kubernetes Engine (GKE) cluster and an application to it

Jan 25, 2022
Pulumi-k8s-operator-example - OpenGitOps Compliant Pulumi Kubernetes Operator Example

Pulumi GitOps Example OpenGitOps Compliant Pulumi Kubernetes Operator Example Pr

May 6, 2022
Running OpenFaas Pro on Linode K8s (feat. Aiven and Pulumi)

Running OpenFaas Pro on Linode K8s (feat. Aiven and Pulumi) Alex Ellis did a great job, when he wrote a tutorial about Event-driven OpenFaaS with Mana

Apr 26, 2022
A Pulumi Kubernetes CertManager component

Pulumi Cert Manager Component This repo contains the Pulumi Cert Manager component for Kubernetes. This add-on automates the management and issuance o

Nov 30, 2022
A Pulumi Kubernetes CoreDNS component

Pulumi Kubernetes CoreDNS Component This repo contains the Pulumi CoreDNS component for Kubernetes. CoreDNS is a fast and flexible DNS server, providi

Dec 1, 2021
A Pulumi NGINX Ingress Controller component

Pulumi NGINX Ingress Controller Component This repo contains the Pulumi NGINX Ingress Controller component for Kubernetes. This ingress controller use

Aug 10, 2022
Pulumi provider for the Elasticsearch Service and Elastic Cloud Enterprise

Terraform Bridge Provider Boilerplate This repository contains boilerplate code for building a new Pulumi provider which wraps an existing Terraform p

Nov 18, 2022
Terraform Provider Pulumi for golang

Terraform Provider Pulumi This is the transcend-io/pulumi provider available on the Terraform registry. It's goal is to allow terraform projects to co

Sep 1, 2022