Skip to content

Resource option: providers ​

The providers resource option is supported only on component resources. It sets a map of providers (keyed by package name) for the component and its child resources — the map flows from the component to every child via parent inheritance. To pass an explicit provider to a single custom resource, use the provider option instead.

When the SDK creates a resource it picks a provider by checking, in order:

  1. The explicit provider option, if set.
  2. A matching provider in the resource's providers map (looked up by package name).
  3. A matching provider inherited from the parent's providers map.

The first match wins. So a child resource created with a component as its parent automatically picks up the matching provider from the component's inherited map — a child aws.s3.Bucket picks up the aws provider, a child kubernetes.helm.v3.Chart picks up the kubernetes provider, and so on. If a component is itself a child of another component, its providers are inherited from that parent in turn.

Example ​

A component can be instantiated multiple times against different sets of providers. Suppose MyComponent deploys a regional AWS database alongside a Helm chart on a Kubernetes cluster in the same region. To run the component in two regions from a single Pulumi program, declare a separate AWS provider and Kubernetes provider for each region, then pass the matching pair into each component instance via the providers map.

typescript
import * as aws from "@pulumi/aws";
import * as k8s from "@pulumi/kubernetes";

const awsEast = new aws.Provider("aws-east", { region: "us-east-1" });
const awsWest = new aws.Provider("aws-west", { region: "us-west-2" });

const k8sEast = new k8s.Provider("k8s-east", { kubeconfig: kubeconfigEast });
const k8sWest = new k8s.Provider("k8s-west", { kubeconfig: kubeconfigWest });

const east = new MyComponent("east", {}, {
    providers: { aws: awsEast, kubernetes: k8sEast },
});

const west = new MyComponent("west", {}, {
    providers: { aws: awsWest, kubernetes: k8sWest },
});

Content from the official Pulumi documentation (github.com/pulumi/docs).