2017-04-10 71 views
-1

我一直在嘗試使用scala創建DynamoDB客戶端。這是我創建的客戶是使用scala建立aws DynamoDB連接

val client = new AmazonDynamoDBClient(
    new InstanceProfileCredentialsProvider(), 
    PredefinedClientConfigurations.dynamoDefault 
    .withRequestTimeout(config.dynamoRequestTimeoutMs) 
    .withMaxConnections(config.dynamoMaxConnections)) 
client.setRegion(RegionUtils.getRegion(config.dynamoRegion)) 

但是在這裏,我使用的是InstanceProfileCredentialsProvider()提供的憑證(訪問密鑰和祕密密鑰)。假設我手頭有證書(access_key =「abcd」和secret_key =「xyz」)。是否有辦法通過提供我擁有的憑據來創建DynamoDB客戶端?提前致謝。

回答

0

BasicAWSCredentials一個實例更換InstanceProfileCredentialsProvider

import com.amazonaws.auth.BasicAWSCredentials 

new BasicAWSCredentials(key, secret)