Search in sources :

Example 1 with AwsRdsDbParameterGroupView

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;
}
Also used : AwsNetworkView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsNetworkView) AwsRdsDbParameterGroupView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsDbParameterGroupView) ArrayList(java.util.ArrayList) Parameter(com.amazonaws.services.cloudformation.model.Parameter) DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) AwsRdsInstanceView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsInstanceView) AwsRdsDbSubnetGroupView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsDbSubnetGroupView) AwsRdsVpcSecurityGroupView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsVpcSecurityGroupView) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

Parameter (com.amazonaws.services.cloudformation.model.Parameter)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AwsNetworkView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsNetworkView)1 AwsRdsDbParameterGroupView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsDbParameterGroupView)1 AwsRdsDbSubnetGroupView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsDbSubnetGroupView)1 AwsRdsInstanceView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsInstanceView)1 AwsRdsVpcSecurityGroupView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsRdsVpcSecurityGroupView)1 DatabaseServer (com.sequenceiq.cloudbreak.cloud.model.DatabaseServer)1 ArrayList (java.util.ArrayList)1