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);
}
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();
}
Aggregations