List of usage examples for com.amazonaws.services.identitymanagement AmazonIdentityManagementClient setEndpoint
@Deprecated public void setEndpoint(String endpoint) throws IllegalArgumentException
From source file:com.cloudera.director.aws.ec2.EC2Provider.java
License:Apache License
/** * Configures the specified IAM client./* w ww. j a v a 2s. com*/ * * @param configuration the provider configuration * @param accumulator the exception accumulator * @param identityManagementClient the IAM client * @param providerLocalizationContext the resource provider localization context * @param verify whether to verify the configuration by making an API call * @return the configured client * @throws InvalidCredentialsException if the supplied credentials are invalid * @throws TransientProviderException if a transient exception occurs communicating with the * provider * @throws UnrecoverableProviderException if an unrecoverable exception occurs communicating with * the provider */ @SuppressWarnings("PMD.EmptyCatchBlock") protected static AmazonIdentityManagementClient configureIAMClient(Configured configuration, PluginExceptionConditionAccumulator accumulator, AmazonIdentityManagementClient identityManagementClient, LocalizationContext providerLocalizationContext, boolean verify) { checkNotNull(identityManagementClient, "identityManagementClient is null"); try { String iamEndpoint = configuration.getConfigurationValue(IAM_ENDPOINT, providerLocalizationContext); if (iamEndpoint != null) { LOG.info("<< Using configured IAM endpoint: {}", iamEndpoint); identityManagementClient.setEndpoint(iamEndpoint); } // else use the single default endpoint for all of AWS (outside GovCloud) if (verify) { // Attempt to use client, to validate credentials and connectivity try { identityManagementClient .getInstanceProfile(new GetInstanceProfileRequest().withInstanceProfileName("test")); } catch (NoSuchEntityException e) { /* call succeeded */ } } } catch (AmazonClientException e) { throw AWSExceptions.propagate(e); } catch (IllegalArgumentException e) { accumulator.addError(IAM_ENDPOINT.unwrap().getConfigKey(), e.getMessage()); } return identityManagementClient; }