bland-monitor-37952
06/25/2025, 10:27 PMexport interface IP {
...
address: string;
...
}
export interface IVirtualMachine {
...
primaryIp: IP;
...
}
Elsewhere I'm passing objects defined as IVirtualMachine around between ComponentResource objects, and accessing vm.primaryIp.address
without issue, but this is the first time I've tried to use one within a dynamic provider.
My resource constructor has this interface for `args`:
interface GetReadyInputs {
clientConfiguration: pulumi.Input<ClientConfiguration>;
nodes: pulumi.Input<IVirtualMachine[]>;
}
and the provider async create
function expects this:
interface GetReadyProviderInputs {
clientConfiguration: ClientConfiguration;
nodes: IVirtualMachine[];
}
But if I try and access the properties of an IVirtualMachine
within the provider I get errors for Cannot read properties of undefined
.
Some judicious console.log
output tells me it's because the value of each item in the nodes
list at that point seems to be a Pulumi string URN, not an object satisfying IVirtualMachine
. So how am I supposed to be passing these objects around so that I can correctly access the properties of them within my provider.
For what it's worth the values I'm trying to access are known at compile time, not looked up at run time, but if they could be that would be amazing and future-proof my code.little-cartoon-10569
06/25/2025, 10:58 PMcheck()
? Or just their URNs?bland-monitor-37952
06/26/2025, 5:54 AMcheck()
function. All the other objects I'd passed, including ones that were nested structures, were available fully without it, so I was expecting the same to be true in this case.
From your pointer I get that if I wanted my values to be resolvable at runtime I'd probably need check()
to do a lookup to fill them in, but given that currently they're available compile-time I was expecting it to Just Work (tm).bland-monitor-37952
06/26/2025, 5:58 AMComponentResource
object as well, but treating them as such wasn't something I thought was important here. That may be an incorrect assumption.
We had problems with CDK where we ended up with deeply nested class hierarchies because TypeScript only does single-inheritance and we were using full classes everywhere. As we try to do a greenfield project in Pulumi we're really trying to avoid the same thing happening, so we wanted to be able to define interfaces which each class may implement multiple of, and each other class only references the interfaces that are relevant to it rather than a concrete class.echoing-dinner-19531
06/26/2025, 7:13 AMbland-monitor-37952
06/26/2025, 8:25 AMbland-monitor-37952
06/26/2025, 8:42 AMechoing-dinner-19531
06/26/2025, 9:02 AMbland-monitor-37952
06/26/2025, 9:22 AMpulumi.Input<IVirtualMachine[]>
correct, or should it be pulumi.Input<IVirtualMachine>[]
? Is it an input which contains a list, or a list of inputs?
I don't seem to be able to unwrap the former to get at the properties of individual IVirtualMachine
objects, so I'm guessing I want the latter.
I'm keen to get this right because it's greenfield. So anything which I get wrong/have as a bad pattern will probably end up replicated all over the place for other components and then become massively hard to unpick.
Also, I know properties in Pulumi can be marked as secret so they are encrypted in state. I don't see a way to do that with dynamic providers?echoing-dinner-19531
06/26/2025, 9:28 AM