aws lambda function getting access denied when getObject from s3

后端 未结 12 1580
离开以前
离开以前 2020-12-08 06:44

I am getting an acccess denied error from S3 AWS service on my Lambda function.

This is the code:

// dependencies
var async = require(\'async\');
var         


        
12条回答
  •  一生所求
    2020-12-08 07:21

    I was struggling with this issue for hours. I was using AmazonS3EncryptionClient and nothing I did helped. Then I noticed that the client is actually deprecated, so I thought I'd try switching to the builder model they have:

    var builder = AmazonS3EncryptionClientBuilder.standard()
      .withEncryptionMaterials(new StaticEncryptionMaterialsProvider(encryptionMaterials))
    if (accessKey.nonEmpty && secretKey.nonEmpty) builder = builder.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey.get, secretKey.get)))
    builder.build()
    

    And... that solved it. Looks like Lambda has trouble injecting the credentials in the old model, but works well in the new one.

提交回复
热议问题