https://pulumi.com logo
b

best-xylophone-83824

08/09/2019, 1:57 PM
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

white-balloon-205

08/09/2019, 5:54 PM
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

best-xylophone-83824

08/09/2019, 6:34 PM
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

white-balloon-205

08/09/2019, 6:37 PM
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

best-xylophone-83824

08/09/2019, 7:48 PM
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

high-translator-22614

08/09/2019, 8:58 PM
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

white-balloon-205

08/09/2019, 9:20 PM
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?