prehistoric-kite-30979
11/12/2021, 12:54 PMOutput<Object<string>>
to Object<Input<string>>
without having to explicitly list all the fields?happy-parrot-60128
11/12/2021, 1:14 PMObject
your own type in your example, something like this but with more fields?
interface Object<T> { field: T }
Also, can you give more detail as to what's requiring the input to be in the latter form? Often input types are nested to give you flexibility on which way round your input's are structured e.g.
type ExampleInput = pulumi.Input<{
field: pulumi.Input<string>;
}>
prehistoric-kite-30979
11/12/2021, 1:37 PMexport function AzureMinimal(
name: string,
args: MinimalOptionsArgs<pulumi.Input<string>>,
opts?: ProviderOptions,
): AzureMinimalOptions {
const provider = new azure.Provider(
name,
{
subscriptionId: args.subscriptionId,
tenantId: args.tenantId,
},
opts,
)
return {
...args,
provider,
}
}
This works except when calling it I have to explicitly pass fields…
Works…
options.AzureMinimal('azure', {
subscriptionId: cloud.metadata.subscriptionId,
tenantId: 'some-uuid,
}),
Doesnt work…
options.AzureMinimal('azure', {
...cloud.metadata,
tenantId: 'some-uuid,
}),
interface MinimalOptionsArgs<StringOrIntputString> extends CustomResourceOptions {
subscriptionId: StringOrIntputString
tenantId: StringOrIntputString
}
(This is obviously fine for minimal opts but some get a bit larger)happy-parrot-60128
11/12/2021, 2:23 PMprehistoric-kite-30979
11/12/2021, 2:23 PMhappy-parrot-60128
11/12/2021, 2:27 PMcloud.metadata
is an output of your desired fields, could you try doing the following?
options.AzureMinimal('azure', cloud.metadata.apply(metadata => ({
...metadata,
tenantId: 'some-uuid,
}))),
prehistoric-kite-30979
11/12/2021, 2:30 PMhappy-parrot-60128
11/12/2021, 2:58 PM