Thread
#general
    b

    brief-baker-41837

    1 month ago
    Hi, I am trying to create a VPC and then query the result object to get the private subnet but it is always failing with the following error during preview itself:
    * multiple EC2 Subnets matched; use additional constraints to reduce matches to a single EC2 Subnet
    I cant seem to figure out the cause specially when this is occurring in preview itself. Please help.
    vpc = awsx.ec2.Vpc("pulumi-test",cidr_block='10.2.0.0/16',subnet_specs=[
          awsx.ec2.SubnetSpecArgs(
            type=awsx.ec2.SubnetType.PRIVATE,
            cidr_mask=26,
          ),
          awsx.ec2.SubnetSpecArgs(
            type=awsx.ec2.SubnetType.PUBLIC,
            cidr_mask=26,
          )
        ], number_of_availability_zones=1)
    
    subnet = aws.ec2.get_subnet(id=vpc.private_subnet_ids[0])
    b

    billowy-army-68599

    1 month ago
    you’re querying the subnets at the same time you’re creating them, you need to make sure the subnet query happens after the vpc creation with depends_on It’s not really clear why you’re doing this however
    b

    brief-baker-41837

    1 month ago
    1. So preview command actually queries the resources on aws to get the results? 2. I think depends_on is a resource option and cannot be used for get_* functions which hqve invoke_option. Let me know if im wrong. 3. Simce im still testing out pulumi, i was trying to get the zone in which the subnet is created to use later on in code.
    @billowy-army-68599 thoughts?