Skip to content

Can I pass multiple providers to a resource to allow deploying to two targets? #8734

Discussion options

You must be logged in to vote

Hey @sheldonhull,

provider in the pulumi.CustomResourceOptions doesn't support taking a list of providers.

You could write a multiplexer function though:

const multiplexer = (resource: pulumi.Resource): pulumi.Resource[] => {
  const resources: pulumi.Resource[] = [resource];

  const additionalProviders = [
    new k8s.Provider("provider-eu", {
        kubeconfig: "",
    });
  ];

  return [ resource, ...additionalProviders.map((provider): pulumi.Resource => Object.assign(resource, { opts: { provider, } }))];
}

Warning: I've not tested this code, but it looks OK 😅

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sheldonhull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants