Example usage for com.amazonaws.services.rds.model DeleteDBInstanceRequest setFinalDBSnapshotIdentifier

List of usage examples for com.amazonaws.services.rds.model DeleteDBInstanceRequest setFinalDBSnapshotIdentifier

Introduction

In this page you can find the example usage for com.amazonaws.services.rds.model DeleteDBInstanceRequest setFinalDBSnapshotIdentifier.

Prototype


public void setFinalDBSnapshotIdentifier(String finalDBSnapshotIdentifier) 

Source Link

Document

The DBSnapshotIdentifier of the new DBSnapshot created when the SkipFinalSnapshot parameter is disabled.

Usage

From source file:com.cloudera.director.aws.rds.RDSProvider.java

License:Apache License

@Override
public void delete(RDSInstanceTemplate template, Collection<String> virtualInstanceIds)
        throws InterruptedException {

    if (virtualInstanceIds.isEmpty()) {
        return;/* w w w  .  j a  va2s  . co  m*/
    }

    for (String virtualInstanceId : virtualInstanceIds) {
        LOG.info(">> Terminating {}", virtualInstanceId);

        DeleteDBInstanceRequest request = new DeleteDBInstanceRequest()
                .withDBInstanceIdentifier(virtualInstanceId);
        if (template.isSkipFinalSnapshot().or(false)) {
            request.setSkipFinalSnapshot(true);
        } else {
            String snapshotIdentifier = String.format("%s-director-final-snapshot-%d", virtualInstanceId,
                    System.currentTimeMillis());
            request.setFinalDBSnapshotIdentifier(snapshotIdentifier);
        }

        try {
            DBInstance deletedDbInstance = client.deleteDBInstance(request);
            LOG.info("<< Result {}", deletedDbInstance);
        } catch (DBInstanceNotFoundException e) {
            LOG.warn("<< Instance {} was not found, assuming already deleted", virtualInstanceId);
        }
    }
}