Search in sources :

Example 1 with AwsDiskEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverter method convert.

private AwsEncryptionV4Parameters convert(AwsEncryptionV1Parameters source, DetailedEnvironmentResponse environment) {
    AwsEncryptionV4Parameters response = new AwsEncryptionV4Parameters();
    String dataHubEncryptionKey = source.getKey();
    EncryptionType dataHubEncryptionKeyType = source.getType();
    if (EncryptionType.CUSTOM.equals(dataHubEncryptionKeyType)) {
        response.setKey(dataHubEncryptionKey);
        response.setType(dataHubEncryptionKeyType);
    } else {
        String environmentEncryptionKeyArn = Optional.ofNullable(environment).map(DetailedEnvironmentResponse::getAws).map(AwsEnvironmentParameters::getAwsDiskEncryptionParameters).map(AwsDiskEncryptionParameters::getEncryptionKeyArn).orElse(null);
        if (environmentEncryptionKeyArn != null && !environmentEncryptionKeyArn.isEmpty()) {
            response.setKey(environmentEncryptionKeyArn);
            response.setType(EncryptionType.CUSTOM);
        } else {
            response.setType(EncryptionType.DEFAULT);
        }
    }
    return response;
}
Also used : EncryptionType(com.sequenceiq.common.api.type.EncryptionType) AwsEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters) AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters)

Example 2 with AwsDiskEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters in project cloudbreak by hortonworks.

the class StackRequestManifester method setupInstanceVolumeEncryptionForAws.

@VisibleForTesting
void setupInstanceVolumeEncryptionForAws(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
    String encryptionKeyArn = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAws).map(AwsEnvironmentParameters::getAwsDiskEncryptionParameters).map(AwsDiskEncryptionParameters::getEncryptionKeyArn).orElse(null);
    stackRequest.getInstanceGroups().forEach(ig -> {
        AwsInstanceTemplateV4Parameters aws = ig.getTemplate().createAws();
        AwsEncryptionV4Parameters encryption = aws.getEncryption();
        if (encryption == null) {
            encryption = new AwsEncryptionV4Parameters();
            aws.setEncryption(encryption);
        }
        if (encryption.getType() == null) {
            aws.getEncryption().setType(EncryptionType.DEFAULT);
        }
        if (encryptionKeyArn != null) {
            aws.getEncryption().setType(EncryptionType.CUSTOM);
            aws.getEncryption().setKey(encryptionKeyArn);
        }
    });
}
Also used : AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters) AwsEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with AwsDiskEncryptionParameters

use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverterTest method createDetailedEnvironmentResponseForAwsEncryption.

private DetailedEnvironmentResponse createDetailedEnvironmentResponseForAwsEncryption(boolean withAws, boolean withResourceEncryption, String environmentEncryptionKey) {
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    if (withAws) {
        AwsEnvironmentParameters parameters = new AwsEnvironmentParameters();
        environment.setAws(parameters);
        if (withResourceEncryption && ENVIRONMENT_ENCRYPTION_KEY != null) {
            AwsDiskEncryptionParameters encryption = new AwsDiskEncryptionParameters();
            parameters.setAwsDiskEncryptionParameters(encryption);
            encryption.setEncryptionKeyArn(environmentEncryptionKey);
        }
    }
    return environment;
}
Also used : AwsDiskEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters) AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)

Aggregations

AwsEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters)3 AwsEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AwsInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters)1 EncryptionType (com.sequenceiq.common.api.type.EncryptionType)1 AwsDiskEncryptionParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsDiskEncryptionParameters)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1