Nar*_*Rao 3 scripting amazon-ec2 python-3.x boto3
如何使用Boto3脚本使用标记和值过滤AWS实例,请建议!
import boto3
ec2 = boto3.resource('ec2')
client = boto3.client('ec2')
response = client.describe_tags(
Filters=[{'Key': 'Owner', 'Value': 'user@example.com'}])
print(response)
Run Code Online (Sandbox Code Playgroud)
谢谢,NTRao
hel*_*loV 14
您使用的是错误的API.使用describe_instances
import boto3
client = boto3.client('ec2')
custom_filter = [{
'Name':'tag:Owner',
'Values': ['user@example.com']}]
response = client.describe_instances(Filters=custom_filter)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8902 次 |
| 最近记录: |