[英]What is the difference between terminate_instances() and terminate() in boto3?
I am trying to delete the instance using boto3
According to the documentation, there are two methods for deleting the instance using boto3.我正在尝试使用
boto3
删除实例根据文档,有两种使用 boto3 删除实例的方法。
terminate() 终止()
terminate_instances 终止实例
What is the difference between these two methods and which one should I use for deleting the instance?这两种方法有什么区别,我应该使用哪一种方法来删除实例?
Using terminate_instances() throws the following error:使用 terminate_instances() 会抛出以下错误:
AttributeError: 'ec2.ServiceResource' object has no attribute 'terminate_instances'
import boto3
ec2 = boto3.resource('ec2')
Instances = ec2.terminate_instances(InstanceIds=['i-xxxxxxxx'])
print(Instances)
What is the correct way to delete the instance using boto3?使用 boto3 删除实例的正确方法是什么?
The difference is simply the caller of the function.区别只是 function 的呼叫者。
The terminate
function is performed on a collection of instances you have already retrieved. terminate
function 是在您已经检索到的实例集合上执行的。
The terminate_instances
function is performed from the client, and requires you to specify the filter of which instances you need to terminate. terminate_instances
function 从客户端执行,并要求您指定需要终止哪些实例的过滤器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.