Search in sources :

Example 1 with ModifyDBInstanceRequest

use of com.amazonaws.services.rds.model.ModifyDBInstanceRequest in project cloudbreak by hortonworks.

the class AwsRdsModifyService method disableDeleteProtection.

public void disableDeleteProtection(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException {
    AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential());
    String regionName = ac.getCloudContext().getLocation().getRegion().value();
    AmazonRdsClient rdsClient = awsClient.createRdsClient(credentialView, regionName);
    String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId();
    ModifyDBInstanceRequest modifyDBInstanceRequest = new ModifyDBInstanceRequest();
    modifyDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier);
    modifyDBInstanceRequest.setDeletionProtection(false);
    LOGGER.debug("RDS modify request to disable delete protection for DB: {}", dbInstanceIdentifier);
    try {
        rdsClient.modifyDBInstance(modifyDBInstanceRequest);
    } catch (RuntimeException ex) {
        throw new CloudConnectorException(ex.getMessage(), ex);
    }
    Waiter<DescribeDBInstancesRequest> rdsWaiter = customAmazonWaiterProvider.getDbInstanceModifyWaiter(rdsClient);
    DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier);
    StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId());
    run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck);
    LOGGER.debug("RDS delete protection is disabled for DB Instance ID: {}", dbInstanceIdentifier);
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) StackCancellationCheck(com.sequenceiq.cloudbreak.cloud.aws.scheduler.StackCancellationCheck) AmazonRdsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient) ModifyDBInstanceRequest(com.amazonaws.services.rds.model.ModifyDBInstanceRequest) DescribeDBInstancesRequest(com.amazonaws.services.rds.model.DescribeDBInstancesRequest)

Aggregations

DescribeDBInstancesRequest (com.amazonaws.services.rds.model.DescribeDBInstancesRequest)1 ModifyDBInstanceRequest (com.amazonaws.services.rds.model.ModifyDBInstanceRequest)1 AmazonRdsClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient)1 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)1 StackCancellationCheck (com.sequenceiq.cloudbreak.cloud.aws.scheduler.StackCancellationCheck)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1