# Endpoint. Use s3-external-1.amazonaws.com for clusters in us-east
s3_endpoint=<s3 endpoint>
# Bucket to upload data.
s3_bucket=<bucket name>
# S3 prefix to add to uploaded data files. All files loaded will have this
prefix.
s3_prefix=<object prefix>
# Local directory from which to load data. All files in this directory will be
encrypted and loaded.
src_dir=<source location>
The following Java class uses the properties file to upload objects using client-side encryption.
import java.io.File;
import java.util.Properties;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3EncryptionClient;
import com.amazonaws.services.s3.model.EncryptionMaterials;
import com.amazonaws.services.s3.model.PutObjectRequest;
public class SampleEncryptAndUploadDataToS3 {
private static final int MAX_RETRY_COUNT = 10;
public static void main(String[] args) throws Exception {
//Specify values in SampleEncryptAndUploadDataToS3.properties file.
AWSCredentials credentials = new PropertiesCredentials(
SampleEncryptAndUploadDataToS3.class.getResourceAsStream("AwsCreden
tials.properties"));
Properties config = new Properties();
config.load(SampleEncryptAndUploadDataToS3.class.getResourceAs
Stream("SampleEncryptAndUploadDataToS3.properties"));
String masterSymmetricKeyBase64 = getProperty(config, "master_symmet
ric_key");
String bucketName = getProperty(config, "s3_bucket");
String s3Prefix = getProperty(config, "s3_prefix");
String s3Endpoint = getProperty(config, "s3_endpoint");
API Version 2012-12-01
121
Amazon Redshift Management Guide
Example: Uploading Client-Side Encrypted Data