protected static void initClients ( ) throws Exception { /* * The ProfileCredentialsProvider will return your [default] credential * profile by reading from the credentials file located at * (~/.aws/credentials). */ ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider ( ) ; try { credentialsProvider . getCredentials ( ) ; } catch ( Exception e ) { throw new AmazonClientException ( "Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (~/.aws/credentials), and is in valid format." , e ) ; } // S3 client s3Client = AmazonS3ClientBuilder . standard ( ) . withCredentials ( credentialsProvider ) . withRegion ( s3RegionName ) . build ( ) ; // Firehose client firehoseClient = AmazonKinesisFirehoseClientBuilder . standard ( ) . withCredentials ( credentialsProvider ) . withRegion ( firehoseRegion ) . build ( ) ; // IAM client iamClient = AmazonIdentityManagementClientBuilder . standard ( ) . withCredentials ( credentialsProvider ) . withRegion ( iamRegion ) . build ( ) ; }
Method to initialize the clients using the specified AWSCredentials .