Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

"An error occurred (AccessDeniedException) when calling the Scan operation: #185

@Abhinavtuteja

Description

@Abhinavtuteja

import json
import os
import boto3
from boto3.dynamodb.conditions import Key, Attr

def lambda_handler(event, context):
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('fruits')
res = table.scan()
items = res["Items"]
print(items)
return {
'statusCode': 200,
'body': "helo from sam",
}

error i am facing

Response:
{
"errorMessage": "An error occurred (AccessDeniedException) when calling the Scan operation: User: arn:aws:sts::213393232127:assumed-role/lambda_basic_execution/HelloLambda is not authorized to perform: dynamodb:Scan on resource: arn:aws:dynamodb:us-east-2:213393232127:table/fruits",
"errorType": "ClientError",
"stackTrace": [
[
"/var/task/lambda_function.py",
10,
"lambda_handler",
"res = table.scan()"
],
[
"/var/runtime/boto3/resources/factory.py",
520,
"do_action",
"response = action(self, *args, **kwargs)"
],
[
"/var/runtime/boto3/resources/action.py",
83,
"call",
"response = getattr(parent.meta.client, operation_name)(**params)"
],
[
"/var/runtime/botocore/client.py",
314,
"_api_call",
"return self._make_api_call(operation_name, kwargs)"
],
[
"/var/runtime/botocore/client.py",
612,
"_make_api_call",
"raise error_class(parsed_response, operation_name)"
]
]
}

Request ID:
"bed12d92-7120-4310-a358-ae53235d7918"

Function Logs:
START RequestId: bed12d92-7120-4310-a358-ae53235d7918 Version: $LATEST
An error occurred (AccessDeniedException) when calling the Scan operation: User: arn:aws:sts::213393232127:assumed-role/lambda_basic_execution/HelloLambda is not authorized to perform: dynamodb:Scan on resource: arn:aws:dynamodb:us-east-2:213393232127:table/fruits: ClientError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 10, in lambda_handler
res = table.scan()
File "/var/runtime/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/var/runtime/boto3/resources/action.py", line 83, in call
response = getattr(parent.meta.client, operation_name)(**params)
File "/var/runtime/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the Scan operation: User: arn:aws:sts::213393232127:assumed-role/lambda_basic_execution/HelloLambda is not authorized to perform: dynamodb:Scan on resource: arn:aws:dynamodb:us-east-2:213393232127:table/fruits

END RequestId: bed12d92-7120-4310-a358-ae53235d7918
REPORT RequestId: bed12d92-7120-4310-a358-ae53235d7918 Duration: 652.45 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 32 MB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions