Turning on certificate inventory
The following Java code example shows how to use the PutInventoryConfiguration operation to start the Pro plan and collect from every
account and Region. The first call must name a plan and come from the management
account. It also sets your organization's home Region, so send it from the Region that
you want as your home Region. PutInventoryConfiguration
replaces the whole configuration. For more information, see Turn on certificate inventory.
package com.amazonaws.samples; import com.amazonaws.services.certificatemanager.AWSCertificateManagerClientBuilder; import com.amazonaws.services.certificatemanager.AWSCertificateManager; import com.amazonaws.services.certificatemanager.model.AccountScope; import com.amazonaws.services.certificatemanager.model.PutInventoryConfigurationRequest; import com.amazonaws.services.certificatemanager.model.PutInventoryConfigurationResult; import com.amazonaws.services.certificatemanager.model.RegionalScope; import com.amazonaws.services.certificatemanager.model.AWSCertificateManagerException; public class AWSCertificateManagerSample { public static void main(String[] args) { // The first successful call sets the home Region. AWSCertificateManager client = AWSCertificateManagerClientBuilder.standard() .withRegion("us-east-1") .build(); // Start the Pro plan, collect from every account and every Region, and keep // longer-lived certificates for 180 days. PutInventoryConfigurationRequest req = new PutInventoryConfigurationRequest() .withAccountScope(new AccountScope().withMode("ALL_ACCOUNTS")) .withRegionalScope(new RegionalScope().withMode("ALL_REGIONS")) .withDataRetentionDays(180) .withInventoryTier("PRO") .withStatus("ENABLED"); // Start the plan and turn on collection. try { PutInventoryConfigurationResult result = client.putInventoryConfiguration(req); System.out.println(result.getConfiguration()); } catch (AWSCertificateManagerException e) { System.err.println("Failed to turn on certificate inventory: " + e.getMessage()); } } }