Hmmm I'm using aws-native provider. I can lookup a...
# general
h
Hmmm I'm using aws-native provider. I can lookup a vpc, easy. But I'm having a hard time finding out how to go from this VPC to the subnets and their CIDR ranges. Any hints?
m
Maybe this example could help? It shows looking up.a VPC and then using it to provision other resources. If not, maybe you could share a little code that shows more what you’re running into.
h
Hmmm,
Copy code
// Note: Some resources are not yet supported by the Native AWS provider, so we are using both the Native
// and Classic provider in this example. The resources will be updated to use native resources as they are
// available in AWS's Cloud Control API.

const defaultVpc = aws.ec2.getVpcOutput({default: true});
const defaultVpcSubnets = aws.ec2.getSubnetIdsOutput({vpcId: defaultVpc.id});
It seems these are the 2 lines, but they are from the classic provider 😞
m
Can you share some of your code? That might help.
(To see what it is you’re trying to do, exactly.)
h
I'm just playing around with the native provider. Nothing of use. Basically stuff like this:
Copy code
lookupVpcArgs := &ec2.LookupVPCArgs{
		VpcId: *pulumi.StringRef("vpc-0b966da8f364dfd1b"),
	}

	vpc, err := ec2.LookupVPC(ctx, lookupVpcArgs, nil)
	if err != nil {
		return nil, err
	}
	log.Printf("vpc: %v", spew.Sprint(vpc))
        return nil, fmt.Errorf("I made a booboo!")
m
Ok. Still not quite sure what you mean by “go from the VPC to the subnets”, but if you mean work with the results of the lookup, is this the kind of thing you’re looking for?
Copy code
vpc, err := ec2.LookupVPC(ctx, &ec2.LookupVPCArgs{
	VpcId: *pulumi.StringRef("vpc-abc123"),
})
if err != nil {
	return err
}

<http://ctx.Log.Info|ctx.Log.Info>(*vpc.VpcId, &pulumi.LogArgs{})

for i := 0; i < len(vpc.CidrBlockAssociations); i++ {
	<http://ctx.Log.Info|ctx.Log.Info>(vpc.CidrBlockAssociations[i], &pulumi.LogArgs{})
}
(That’s using aws-native)