use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method createAwsRequest.
private AwsEnvironmentParameters createAwsRequest() {
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName("my-table");
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
awsEnvironmentParameters.setAwsDiskEncryptionParameters(AwsDiskEncryptionParameters.builder().withEncryptionKeyArn("dummy-key-arn").build());
return awsEnvironmentParameters;
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters 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.AwsEnvironmentParameters in project cloudbreak by hortonworks.
the class AwsCloudProvider method setS3Guard.
@Override
public EnvironmentTestDto setS3Guard(EnvironmentTestDto environmentTestDto, String tableName) {
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName(tableName);
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
return environmentTestDto.withAws(awsEnvironmentParameters);
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentity.
@Test
public void whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentity() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockFileSystemResponseForCloudbreakClient();
SdxCluster sdxCluster = new SdxCluster();
SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
sdxCluster.setInitiatorUserCrn(USER_CRN);
sdxCluster.setClusterName("sdx-cluster");
SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
cloudStorageRequest.setBaseLocation("s3a://example-path");
cloudStorageRequest.setFileSystemType(FileSystemType.S3);
S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
s3Params.setInstanceProfile("instance:profile");
cloudStorageRequest.setS3(s3Params);
sdxClusterRequest.setCloudStorage(cloudStorageRequest);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("AWS");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
s3CloudStorageV1Parameters.setInstanceProfile("logprofile");
loggingResponse.setS3(s3CloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName("table");
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
environment.setAws(awsEnvironmentParameters);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.initCloudStorageRequest(environment, clusterV4Request, sdxCluster, sdxClusterRequest));
StorageLocationBase singleRequest = cloudStorageConfigReq.getLocations().iterator().next();
assertEquals(2, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.ID_BROKER)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals("table", cloudStorageConfigReq.getAws().getS3Guard().getDynamoTableName());
assertEquals(1, cloudStorageConfigReq.getLocations().size());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, singleRequest.getType());
assertEquals("ranger/example-path", singleRequest.getValue());
verify(storageValidationService).validateCloudStorage("AWS", cloudStorageRequest);
}
use of com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters 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);
}
});
}
Aggregations