'Serverless framework fail to deploy due to s3 method - error reason: FUNCTION_ERROR_INIT_FAILURE
I am having a method in my app (NodeJS deployed as lambda in AWS using Serverless framework), that I use to get the list of items in an S3 bucket.
Method:
const getObjectsList = async (bucketName, path) => {
let s3 = new AWS.S3();
let prefix = `${path}/`;
let params = {
Bucket: bucketName,
Prefix: prefix,
}
let result = await s3.listObjectsV2(params).promise(); //CAUSE OF THE FAILURE
return result.Contents ?? [];
}
The issue it that I am getting the following error log when I try to deploy the service having that method:
UPDATE_FAILED: AppProvConcLambdaAlias (AWS::Lambda::Alias)
Provisioned Concurrency configuration failed to be applied. Reason: FUNCTION_ERROR_INIT_FAILURE
But the service gets deployed successfully without any issue if I comment let result = await s3.listObjectsV2(params).promise(); so I came to the conclusion that the failing cause is that method, but why is that? Am I missing something? I would like to also note that the app runs without any issue locally.
Serverless Config File (IAM part)
provider:
# SOME CONFIGURATIONS
iam:
role:
statements:
- Effect: Allow
Action:
- s3:PutObject
- s3:ListBucket
- s3:GetObject
- s3:DeleteObject
Resource:
- arn:aws:s3:::{HERE_COMES_THE_NAME_OF_MY_BUCKET}
- arn:aws:s3:::{HERE_COMES_THE_NAME_OF_MY_BUCKET}/*
# REST OF CONFIGURATION
EXTRA INFORMATION:
Environment: darwin, node 14.17.3, framework 3.12.0, plugin 6.2.1, SDK 4.3.2
Thank you all for your time and assistance. If I am missing any detail of crucial information please let me know.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
