Switch to using the dep tool and update all the dependencies

This commit is contained in:
Nick Craig-Wood 2017-05-11 15:39:54 +01:00
parent 5135ff73cb
commit 98c2d2c41b
5321 changed files with 4483201 additions and 5922 deletions

View file

@ -0,0 +1,31 @@
# Example
This is an example using the AWS SDK for Go to list ec2 instances that match provided tag name filter.
# Usage
The example uses the bucket name provided, and lists all object keys in a bucket.
```sh
go run -tags example filter_ec2_by_tag.go <name_filter>
```
Output:
```
listing instances with tag vpn in: us-east-1
[{
Instances: [{
AmiLaunchIndex: 0,
Architecture: "x86_64",
BlockDeviceMappings: [{
DeviceName: "/dev/xvda",
Ebs: {
AttachTime: 2016-07-06 18:04:53 +0000 UTC,
DeleteOnTermination: true,
Status: "attached",
VolumeId: "vol-xxxx"
}
}],
...
```

View file

@ -0,0 +1,43 @@
// +build example
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
)
// This example will list instances with a filter
//
// Usage:
// filter_ec2_by_tag <name_filter>
func main() {
sess := session.Must(session.NewSession())
nameFilter := os.Args[1]
awsRegion := "us-east-1"
svc := ec2.New(sess, &aws.Config{Region: aws.String(awsRegion)})
fmt.Printf("listing instances with tag %v in: %v\n", nameFilter, awsRegion)
params := &ec2.DescribeInstancesInput{
Filters: []*ec2.Filter{
{
Name: aws.String("tag:Name"),
Values: []*string{
aws.String(strings.Join([]string{"*", nameFilter, "*"}, "")),
},
},
},
}
resp, err := svc.DescribeInstances(params)
if err != nil {
fmt.Println("there was an error listing instances in", awsRegion, err.Error())
log.Fatal(err.Error())
}
fmt.Printf("%+v\n", *resp)
}