Some background:
We have an extended ResourceOptions library that helps us explicitly require that a provider be for azure/aws, etc. It also does other things but lets keep it simple for now…
I’m trying to write some helper functions that take args and build out these options so that we can pass stack references outputs to them.
export 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)