b

    bitter-psychiatrist-55958

    5 months ago
    Hello, I have a simple VPC where I am trying to get a subnet ID to use in an
    aws.ec2.NetworkInterface
    . The VPC is defined as:
    const vpc = new awsx.ec2.Vpc("culex-vpc", {
      cidrBlock: "10.50.0.0/16",
      numberOfAvailabilityZones: 1,	// defaults to 2, but for a lab 1 is good enuf
      subnets: [
        { type: "public", location: "10.50.20.0/24", tags },
        { type: "private", location: "10.50.30.0/24", tags }
      ],
      tags
    });
    How would I get the private subnet to use in the
    subnetId
    property in
    aws.ec2.NetworkInterface
    ? I tried using
    subnetId: vpc.id.apply(async () => vpc.privateSubnetsIds),
    as seen above here, but have issues with it being the wrong type for
    subnetId
    .
    e

    echoing-dinner-19531

    5 months ago
    b

    bitter-psychiatrist-55958

    5 months ago
    TypeScript is upset about the type.
    Subnet ID to create the ENI in.
    
    Type 'Promise<Subnet[]>' is not assignable to type 'Input<string>'.
      Type 'Promise<Subnet[]>' is not assignable to type 'Promise<string>'.
        Type 'Subnet[]' is not assignable to type 'string'.ts(2322)
    networkInterface.d.ts(339, 5): The expected type comes from property 'subnetId' which is declared here on type 'NetworkInterfaceArgs'
    e

    echoing-dinner-19531

    5 months ago
    Hmm maybe something like
    output(vpc.privateSubnets()).apply(subnets => subnet[0].id)
    ?
    b

    bitter-psychiatrist-55958

    5 months ago
    thanks!
    subnetId: output(vpc.getSubnets("private").then(subnet => subnet[0].id)),
    gets the type error to go away 😄 lets see if it actually works!
    looks like that worked! thanks @echoing-dinner-19531 on to the next issue 😄