Can I pass multiple providers to a resource to allow deploying to two targets? #8734
-
In my scenario I'm trying to use the yaml renderer to generate the K8 deployment yaml, while also wanting to try and use Pulumi directly. Should this be possible or would it require me to duplicate the stack config with one being yaml and one being k8, which manages two state files separately based on stack? It seems the What I'm currently doing
What I'd like to be able to do:
Otherwise, I'm assuming I'd need to duplicate my stack config and treat the yaml like a new stack, one which deploys to the yaml in the directory and the other for deploying to k8 as a new environment with both having unique state files. Would be great to get some expertise and know what is the best route. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @sheldonhull,
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 😅 |
Beta Was this translation helpful? Give feedback.
Hey @sheldonhull,
provider
in thepulumi.CustomResourceOptions
doesn't support taking a list of providers.You could write a multiplexer function though:
Warning: I've not tested this code, but it looks OK 😅