In one of my js file, I created a k8s provider wit...
# typescript
e
In one of my js file, I created a k8s provider with
Copy code
const provider = new k8s.Provider("k8s", {
  kubeconfig: stack.getOutput("kubeconfig"),
});
How can I reuse this provider in multiple js files? I’d expect some
pulumi.getResourceByName
stuff
b
Wouldn't exporting it and importing it be enough?
e
I don’t really know how that is achieved in typescript.
e
Yes. That’s one way to organize it
b
I would generally recommend using component resources instead of this approach, however. If you could describe a little more what you're ultimately trying to achieve, it would help me help you
e
This approach looks goo.d
What’s the component approach?
e
I feel these two approaches are basically the same. We define a resource and import it to the index.js. The former is more versatile because it has shared config.
@billowy-army-68599 I am interested in that, if there is a way to retrieve a resource based by name.
For example, res = pulumi.getResource(“some-defined-resource-name”)
b
@echoing-activity-32278 there isn't a way based on the state, but you can
get
a function that's in the cloud already using a data lookup
e
Could you share with me an example code? Thanks
b
@echoing-activity-32278 what resource are you trying to look up?
e
I am using azure native, I want to access whatever azure native resources I have applied through pulumi based on the unique name I specified.