简体   繁体   中英

storagegateway.ListGateways() returning “Invalid resource” with status code: 400

I am having trouble using the go sdk to list all of the storage gateways in a region using the following code:

package main

import (
    "fmt"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/storagegateway"
)

func newSess() (sess *session.Session) {
    sess, err := session.NewSession(&aws.Config{
        Region: aws.String("us-east-2"),
    })

    if err != nil {
        fmt.Printf("Error creating session: %s\n", err)
        return
    }

    return sess
}

func main() {
    sgw := storagegateway.New(newSess())

    input := &storagegateway.ListGatewaysInput{
        Limit:  aws.Int64(5),
        Marker: aws.String("1"),
    }

    result, err := sgw.ListGateways(input)
    if err != nil {
        fmt.Printf("Error listing gateways %s\n", err)
        return
    }

    fmt.Println(result)

}

My environment is the following:

  • Go version: 1.9.2 darwin/amd64
  • Operating system: macOS 10.13.2
  • aws-sdk-go: v1.12.63

The SDK is using the default profile specified in ~/.aws/config as it should and the credentials are correct as well. Furthermore, I am able to list the gateways using the awscli alone.

This could very well be something simple that I have overlooked as I am no expert. That said, any help would be greatly appreciated.

通过简单地删除Marker: aws.String("1")行,示例代码似乎对我来说按预期工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM