Search in sources :

Example 1 with S3EncryptionConfiguration

use of com.amazonaws.services.qldb.model.S3EncryptionConfiguration in project amazon-qldb-dmv-sample-java by aws-samples.

the class ExportJournal method main.

public static void main(final String... args) throws Exception {
    String s3BucketName;
    String kmsArn = null;
    String roleArn = null;
    if (args.length >= 1) {
        s3BucketName = args[0];
        if (args.length >= 2) {
            roleArn = args[1];
        }
        // If not provided, SSE-S3 is used for exporting to S3 bucket.
        if (args.length == 3) {
            kmsArn = args[2];
        }
    } else {
        String accountId = AWSSecurityTokenServiceClientBuilder.defaultClient().getCallerIdentity(new GetCallerIdentityRequest()).getAccount();
        s3BucketName = Constants.JOURNAL_EXPORT_S3_BUCKET_NAME_PREFIX + "-" + accountId;
    }
    S3EncryptionConfiguration s3EncryptionConfiguration;
    if (kmsArn == null) {
        s3EncryptionConfiguration = new S3EncryptionConfiguration().withObjectEncryptionType(S3ObjectEncryptionType.SSE_S3);
    } else {
        s3EncryptionConfiguration = new S3EncryptionConfiguration().withObjectEncryptionType(S3ObjectEncryptionType.SSE_KMS).withKmsKeyArn(kmsArn);
    }
    createJournalExportAndAwaitCompletion(Constants.LEDGER_NAME, s3BucketName, Constants.LEDGER_NAME + "/", roleArn, s3EncryptionConfiguration, DEFAULT_EXPORT_TIMEOUT_MS);
}
Also used : GetCallerIdentityRequest(com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest) S3EncryptionConfiguration(com.amazonaws.services.qldb.model.S3EncryptionConfiguration)

Example 2 with S3EncryptionConfiguration

use of com.amazonaws.services.qldb.model.S3EncryptionConfiguration in project amazon-qldb-dmv-sample-java by aws-samples.

the class ValidateQldbHashChain method createExport.

/**
 * Export journal contents to a S3 bucket.
 *
 * @return the ExportId of the journal export.
 * @throws InterruptedException if the thread is interrupted while waiting for export to complete.
 */
private static String createExport() throws InterruptedException {
    String accountId = AWSSecurityTokenServiceClientBuilder.defaultClient().getCallerIdentity(new GetCallerIdentityRequest()).getAccount();
    String bucketName = Constants.JOURNAL_EXPORT_S3_BUCKET_NAME_PREFIX + "-" + accountId;
    String prefix = Constants.LEDGER_NAME + "-" + Instant.now().getEpochSecond() + "/";
    S3EncryptionConfiguration encryptionConfiguration = new S3EncryptionConfiguration().withObjectEncryptionType(S3ObjectEncryptionType.SSE_S3);
    ExportJournalToS3Result exportJournalToS3Result = ExportJournal.createJournalExportAndAwaitCompletion(Constants.LEDGER_NAME, bucketName, prefix, null, encryptionConfiguration, ExportJournal.DEFAULT_EXPORT_TIMEOUT_MS);
    return exportJournalToS3Result.getExportId();
}
Also used : ExportJournalToS3Result(com.amazonaws.services.qldb.model.ExportJournalToS3Result) GetCallerIdentityRequest(com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest) S3EncryptionConfiguration(com.amazonaws.services.qldb.model.S3EncryptionConfiguration)

Aggregations

S3EncryptionConfiguration (com.amazonaws.services.qldb.model.S3EncryptionConfiguration)2 GetCallerIdentityRequest (com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest)2 ExportJournalToS3Result (com.amazonaws.services.qldb.model.ExportJournalToS3Result)1