use of com.amazonaws.AmazonClientException in project cloudbreak by hortonworks.
the class AwsCredentialConnector method verifyAccessKeySecretKeyIsAssumable.
private CloudCredentialStatus verifyAccessKeySecretKeyIsAssumable(CloudCredential cloudCredential) {
AwsCredentialView awsCredential = new AwsCredentialView(cloudCredential);
try {
AmazonEC2Client access = awsClient.createAccess(cloudCredential);
DescribeRegionsRequest describeRegionsRequest = new DescribeRegionsRequest();
access.describeRegions(describeRegionsRequest);
} catch (AmazonClientException ae) {
String errorMessage = "Unable to verify AWS credentials: please make sure the access key and secret key is correct";
LOGGER.error(errorMessage, ae);
return new CloudCredentialStatus(cloudCredential, CredentialStatus.FAILED, ae, errorMessage);
} catch (RuntimeException e) {
String errorMessage = String.format("Could not verify keys '%s': check if the keys exists and if it's created with the correct external ID", awsCredential.getAccessKey());
LOGGER.error(errorMessage, e);
return new CloudCredentialStatus(cloudCredential, CredentialStatus.FAILED, e, errorMessage);
}
return new CloudCredentialStatus(cloudCredential, CredentialStatus.CREATED);
}
use of com.amazonaws.AmazonClientException in project cloudbreak by hortonworks.
the class AwsSetup method prerequisites.
@Override
public void prerequisites(AuthenticatedContext ac, CloudStack stack, PersistenceNotifier persistenceNotifier) {
AwsNetworkView awsNetworkView = new AwsNetworkView(stack.getNetwork());
AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential());
String region = ac.getCloudContext().getLocation().getRegion().value();
verifySpotInstances(stack);
AwsCredentialView awsCredentialView = new AwsCredentialView(ac.getCloudCredential());
AwsInstanceProfileView awsInstanceProfileView = new AwsInstanceProfileView(stack);
if (awsClient.roleBasedCredential(awsCredentialView) && awsInstanceProfileView.isCreateInstanceProfile()) {
validateInstanceProfileCreation(awsCredentialView);
}
if (awsNetworkView.isExistingVPC()) {
try {
AmazonEC2Client amazonEC2Client = awsClient.createAccess(credentialView, region);
validateExistingIGW(awsNetworkView, amazonEC2Client);
validateExistingSubnet(awsNetworkView, amazonEC2Client);
} catch (AmazonServiceException e) {
throw new CloudConnectorException(e.getErrorMessage());
} catch (AmazonClientException e) {
throw new CloudConnectorException(e.getMessage());
}
}
validateExistingKeyPair(stack.getInstanceAuthentication(), credentialView, region);
LOGGER.debug("setup has been executed");
}
use of com.amazonaws.AmazonClientException in project dataverse by IQSS.
the class S3AccessIO method savePathAsAux.
@Override
public // this method copies a local filesystem Path into this DataAccess Auxiliary location:
void savePathAsAux(Path fileSystemPath, String auxItemTag) throws IOException {
if (!this.canWrite()) {
open(DataAccessOption.WRITE_ACCESS);
}
String destinationKey = getDestinationKey(auxItemTag);
try {
File inputFile = fileSystemPath.toFile();
s3.putObject(new PutObjectRequest(bucketName, destinationKey, inputFile));
} catch (AmazonClientException ase) {
logger.warning("Caught an AmazonServiceException in S3AccessIO.savePathAsAux(): " + ase.getMessage());
throw new IOException("S3AccessIO: Failed to save path as an auxiliary object.");
}
}
use of com.amazonaws.AmazonClientException in project dataverse by IQSS.
the class S3AccessIO method listAuxObjects.
@Override
public List<String> listAuxObjects() throws IOException {
if (!this.canWrite()) {
open();
}
String prefix = getDestinationKey("");
List<String> ret = new ArrayList<>();
ListObjectsRequest req = new ListObjectsRequest().withBucketName(bucketName).withPrefix(prefix);
ObjectListing storedAuxFilesList = s3.listObjects(req);
List<S3ObjectSummary> storedAuxFilesSummary = storedAuxFilesList.getObjectSummaries();
try {
while (storedAuxFilesList.isTruncated()) {
logger.fine("S3 listAuxObjects: going to next page of list");
storedAuxFilesList = s3.listNextBatchOfObjects(storedAuxFilesList);
storedAuxFilesSummary.addAll(storedAuxFilesList.getObjectSummaries());
}
} catch (AmazonClientException ase) {
logger.warning("Caught an AmazonServiceException in S3AccessIO.listAuxObjects(): " + ase.getMessage());
throw new IOException("S3AccessIO: Failed to get aux objects for listing.");
}
for (S3ObjectSummary item : storedAuxFilesSummary) {
String destinationKey = item.getKey();
String fileName = destinationKey.substring(destinationKey.lastIndexOf(".") + 1);
logger.fine("S3 cached aux object fileName: " + fileName);
ret.add(fileName);
}
return ret;
}
use of com.amazonaws.AmazonClientException in project krypton-android by kryptco.
the class SNSTransport method registerWithAWS.
public synchronized void registerWithAWS() throws TransportException {
try {
AmazonSNSClient client = getClient();
CreatePlatformEndpointRequest request = new CreatePlatformEndpointRequest().withPlatformApplicationArn(PLATFORM_APPLICATION_ARN).withToken(token);
CreatePlatformEndpointResult result = client.createPlatformEndpoint(request);
setEndpointARN(result.getEndpointArn());
HashMap<String, String> enabledAttribute = new HashMap<>();
enabledAttribute.put("Enabled", "true");
SetEndpointAttributesRequest enableRequest = new SetEndpointAttributesRequest().withEndpointArn(endpointARN).withAttributes(enabledAttribute);
client.setEndpointAttributes(enableRequest);
} catch (AmazonClientException e) {
throw new TransportException(e.getMessage());
}
}
Aggregations