AWS is buggy I think. I didn't make any change to the code. Today it is working fine. I struggled all day
I am reading the content of a file from S3 and trying to insert data into Dynamodb table. Everything works right up until inserting data into the dynamodb table. The table exists but it says resource not found Both Lambda and Dynamodb exist in the same region.
It says: "errorMessage": "An error occurred (ResourceNotFoundException) when calling the PutItem operation: Requested resource not found", "errorType": "ResourceNotFoundException",
I tried describe the table. that also throws error
dbclient = boto3.session('dynamodb')
response = dbclient.describe_table(TableName='USBCallCenterTable')
print(response)
import json
import boto3
from pprint import pprint
def lambda_handler(event, context):
session = boto3.session.Session()
s3_client = session.client('s3')
for record in event['Records']:
bucket_name=record['s3']['bucket']['name']
key_name = record['s3']['object']['key']
#pprint(dir(record))
#print(bucket,key)
response = s3_client.get_object(Bucket = bucket_name, Key = key_name)
#convert streaming data to byte
content = response['Body'].read()
##convert the byte into string
data_inString = content.decode('UTF-8')
##convert the string data into dictionary
data_inDictionary = json.loads(data_inString)
print(data_inDictionary)
dynamodbtable = boto3.resource('dynamodb')
table = dynamodbtable.Table('customer')
table.put_item(Item=data_inDictionary)

roleassociated with lambda function don't have permission or that table is not exists.