AWSCredentialsProvider

AWSCredentialsProvider

在Scala中使用Java s3 sdk aws-java-sdk-s3:1.11.542时,出现“您提供的AWS访问密钥ID在我们的记录中不存在”。

我已经验证我可以访问存储桶并运行命令,例如:aws s3 mv s3://{bucket} ./ --recursiveaws s3 ls s3://{bucket}

我为客户实施的是:

implicit val s3Client: AmazonS3 = AmazonS3ClientBuilder
      .standard
      .withRegion(new DefaultAwsRegionProviderChain().getRegion)
      .withCredentials(new DefaultAWSCredentialsProviderChain)
      .build


我也尝试显式使用BasicAWSCredentialsEnvironmentVariableCredentialsProviderProfileCredentialsProvider

编辑:我使用的默认配置文件和okta是一个问题

最佳答案

您可以使用AWSCredentialsProvider API

implicit val awsCredentialsProvider = new AWSCredentialsProvider {
          override def getCredentials = new BasicAWSCredentials(AWSKey, AWSSecret)
          override def refresh(): Unit = ???
    }


并使用awsCredentialsProvider创建AmazonS3ClientBuilder.

implicit val s3Client: AmazonS3 = AmazonS3ClientBuilder
      .standard
      .withCredentials(awsCredentialsProvider)
      .withRegion(new DefaultAwsRegionProviderChain().getRegion)
      .build

08-07 14:28