use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient in project cloudbreak by hortonworks.
the class AwsObjectStorageConnector method validateObjectStorage.
@Override
public ObjectStorageValidateResponse validateObjectStorage(ObjectStorageValidateRequest request) {
String accountId = Crn.safeFromString(request.getCredential().getId()).getAccountId();
if (!entitlementService.awsCloudStorageValidationEnabled(accountId)) {
LOGGER.info("Aws Cloud storage validation entitlement is missing, not validating cloudStorageRequest: {}", JsonUtil.writeValueAsStringSilent(request));
return ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build();
}
AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential());
AmazonIdentityManagementClient iam = awsClient.createAmazonIdentityManagement(awsCredentialView);
SpiFileSystem spiFileSystem = request.getSpiFileSystem();
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
resultBuilder.prefix("Cloud Storage validation failed");
ValidationResult validationResult = awsIDBrokerObjectStorageValidator.validateObjectStorage(iam, spiFileSystem, request.getLogsLocationBase(), request.getBackupLocationBase(), resultBuilder);
ObjectStorageValidateResponse response;
if (validationResult.hasError()) {
response = ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.ERROR).withError(validationResult.getFormattedErrors()).build();
} else {
response = ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).withError(validationResult.getFormattedWarnings()).build();
}
return response;
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient in project cloudbreak by hortonworks.
the class AwsPlatformResources method accessConfigs.
@Override
public CloudAccessConfigs accessConfigs(ExtendedCloudCredential cloudCredential, Region region, Map<String, String> filters) {
CloudAccessConfigs cloudAccessConfigs = new CloudAccessConfigs(new HashSet<>());
AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential);
AmazonIdentityManagementClient client = awsClient.createAmazonIdentityManagement(awsCredentialView);
String accessConfigType = filters.get(CloudParameterConst.ACCESS_CONFIG_TYPE);
Set<CloudAccessConfig> cloudAccessConfigSet;
if (AwsAccessConfigType.ROLE.name().equals(accessConfigType)) {
cloudAccessConfigSet = getAccessConfigByRole(client);
} else {
cloudAccessConfigSet = getAccessConfigByInstanceProfile(client);
}
cloudAccessConfigs.getCloudAccessConfigs().addAll(cloudAccessConfigSet);
return cloudAccessConfigs;
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient in project cloudbreak by hortonworks.
the class AwsClient method createAmazonIdentityManagement.
public AmazonIdentityManagementClient createAmazonIdentityManagement(AwsCredentialView awsCredential) {
String region = awsDefaultZoneProvider.getDefaultZone(awsCredential);
AmazonIdentityManagement client = proxy(AmazonIdentityManagementClientBuilder.standard().withRequestHandlers(new AwsTracingRequestHandler(tracer)).withRegion(region).withClientConfiguration(getDefaultClientConfiguration()).withCredentials(getCredentialProvider(awsCredential)).build(), awsCredential, region);
return new AmazonIdentityManagementClient(client);
}
Aggregations