英文:
Get tables whose wcu/rcu 200 or 200+ using boto3
问题
在使用 boto3 获取表格的 wcu/rcu 值方面,我有 200 多个表格,我需要列出 wcu/rcu 值设置为 200 或 200+ 的表格,所以我希望能够使用 boto3 找到解决方案,因为有些表格是按需的,有些已启用按预配吞吐量。我真的不想手动处理这个。
我尝试的代码如下:
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("table-name")
billing_mode = table.billing_mode_summary
print(billing_mode)
但这没有提供期望的输出。是否有方法可以做到这一点?
英文:
Is there any way to get table wcu/rcu value using boto3,
I have 200+ tables from which I need to list out tables whose wcu/rcu values are set to 200 or 200+, so looking for solution using boto3 if i can get these tables, as some tables are on demand and some have been provisioned throughput enable.
I really don't want to do this manually,
Code I tried is:
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("table-name")
billing_mode = table.billing_mode_summary
print(billing_mode)
but this doesn't provided desired output.
Is there any way to do this.
答案1
得分: 1
你可以使用dynamodb.describe_table
来获取表的WCU(Write Capacity Units)和RCU(Read Capacity Units)值,如下所示:
dynamodb = boto3.client('dynamodb')
...
table_info = dynamodb.describe_table(TableName="table-name")['Table']
wcu = table_info['ProvisionedThroughput']['WriteCapacityUnits']
rcu = table_info['ProvisionedThroughput']['ReadCapacityUnits']
... 您的条件来验证这些值...
要获取更多详细信息,请查看DynamoDB.Client.describe_table。
英文:
> Is there any way to get table wcu/rcu value using boto3
You can use dynamodb.describe_table
like this:
dynamodb = boto3.client('dynamodb')
...
table_info = dynamodb.describe_table(TableName="table-name")['Table']
wcu = table_info['ProvisionedThroughput']['WriteCapacityUnits']
rcu = table_info['ProvisionedThroughput']['ReadCapacityUnits']
... Your conditions to verify the values...
For more details check DynamoDB.Client.describe_table
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论