2019-01-03 17:18
浏览 66


So I have some different types of aws resources tagged as xxx/yyy/<generated_id>. I need to fetch them using go-sdk.

Here is a sample code for subnets, the filters look the same for every other resource.

This doesn't work.

var resp *ec2.DescribeSubnetsOutput
resp, err = d.ec2Client().DescribeSubnets(&ec2.DescribeSubnetsInput{
    Filters: []*ec2.Filter{
            Name:   aws.String("vpc-id"),
            Values: []*string{&d.VpcId},
            Name:   aws.String(fmt.Sprintf(`tag:"xxx/yyy.[*]"`),
            Values: []*string{aws.String("owned")},

This does: aws ec2 describe-subnets --filters `Name=tag:"xxx/yyy.[*]",Values=owned`

I'm obviously doing something wrong, can someone point out what?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • downloadbooks_2014 2019-01-03 17:55

    There is nothing in the API documentation to suggest that DescribeSubnets accepts a regular expression in filter names:

    If it works in the CLI, that's likely something the CLI is doing on top of what the SDK offers. The Go SDK is like any other AWS SDK; it exposes the AWS API in a language-specific way. The AWS CLI adds convenience features on top of the API to make it more useful on the command line, but that doesn't mean those features are exposed by the API or any published SDK.

    解决 无用
    打赏 举报

相关推荐 更多相似问题