31.5.6. 使用带有 S3 组件的 KMS
要使用 AWS KMS 对/解密数据进行加密/解密数据,您可以使用以下示例 2.21.x 中引入的选项来加密数据。
from("file:tmp/test?fileName=test.txt") .setHeader(S3Constants.KEY, constant("testFile")) .to("aws-s3://mybucket?amazonS3Client=#client&useAwsKMS=true&awsKMSKeyId=3f0637ad-296a-3dfe-a796-e60654fb128c");
from("file:tmp/test?fileName=test.txt")
.setHeader(S3Constants.KEY, constant("testFile"))
.to("aws-s3://mybucket?amazonS3Client=#client&useAwsKMS=true&awsKMSKeyId=3f0637ad-296a-3dfe-a796-e60654fb128c");
这样,您将询问 S3,以使用 KMS 密钥 3f0637ad-296a-3dfe-a796-e60654fb128c 加密文件 test.txt。当您需要下载此文件时,解密将在下载前直接进行。