使用AWS Java SDK在子网/VPC中列出所有资源
我正在尝试制作一个可以自动可视化 aws 架构的 java 应用程序。
我知道有一些服务可以为您执行此操作,例如 Hava、CloudCraft 等。但我想制作自己的服务,以便我可以将其集成到我的管道中(也不想付费)。
此过程的第一步是获取所有资源、vpc/子网依赖项并获取连接。
我使用了 java aws sdk,并尝试以以下格式创建一个 json 资源数组:
[
{
"type" : "vpc",
"name" : "1234",
"resources" : [
{
"type" : "subnet",
"name" : "1234",
"resources" : [
{
"type" : "ec2",
"name" : "1234"
}
]
},
{
}
]
},
{
"type" : "EBS",
"name" : "1234"
}
]
我通过使用 AmazonEC2 类、describeVpcs()、describeSubnets、describeInstances 方法来完成此操作。
但是,如果我要对每个资源都执行此操作,从长远来看,这将非常耗时且难以管理。所以我想知道是否有一种方法可以找到给定子网/vpc 的所有资源,这样我就不需要使用不同的类/方法查询每个资源
我还尝试使用 AWSResourceGroupsTaggingAPI 类来获取所有资源,这为我提供了所有资源、它们的标签和它们的 arn,但没有为我提供资源关系或子网/vpc夹杂物。
任何提示或建议将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论