Getting organization-wide certificate counts - AWS Certificate Manager
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Getting organization-wide certificate counts

The following Java code example shows how to use the GetInventoryInsights operation to get the expiration counts. For more information, see Get organization-wide counts.

package com.amazonaws.samples; import com.amazonaws.services.certificatemanager.AWSCertificateManagerClientBuilder; import com.amazonaws.services.certificatemanager.AWSCertificateManager; import com.amazonaws.services.certificatemanager.model.InventoryExpiryWindowOptions; import com.amazonaws.services.certificatemanager.model.GetInventoryInsightsRequest; import com.amazonaws.services.certificatemanager.model.GetInventoryInsightsResult; import com.amazonaws.services.certificatemanager.model.InventoryAggregateRequest; import com.amazonaws.services.certificatemanager.model.AWSCertificateManagerException; public class AWSCertificateManagerSample { public static void main(String[] args) { // Send requests to your organization's home Region. AWSCertificateManager client = AWSCertificateManagerClientBuilder.standard() .withRegion("us-east-1") .build(); // Ask for the expiration counts. GetInventoryInsightsRequest req = new GetInventoryInsightsRequest() .withRequestedAggregates(new InventoryAggregateRequest() .withExpiryWindow(new InventoryExpiryWindowOptions())); // Get the counts. try { GetInventoryInsightsResult result = client.getInventoryInsights(req); System.out.println(result.getCertificateCount()); System.out.println(result.getAggregates()); } catch (AWSCertificateManagerException e) { System.err.println("Failed to get the inventory counts: " + e.getMessage()); } } }