https://pulumi.com logo
b

brash-quill-35776

08/10/2021, 3:57 AM
Hi, I would like to use StackReference to get k8s
ClusterProvider
from pipeline A and use it in pipeline B. When I do so, I am able to see the
ClusterProvider
in pipeline B properly but, since it is of type
Output<Provider>
, I can't use it as a provider for k8s Namespace resource
Copy code
const reference = new pulumi.StackReference("A-dev");
const clusterProvider = reference.requireOutput("clusterProvider").get();

const ns = new k8s.core.v1.Namespace("cluster", {
}, { provider: clusterProvider });
// getting error when pulumi up
Copy code
Error: Cannot call '.get' during update or preview.
    To manipulate the value of this Output, use '.apply' instead.
        at Proxy.get (/Users/u6105440/Workspace/tr/Stratus/a207937_stratus-namespace/node_modules/@pulumi/pulumi/output.js:173:15)
        at Object.<anonymous> (/Users/u6105440/Workspace/tr/Stratus/a207937_stratus-namespace/src/config.ts:7:75)
        at Module._compile (node:internal/modules/cjs/loader:1101:14)
        at Module.m._compile (/Users/u6105440/Workspace/tr/Stratus/a207937_stratus-namespace/node_modules/ts-node/src/index.ts:439:23)
        at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
        at Object.require.extensions.<computed> [as .ts] (/Users/u6105440/Workspace/tr/Stratus/a207937_stratus-namespace/node_modules/ts-node/src/index.ts:442:12)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Module.require (node:internal/modules/cjs/loader:1005:19)
        at require (node:internal/modules/cjs/helpers:94:18)
I understand that the
provider
property is not Input that blocks it from accepting the
Output<Provider>
, and using
get()
or
apply()
will also having issues. In this case, how do I get it around? I need this
ClusterProvider
to use as k8s provider for the following resources
b

billowy-army-68599

08/10/2021, 3:59 AM
you don't need the
get
property at the end there, I think
b

brash-quill-35776

08/10/2021, 4:00 AM
ya, tried without
get
which gives me of
Output
, this can't be passed to the
provider
property because
provider
is not
Input
type
b

bored-oyster-3147

08/10/2021, 11:12 AM
You’re going to want your stack output to be the information you need to build the provider instead of the provider object
b

brash-quill-35776

08/10/2021, 2:10 PM
Sorry I don't fully understand your suggestions, I am using K8S Cluster Provider in the project A, therefore I want to reuse it in project B just like passing variables. Are you saying I must create a
provider
thing to achieve that?
Hi @bored-oyster-3147 Thanks for pointing this out, well actually this is how I implement it in my first version. If that's the only way to do so, then I must get information below to construct a
K8s.Provider
object, which totally makes sense as this is how I use it in project A anyway. 1. endpoint 2. masteAuth 3. cluster name Since the
StackReference
provide access to output value, I was thinking of accessing the
ClusterProvider
object directly instead of constructing it the same way I did in project A. Are you saying that it is not possible to directly reference an output from StackReference?
b

bored-oyster-3147

08/10/2021, 2:21 PM
I’m saying look at the ProviderArgs class. It accepts Input<T> values which means you can use Outputs to construct it. So instead of outputting the Provider itself in Project A, output the values that you need to construct it and then instantiate a new instance of the Provider in project B.
b

brash-quill-35776

08/10/2021, 2:27 PM
I see, that's exactly what I mentioned above. Although I know could definitely work for sure, doing so would have to create redundant object across different stack(which is not a big deal tho). I was trying to directly use the output of project A in project B as if they are in a single project. But if you are indicating there is no way to do that, I am happy to use my first implementation then. Thank you
b

bored-oyster-3147

08/10/2021, 2:29 PM
The Provider object is not a resource that is represented in cloud so personally I see no problem with creating it twice. It’s more of an ephemeral object than anything
👍 1
But in the event that it was a cloud represented object, I still would prefer the route of outputting an ID and doing one of the Get methods
b

brash-quill-35776

08/10/2021, 2:48 PM
make sense
thank you so much
5 Views