https://pulumi.com logo
Title
h

hundreds-receptionist-31352

02/10/2021, 1:47 PM
Hi, I have this class returning a pulumi.Output<vpc>
class Vpc {
....
cidr = getCidr() // get a cidr from database
...
const vpc = pulumi.all([cidr]).apply(cidr)=>
{
return new vpcConfig('vpc',{cidr})
}
....
this.vpc=vpc
}
I need to return only type <vpc> ( I could do it without using pulumi.all inside of this class), otherwide I have to use another pulumi.all when using it
const vpc = new Vpc(.....)
pulumi.all([vpc]).apply(vpc) =>
{
new eks.cluster('.....', vpc)
}
is there any way to avoid using too much pulumi.all and get only the object type that I need( <vpc> in this case ) ? thanks in advance
w

witty-candle-66007

02/10/2021, 2:21 PM
If you can share your code in it’s entirety, that may help. But, a couple of things that I notice. You shouldn’t have to use pulumi.all() in this case and go straight to
.apply()
such as follows:
cidr.apply(cidr => return new vpcConfig(vpc,{cidr})
The
.all
is really only needed if there are multiple values you need to resolve. import { baseTags, projectName, stackName, } from “./config”;
And if I’m reading your example correctly, in your class, you should be able to return just the vpc.id since the
new eks cluster()
only needs the ID, or reference
vpc.id
in the
new eks.cluster()
part which I think will lift the value so an apply is not needed.