use of com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsDbParameterGroupView in project cloudbreak by hortonworks.
the class AwsStackRequestHelper method getStackParameters.
@VisibleForTesting
Collection<Parameter> getStackParameters(AuthenticatedContext ac, DatabaseStack stack, boolean deleteProtection) {
AwsNetworkView awsNetworkView = new AwsNetworkView(stack.getNetwork());
DatabaseServer databaseServer = stack.getDatabaseServer();
AwsRdsInstanceView awsRdsInstanceView = new AwsRdsInstanceView(databaseServer);
AwsRdsDbSubnetGroupView awsRdsDbSubnetGroupView = new AwsRdsDbSubnetGroupView(databaseServer);
AwsRdsVpcSecurityGroupView awsRdsVpcSecurityGroupView = new AwsRdsVpcSecurityGroupView(databaseServer);
AwsRdsDbParameterGroupView awsRdsDbParameterGroupView = new AwsRdsDbParameterGroupView(databaseServer);
List<Parameter> parameters = new ArrayList<>(asList(new Parameter().withParameterKey("DBInstanceClassParameter").withParameterValue(awsRdsInstanceView.getDBInstanceClass()), new Parameter().withParameterKey("DBInstanceIdentifierParameter").withParameterValue(awsRdsInstanceView.getDBInstanceIdentifier()), new Parameter().withParameterKey("DBSubnetGroupNameParameter").withParameterValue(awsRdsDbSubnetGroupView.getDBSubnetGroupName()), new Parameter().withParameterKey("DBSubnetGroupSubnetIdsParameter").withParameterValue(String.join(",", awsNetworkView.getSubnetList())), new Parameter().withParameterKey("EngineParameter").withParameterValue(awsRdsInstanceView.getEngine()), new Parameter().withParameterKey("MasterUsernameParameter").withParameterValue(awsRdsInstanceView.getMasterUsername()), new Parameter().withParameterKey("MasterUserPasswordParameter").withParameterValue(awsRdsInstanceView.getMasterUserPassword()), new Parameter().withParameterKey("DeletionProtectionParameter").withParameterValue(deleteProtection ? "true" : "false")));
addParameterIfNotNull(parameters, "AllocatedStorageParameter", awsRdsInstanceView.getAllocatedStorage());
addParameterIfNotNull(parameters, "BackupRetentionPeriodParameter", awsRdsInstanceView.getBackupRetentionPeriod());
addParameterIfNotNull(parameters, "EngineVersionParameter", awsRdsInstanceView.getEngineVersion());
addParameterIfNotNull(parameters, "MultiAZParameter", awsRdsInstanceView.getMultiAZ());
addParameterIfNotNull(parameters, "StorageTypeParameter", awsRdsInstanceView.getStorageType());
addParameterIfNotNull(parameters, "PortParameter", databaseServer.getPort());
boolean useSslEnforcement = databaseServer.isUseSslEnforcement();
addParameterIfNotNull(parameters, "DBParameterGroupNameParameter", useSslEnforcement ? awsRdsDbParameterGroupView.getDBParameterGroupName() : null);
addParameterIfNotNull(parameters, "DBParameterGroupFamilyParameter", useSslEnforcement ? awsRdsDbParameterGroupView.getDBParameterGroupFamily() : null);
addParameterIfNotNull(parameters, "SslCertificateIdentifierParameter", useSslEnforcement && awsRdsInstanceView.isSslCertificateIdentifierDefined() ? awsRdsInstanceView.getSslCertificateIdentifier() : null);
if (awsRdsInstanceView.getVPCSecurityGroups().isEmpty()) {
// VPC-id and VPC cidr should be filled in
parameters.addAll(asList(new Parameter().withParameterKey("VPCIdParameter").withParameterValue(String.valueOf(awsNetworkView.getExistingVpc())), new Parameter().withParameterKey("DBSecurityGroupNameParameter").withParameterValue(awsRdsVpcSecurityGroupView.getDBSecurityGroupName())));
} else {
parameters.add(new Parameter().withParameterKey("VPCSecurityGroupsParameter").withParameterValue(String.join(",", awsRdsInstanceView.getVPCSecurityGroups())));
}
return parameters;
}
Aggregations