我一直在尝试使用 scala 创建 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 客户端?提前谢谢。
将InstanceProfileCredentialsProvider
替换为 BasicAWSCredentials
的实例:
import com.amazonaws.auth.BasicAWSCredentials
new BasicAWSCredentials(key, secret)