Listing nodes using jclouds

55 Views Asked by At

Is it possible to list nodes in a non-default AWS VPC? This can be done easily using EC2::DescribeInstances by passing a filter with vpc-id= but I can't figure out how to do it using jclouds.

I know how to create an instance in a specified VPC using template options, but I cannot find an equivalent approach for listing nodes. I'm currently using listNodesDetailsMatching(...).

1

There are 1 best solutions below

1
Ignasi Barrera On

You cannot eagerly filter that on the provider. Using the portable interface you can just provide a predicate to filter nodes once you have them all. You can directly use the underlying AWS EC2 API to do what you want. It could be something like the following:

AWSEC2Api aws = computeServiceContext.unwrapApi(AWSEC2Api.class);
AWSInstanceApi instanceApi = aws.getInstanceApi().get();
instanceApi.describeInstancesInRegionWithFilter("region", ImmutableMultimap.of("vpc-id", "myvpc"));