得到了下面的代码,它显示了我所有的存储网关。我只需要在一个网关上获得信息
import boto3
sg = boto3.client('storagegateway', 'us-east-1')
sg.list(gateways)
print (sg.list_gateways)知道如何过滤并只打印特定的gw吗?
发布于 2022-01-21 21:22:02
尝试像这样过滤特定网关的名称..。
import boto3
sg = boto3.client('storagegateway', 'us-east-1')
response = sg.list_gateways()
for gw in response['Gateways']:
if gw['GatewayName'] == 'YOUR_GATEWAY_NAME':
print(gw)您还可以对其他响应元素(例如ARN、ID等)进行筛选。通过更新IF语句。此外,如果您有超过100个存储网关实例,则需要处理Marker元素来检索所有结果。有关更多信息,请参见此处的Boto3文档:
https://stackoverflow.com/questions/70805366
复制相似问题