Home > Blockchain >  Testing AWS Lambda via the console produces an Access Denied error
Testing AWS Lambda via the console produces an Access Denied error

Time:05-06

I've just deployed a stack via Cloudformation via a Github workflow runner. The Lambda is then shown in the AWS console. Within this, I test the Lambda with the "Event JSON". I then encounter the following error message:

START RequestId: 2ce35782-f9d6-4a33-b9b2-cbc27da7a3f34 Version: $LATEST
HTTP Error: 400 Client Error: Bad Request for url: https://api.random.com/v1/logs/segments/20220504/20220504/aggs
Exporting to path "s3://bucket/folder/2022/05/05/myjson.json"
[ERROR] ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
Traceback (most recent call last):
  File "/var/task/app.py", line 56, in lambda_handler
    upload_s3(bucket, prefix, json_payload)
  File "/var/task/utils.py", line 54, in upload_s3
    Key=key)
  File "/var/task/botocore/client.py", line 415, in _api_call

The complaint is with the uploading to s3, however the AWS credentials were set in the "Secret" section of Github. Where am I going wrong?

CodePudding user response:

It appears that the Lambda execution role doesn't have the necessary permission for putting an object in S3 bucket.

Identify Lambda execution role under Configuration tab for the deployed lambda function from AWS console and verify its permissions. You may add the necessary permissions for the role and test it again.

  • Related