breezy-butcher-78604
11/04/2019, 3:18 AMawsx.ec2.Vpc.fromExistingIds()
method but can’t quite figure out how to supply the right IDs. here’s what I’ve got so far:
function toArray<T>(v: T | T[]) {
return Array.isArray(v) ? v : [v];
}
const cfg = new pulumi.Config();
// Grab the VPC ID from the existing VPC stack
const vpcStack = new pulumi.StackReference(cfg.require("vpcStack"));
// Now create a VPC object from the id
const vpc = awsx.ec2.Vpc.fromExistingIds("vpc", {
vpcId: vpcStack.getOutput("vpcId"),
publicSubnetIds: toArray(vpcStack.getOutput("publicSubnetIds"))
});
however when running pulumi up, i get the below error message.
I’m pretty new to typescript so my guess is I’m not handling the Output<T>
type returned from getOutput()
properly. the output should be an array of subnet IDs, eg:
[
"subnet-abcdefg123456",
"subnet-foobah12345",
"subnet-blahblahblah"
]
however it appears its not making it through properly.tall-librarian-49374
11/04/2019, 7:31 AMvpcStack.getOutput("publicSubnetIds").apply(toArray)
breezy-butcher-78604
11/04/2019, 7:37 AMtall-librarian-49374
11/04/2019, 7:46 AMpublicSubnetIds
is not great - it doesn't allow an Output
. Try toArray(vpcStack.getOutputSync("publicSubnetIds"))
?breezy-butcher-78604
11/04/2019, 7:53 AM