//snippet-sourcedescription:[CreateIdentityPool.java demonstrates how to create a new identity pool. The identity pool is a store of user identity information that is specific to your AWS account.]
//snippet-keyword:[Java]
//snippet-sourcesyntax:[java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon Cognito]
//snippet-service:[cognito]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[2019-06-02]
//snippet-sourceauthor:[jschwarzwalder AWS]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
//snippet-start:[cognito.java2.create_identity_pool.complete]

package com.example.cognito;

//snippet-start:[cognito.java2.create_identity_pool.import]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.cognitoidentity.CognitoIdentityClient;
import software.amazon.awssdk.services.cognitoidentity.model.CreateIdentityPoolRequest;
import software.amazon.awssdk.services.cognitoidentity.model.CreateIdentityPoolResponse;
//snippet-end:[cognito.java2.create_identity_pool.import]

public class CreateIdentityPool {

    public static void main(String[] args) {
        final String USAGE = "\n" +
                "Usage:\n" +
                "    CreateIdentityPool <identity_pool_name> \n\n" +
                "Where:\n" +
                "    identity_pool_name - the name to give your identity pool.\n\n" +
                "Example:\n" +
                "    CreateTable HelloTable\n";

        if (args.length < 1) {
            System.out.println(USAGE);
            System.exit(1);
        }
        //snippet-start:[cognito.java2.create_identity_pool.main]
        String identity_pool_name = args[1];

        CognitoIdentityClient cognitoclient = CognitoIdentityClient.builder()
                .region(Region.US_EAST_1)
                .build();

        CreateIdentityPoolResponse response = cognitoclient.createIdentityPool(
                CreateIdentityPoolRequest.builder()
                        .allowUnauthenticatedIdentities(false)
                        .identityPoolName(identity_pool_name)
                        .build()
        );

        System.out.println("Unity Pool " + response.identityPoolName() + " is created. ID: " + response.identityPoolId());

        //snippet-end:[cognito.java2.create_identity_pool.main]
    }
}
//snippet-end:[cognito.java2.create_identity_pool.complete]
@@ -403,18 +403,17 @@
 te:%5B
-2019-06-
+4/16/2
 02
+0
 %5D%0A//
@@ -438,22 +438,16 @@
 or:%5B
-j
 sc
-hwarzwalder
+macdon
  AWS
@@ -468,18 +468,8 @@
 ght 
-2010-2019 
 Amaz
@@ -1026,70 +1026,8 @@
 %0A */
-%0A//snippet-start:%5Bcognito.java2.create_identity_pool.complete%5D
 %0A%0Apa
@@ -1415,16 +1415,119 @@
 sponse;%0A
+import software.amazon.awssdk.services.cognitoidentityprovider.model.CognitoIdentityProviderException;%0A
 //snippe
@@ -2063,25 +2063,24 @@
 %0A           
- 
 System.exit(
@@ -2097,73 +2097,8 @@
   %7D%0A
-        //snippet-start:%5Bcognito.java2.create_identity_pool.main%5D
 %0A   
@@ -2113,31 +2113,29 @@
 ing identity
-_pool_n
+PoolN
 ame = args%5B1
@@ -2133,17 +2133,17 @@
  = args%5B
-1
+0
 %5D;%0A%0A    
@@ -2281,24 +2281,358 @@
  .build();%0A%0A
+        String identityPoolId = createIdPool(cognitoclient, identityPoolName) ;%0A        System.out.println(%22Unity Pool Id %22 + identityPoolId);%0A    %7D%0A%0A    //snippet-start:%5Bcognito.java2.create_identity_pool.main%5D%0A    public static String createIdPool(CognitoIdentityClient cognitoclient, String identityPoolName ) %7B%0A%0A        try %7B%0A    
         Crea
@@ -2864,23 +2864,21 @@
 identity
-_pool_n
+PoolN
 ame)%0A   
@@ -2931,123 +2931,145 @@
     
-System.out.println(%22Unity Pool %22 + response.identityPoolName() + %22 is created. ID: %22 + response.identityPoolId());%0A
+   return response.identityPoolId();%0A    %7D catch (CognitoIdentityProviderException e)%7B%0A        e.getStackTrace();%0A    %7D%0A       return %22%22;
 %0A   
@@ -3141,63 +3141,4 @@
 %7D%0A%7D%0A
-//snippet-end:%5Bcognito.java2.create_identity_pool.complete%5D

Update CreateIdentityPool.java