Dav*_*ave 2 amazon-web-services boto3
如何使用 boto3 根据 InstanceId 检索实例名称?
connection = boto3.resource('ec2')
instances = connection.instances.filter(InstanceIds=[instanceid])
for instance in instances:
instance_name=???
Run Code Online (Sandbox Code Playgroud)
您需要获取标签Name:
def get_name(instance):
for tag in instance.tags:
if tag['Key'] == 'Name':
return tag['Value']
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3641 次 |
| 最近记录: |