如何索引aws快照输出?

在这里,我正在打印我的快照。我在下面发布了我希望快照打印出来的样子,并且还希望能够打印单个快照。我不确定如何做到这一点,任何帮助都会很棒。


svc := ec2.New(&aws.Config{Region: "us-east-1"})

params := &ec2.DescribeSnapshotsInput{

    OwnerIDs: []*string{

        aws.String("130300684064"),

    },

}


b, err2 := svc.DescribeSnapshots(params)

if err2 != nil {

    panic(err2)

}

fmt.Printf(awsutil.StringValue(b))

这是输出的内容:http : //imgur.com/3MnBNXI 这是我想要输出的内容:


{


Snapshots:


----0


  Description: "Snapshot from MULTI",


  Encrypted: false,


  OwnerID: "130300684064",


  Progress: "100%!"(MISSING),


  SnapshotID: "snap-81b1dff6",


  StartTime: 2015-07-21 18:41:54 +0000 UTC,


  State: "completed",


  VolumeID: "vol-5121ebaa",


  VolumeSize: 1


},{


----1


  Description: "Snapshot from MULTI",


  Encrypted: false,


  OwnerID: "130300684064",


  Progress: "100%!"(MISSING),


  SnapshotID: "snap-08352a7f",


  StartTime: 2015-07-21 18:41:54 +0000 UTC,


  State: "completed",


  VolumeID: "vol-9b21eb60",


  VolumeSize: 1


},{


----2


  Description: "Snapshot from MULTI",


  Encrypted: false,


  OwnerID: "130300684064",


  Progress: "100%!"(MISSING),


  SnapshotID: "snap-768ffb00",


  StartTime: 2015-07-21 18:41:54 +0000 UTC,


  State: "completed",


  VolumeID: "vol-5620eaad",


  VolumeSize: 1


}]

完整代码在这里:http : //pastebin.com/QgmV6kRj


大话西游666
浏览 131回答 1
1回答

湖上湖

如果要打印单个快照的详细信息,可以迭代响应:resp, err := svc.DescribeSnapshots(params)if err != nil {    log.Fatal(err)}for i, s := range resp.Snapshots {    fmt.Printf("Snapshot: %d\n", i)    fmt.Println(s)}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go