Listing All resources in a subnet/vpc with AWS Java SDK

Viewed 87

I'm trying to make a java application that can visualize aws architecture automatically.

I know there exist services that do this for you such as Hava, CloudCraft etc.. but I want to make my own so that I can integrate it into my pipeline (also dont want to pay).

The first step to this process is to get all resources, vpc/subnet dependencies, and get connections.

I've used the java aws sdk and am trying to make a json array of resources in the following format:

[
    {
        "type" : "vpc",
        "name" : "1234",
        "resources" : [
            {
                "type" : "subnet",
                "name" : "1234",
                "resources" : [
                    {
                        "type" : "ec2",
                        "name" : "1234"
                    }
                ]
            },
            {
                
            }
        ]
    },
    {
        "type" : "EBS",
        "name" : "1234"
    }
]

I've done this by using the AmazonEC2 class, using describeVpcs(), describeSubnets, describeInstances methods.

But if I were to do this for every single resource, it would be very timeconsuming and hard to manage in the longrun.. so I was wondering if there is a way to find all resources for a given subnet/vpc so that I dont have to query every single resource using a different class/method

I've also tried using the AWSResourceGroupsTaggingAPI class to get all resources, which gives me all resources, their tags, and their arn's but does not give me the resource relations or subnet/vpc inclusions.

Any tips or suggestions would be appreciated.

0 Answers
Related