sparse-intern-71089
03/19/2021, 2:53 PMbored-oyster-3147
03/19/2021, 3:27 PMazure_native.authorization.getClientConfig() returns something like Output<ClientConfig> so if you pass it to pulumi.output(...) you're getting Output<Output<ClientConfig>> which isn't what you want.
this should suffice:
var clientClient = azure_native.authorization.getClientConfig();
var subscriptionId = clientConfig.apply(c => c.subscriptionId);
Keep in mind that when you do this subscriptionId is still Output<string> so you can't just manipulate it like you would a string, it is still an output that needs to be asynchronously evaluated.ancient-night-64850
03/19/2021, 3:45 PMbored-oyster-3147
03/19/2021, 3:56 PMancient-night-64850
03/19/2021, 4:01 PMancient-night-64850
03/19/2021, 4:03 PMbored-oyster-3147
03/19/2021, 4:08 PMpulumi.output(...) the promise that getClientConfig() returns. Then you can var subscriptionId = clientConfig.apply(c => c.subscriptionId);. Then you can pass that to your resource.bored-oyster-3147
03/19/2021, 4:09 PMRegisterOutputs() at the end otherwise your pulumi execution will not wait for your promises to finish because it won't be aware of them.bored-oyster-3147
03/19/2021, 4:10 PMancient-night-64850
03/19/2021, 4:12 PMancient-night-64850
03/19/2021, 4:12 PMbored-oyster-3147
03/19/2021, 4:13 PMexport const azid = "azure id: " + azureSubscriptionId;
this line won't work because you can't concatenate types string and Output<T> .
Instead you would want to:
export const azid = azureSubscriptionId.apply(x => "azure id: " + x);ancient-night-64850
03/19/2021, 4:21 PMbored-oyster-3147
03/19/2021, 4:23 PMazureSubscriptionId was not Output<string> it was Output<Promise<T>>ancient-night-64850
03/19/2021, 4:25 PMbored-oyster-3147
03/19/2021, 4:28 PMconst clientConfig = azure_native.authorization.getClientConfig();
With this clientConfig should be Promise<GetClientConfigResult>
const clientConfig = pulumi.output(azure_native.authorization.getClientConfig());
With this clientConfig should be Output<GetClientConfigResult>
var azureSubscriptionId = clientConfig.apply(c => c.subscriptionId);
Now azureSubscriptionId should be Output<string>
Which should allow you to:
export const azid = azureSubscriptionId.apply(x => "azure id: " + x);
and still have an Output<string>
There had to have been a step that was missed if you still had a Promise<T> on the third line.ancient-night-64850
03/19/2021, 4:58 PMbored-oyster-3147
03/19/2021, 5:09 PMpulumi.output(...) here: https://github.com/pulumi/examples/blob/4529da55208d11bc708d88b8694f92f73455500d/linode-js-webserver/index.ts
and we can see here that linode GetProfile also returns `Promise<TResult>`: https://www.pulumi.com/docs/reference/pkg/linode/getprofile/
And they are just accessing the properties on that directly after that. So maybe yours should only be 2 lines?
Like this:
const clientConfig = pulumi.output(azure_native.authorization.getClientConfig());
export const azid = clientConfig.subscriptionId.apply(x => "azure id: " x);bored-oyster-3147
03/19/2021, 5:11 PMclientConfig.subscriptionId is type string you might not need the .apply(...)ancient-night-64850
03/19/2021, 5:50 PMancient-night-64850
03/19/2021, 5:50 PM