AWS Code Sample

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above. demonstrates how to list aliases in the account and region.

package aws.example.kms; import; import; import; import; import; public class ListAliases { public static void main(String[] args) { AWSKMS kmsClient = AWSKMSClientBuilder.standard().build(); // List the aliases in this AWS account // Integer limit = 10; String nextMarker = null; do { ListAliasesRequest req = new ListAliasesRequest() .withMarker(nextMarker).withLimit(limit); ListAliasesResult result = kmsClient.listAliases(req); for (AliasListEntry alias : result.getAliases()) { System.out.printf("Found an alias named \"%s\".%n", alias.getAliasName()); } nextMarker = result.getNextMarker(); } while (nextMarker != null); } }

Sample Details

Service: kms

Last tested: 2019-04-09

Author: AWS

Type: full-example

On this page: