This post explains how to use Python Boto3 APIs to obtain data such as Dynamodb table arn, table status, creation time, billing mode, and other details.
You need to have a DynamoDB table in order to follow this lesson; see this page for instructions on how to create a DynamoDB table.
To obtain the arn of a dynamodb table, see the python code example below. Replace "sample-movie-table-resource" with the name of your table.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
table_arn = table.table_arn
print(table_arn)
See the Python code sample below to find out how to get a dynamodb table's status. The name of your table should be substituted for "sample-movie-table-resource".
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
table_status = table.table_status
print(table_status)
To check the KeySchema of the table, see the Python code example below.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
key_schema = table.key_schema
print(key_schema)
Check the table's attribute definitions using the sample code below.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
attributes = table.attribute_definitions
print(attributes)
See the Python code sample below to get total count of items of dynamodb table.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
total_items = table.item_count
print(total_items)
Refer below sample code to check the details for the read/write capacity mode.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
billing_mode = table.billing_mode_summary
print(billing_mode)
To check the time of table creation, use the sample code below.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
creation_time = table.creation_date_time
print(creation_time)
To get table's server side encryption details, use the sample code below.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
sse_status = table.sse_description
print(sse_status)
To get unique identifier for the table, use the sample code below.
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("sample-movie-table-resource")
id = table.table_id
print(id)
Category: Python