Search in sources :

Example 6 with AmazonIdentityManagementClient

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;
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AmazonIdentityManagementClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 7 with AmazonIdentityManagementClient

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;
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AmazonIdentityManagementClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient) CloudAccessConfig(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfig) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)

Example 8 with AmazonIdentityManagementClient

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);
}
Also used : AmazonIdentityManagementClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient) AwsTracingRequestHandler(com.sequenceiq.cloudbreak.cloud.aws.common.tracing.AwsTracingRequestHandler) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Aggregations

AmazonIdentityManagementClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient)8 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)7 SimulatePrincipalPolicyRequest (com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyRequest)5 SimulatePrincipalPolicyResult (com.amazonaws.services.identitymanagement.model.SimulatePrincipalPolicyResult)5 GetCallerIdentityRequest (com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest)5 GetCallerIdentityResult (com.amazonaws.services.securitytoken.model.GetCallerIdentityResult)5 AmazonSecurityTokenServiceClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonSecurityTokenServiceClient)5 ArrayList (java.util.ArrayList)5 EvaluationResult (com.amazonaws.services.identitymanagement.model.EvaluationResult)4 AwsPermissionMissingException (com.sequenceiq.cloudbreak.cloud.aws.common.exception.AwsPermissionMissingException)4 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)4 URL (java.net.URL)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 OrganizationsDecisionDetail (com.amazonaws.services.identitymanagement.model.OrganizationsDecisionDetail)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Action (com.amazonaws.auth.policy.Action)1 Condition (com.amazonaws.auth.policy.Condition)1 Policy (com.amazonaws.auth.policy.Policy)1 Statement (com.amazonaws.auth.policy.Statement)1