Looking for some `StackReference` type conversion ...
# typescript
Looking for some
type conversion help, or maybe it's the standard Output/Input handling stuff that I need? I'm accessing the details of a VPC from a StackReference, and I need the
as an
to an
- whats the best way to be able to treat the subnet output from the StackReference into an array? Or even better - can I grab the full vpc Output object and then interrogate it to get the subnetId I need?
Copy code
const devopsVpc = vpcStack.getOutput("devopsVpc"); // Full VPC output - can I get this and use it like it was created in this stack? 
const devopsVpcPublicSubnetIds = vpcStack.getOutput("devopsVpcPublicSubnetIds"); // Output<any> - can I coerce this to an array?
// output in this stack is Array:
// Outputs:
// + subnetIds: [
//   +     [0]: "subnet-06a**********3fe0"
//   +     [1]: "subnet-036**********c6b7"
//     ]

// but how to access as an array as input to EC2 creation?
// just need a single subnetId
const host = new ec2.Instance("bastionHost", {
  ami: ubuntuAmi,
  tags: { "Name": "hostthemost" },
  instanceType: "t2.medium",
  subnetId: devopsVpcPublicSubnetIds[0], // <-- throws since not an array type
//   ...other props...

export const subnetIds = devopsVpcPublicSubnetIds; // show sup as an array Output (see above)
yeah you can do what's called "type assertion"
Copy code
const devopsVpcPublicSubnetIds = vpcStack.getOutput("devopsVpcPublicSubnetIds") as Output<Array<string>>
you can do something similar with the
thanks! Was trying the prefix approach but didn't think to wrap everything in an <Output<Type>>
p 1