使用KMS的AWS S3客户端加密 - 忽略Region

时间:2014-11-27 14:55:54

标签: amazon-web-services amazon-s3

我正在使用最近发布的亚马逊KMS服务,但是当传入AmazonS3EncryptionClient时,我遇到了一个被忽略的问题。

AmazonS3EncryptionClient s3 = new AmazonS3EncryptionClient(credentials,
new KMSEncryptionMaterialsProvider(keyId))
.withRegion(Region.getRegion(Regions.EU_WEST_1));

返回的错误消息表明,尽管已将其设置为US-East-1

,但仍无法在区域EU-West-1中找到该密钥

错误消息是

 com.amazonaws.services.kms.model.NotFoundException: 
   Key 'arn:aws:kms:us-east-1:account#:key/mykeyname' does not exist (Service: AWSKMS; 
   Status Code: 400; Error Code: NotFoundException; 
   Request ID: 8fb90ad0-7644-11e4-bf12-0b5a59268629)

我找不到任何文档建议这是API中的特定错误,有什么建议吗?

1 个答案:

答案 0 :(得分:2)

尝试阅读此主题底部的评论/建议:

http://java.awsblog.com/post/Tx19OLB7M3D6DS8/S3-Encryption-with-AWS-Key-Management-Service

看起来有一个版本可以通过添加新参数来解决这个问题。

即:

AmazonS3 s3 = new AmazonS3EncryptionClient(new DefaultAWSCredentialsProviderChain(),
                new KMSEncryptionMaterialsProvider(customerMasterKeyId),
                new CryptoConfiguration().withKmsRegion(Regions.fromName("us-west-2")));
相关问题