我試圖使用Python和Boto3獲取EC2實例的平臺名稱。但是,當我運行腳本時,它只會將Windows實例的平臺名稱顯示爲「Windows」,而在Linux平臺上運行的每個實例(Amazon Linux,Ubuntu,CentOS等)均顯示爲「無」。 這裏是我的腳本:獲取EC2實例的「平臺」屬性時出現錯誤
import boto3
ec2 = boto3.resource('ec2')
filters = [{'Name':'instance-state-name','Values':['running']}]
instances = ec2.instances.filter(Filters=filters).all()
for inst in instances:
print inst.id + "-" + str(inst.platform)
和輸出:
i-00dddfd5011ab2993-None
i-0ff7a32debff120de-None
i-018cd715318fc5b2d-None
i-06a84fa0421b7918c-windows
有沒有辦法,我能得到Linux實例的平臺屬性的任何方式?
[有沒有什麼辦法從實例中獲取平臺和操作系統](https://stackoverflow.com/questions/41172415/is-there-any-way-to-get-the-platform-和-OS-from-the-instances) – helloV