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;
}
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);
}
});
}
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;
}
Aggregations