
Introduction
Boto3 is a Python library provided by AWS that allows you to configure various services provided by AWS such as DynamoDB and S3. Depending on how you use it, you can migrate the settings from the development environment to the production environment as they are, making it easier to set up your infrastructure.
This time, we will use Boto3 to check the data contents of DynamoDB.
Create reference table
Try Boto3
Since boto3 can be used with Lambda, use Lmabda. The function name can be anything, but this time I chose [watchDynamoDBData]. Create it with Python3.7.
Use a role that has permissions to access DynamoDB as the execution role. If it is not set, you will get an AccessDeniedException when executing Lambda.
Edit the created function as follows.
import boto3
def lambda_handler(event, context):
client = boto3.client('dynamodb')
For TableName, enter the name of the table you want to check
table = client.scan(TableName = "sample_tbl")
return table
Set up a test event and run it. It is successful if the output is as follows.
Response:
{
"Items": [
{
"sample_key": {
"S": "sample_data"
}
]
},
~~~~~~~~~~
~~~~~~~~~~
that’s all. thank you for your hard work.