how can I configure ambient provider from index.ts...
# general
b
how can I configure ambient provider from index.ts itself without reparenting all resources under ComponentResource? I have bootstrap pulumie project with a single stack which creates GCP projects and service accounts with key made available in stack output. Idea is that individual pulumi projects should then reference that stack get key from it's output and then configure ambient provider to use it
w
Until #2059 is addressed, note that you can move things into components if you want - and use
aliases
on the instance of the component to adopt the existing resources without having to replace anything. 2059 is definitely the most direct solution to this scenario though.
b
hm, what if I
dummyResource(name, {}, { alias : pulumi.runtime.getRootResource, provider: mynewGlobalProvider})
? would it reparent all resources under dummy resource and as a result make all resources use new provider by default?
w
I do not believe that would work - though I'll admit I've never thought to try that specific approach 🙂. If it does - that's an intriguing workaround for 2059.
b
Didn't work 🙂
Copy code
class DummyRoot extends pulumi.ComponentResource {
   constructor(name: string, opts : pulumi.ComponentResourceOptions) {
      super("dummy", name, {}, opts)
      this.registerOutputs({})
   }
}

new DummyRoot("dummy", { provider: provider, aliases: [pulumi.runtime.getRootResource() as Promise<pulumi.URN>] });
new gcp.compute.Network("vpc_network", {})
h
The way I handled this in python (to handle localstack switching) was to define an
opts()
that inserted providers if there's no parent, eg:
foo.Bar('MyBar', ..., **opts())
as for shuffling data between stacks, this is an extremely common question but I haven't seen a satisfactory answer yet.
w
shuffling data between stacks
What precisely did you have in mind here? We have the following tools: 1. StackReference 2.
import
3.
aliases
Depending on which versions of this you are trying to do - one or more of those should help?