【发布时间】:2018-08-21 04:15:54
【问题描述】:
我试图通过 powershell 列出所有 AWS 卷并获取它所连接的实例。我正在运行一个具有帐户 root 权限的 powershell 程序,如下所示。
使用文档:
一种。 https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/TVolume.html
湾。 https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/EC2/TVolumeAttachment.html
我正在使用代码:
$volno=0
foreach ($i in Get-EC2Volume) {
++$volno
write-host $i.VolumeId $i.Name $i.Size $i.VolumeType
write-host $i.Atachments.Count
foreach ($j in $i.Atachments) {
$j.InstanceId
}
}
我得到了这些结果:
vol-83d1e111 10 gp2
0
vol-2248a222 8 gp2
0
vol-4b48a333 30 gp2
0
vol-345fbf44 50 gp2
0
vol-b4876b55 8 gp2
0
....
问题
- 结果显示没有附件,也就是说,所有卷都没有附加到任何实例。一些卷附加到正在运行的实例。为什么?
参考 A.显示有一个属性“附件”,其类型为System.Collections.Generic.List
和
参考 B.表明Amazon.EC2.Model.VolumeAttachment有InstanceId的成员
【问题讨论】:
标签: amazon-web-services volumes