stackUser
stackUser

Reputation: 579

How to use AWS Java SDK to get all AWS Resources tag details?

I am new to the AWS so this may be the simple question.

My requirement is to get the list of all tagged and untagged AWS resources list and create a separate report for tagged resources and untagged resources in JAVA.

I can get the AWS EC2 tagged resources and untagged resources list by using aws-java-sdk-ec2 in JAVA.

But it looks difficult to use separate SDK for every AWS service to get resources tag details.

AWS provides a central way to access all AWS resources tag details by using their tagging API but I dont understand how to use that in Java.

So How to get the list of all AWS resources without tag and list of all AWS resources with tags?

Thanks in Advance.

Upvotes: 1

Views: 1710

Answers (1)

Juned Ahsan
Juned Ahsan

Reputation: 68715

You need to use the Java AWS SDK top-level dependency in your pom as mentioned here

<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk</artifactId>
    <version>1.11.327</version>
  </dependency>
</dependencies>

Secondly, you can call the AWSResourceGroupsTaggingAPI

For example GetResourcesResult API

GetResources Result getResources(GetResourcesRequest getResourcesRequest)

Returns all the tagged or previously tagged resources that are located in the specified region for the AWS account. You can optionally specify filters (tags and resource types) in your request, depending on what information you want returned. The response includes all tags that are associated with the requested resources.getResources(GetResourcesRequest getResourcesRequest) Returns all the tagged or previously tagged resources that are located in the specified region for the AWS account. You can optionally specify filters (tags and resource types) in your request, depending on what information you want returned. The response includes all tags that are associated with the requested resources.

You may like to use the below AWSResourceGroupsTaggingAPIAsyncClient client, which implements this interface

Upvotes: 1

Related Questions