|
2 | 2 |
|
3 | 3 | [](http://godoc.org/github.com/awslabs/aws-sdk-go)
|
4 | 4 | [](https://travis-ci.org/awslabs/aws-sdk-go)
|
5 |
| -[](https://github.com/awslabs/aws-sdk-go/blob/master/LICENSE) |
| 5 | +[](https://github.com/awslabs/aws-sdk-go/blob/master/LICENSE.txt) |
6 | 6 |
|
7 |
| -aws-sdk-go is a set of clients for all Amazon Web Services APIs, |
8 |
| -automatically generated from the JSON schemas shipped with |
9 |
| -[botocore](http://github.com/boto/botocore). |
10 |
| - |
11 |
| -It supports all known AWS services, and maps exactly to the documented |
12 |
| -APIs, with some allowances for Go-specific idioms (e.g. `ID` vs. `Id`). |
| 7 | +aws-sdk-go is the official AWS SDK for the Go programming language. |
13 | 8 |
|
14 | 9 | ## Caution
|
15 | 10 |
|
16 |
| -It is currently **highly untested**, so please be patient and report any |
17 |
| -bugs or problems you experience. The APIs may change radically without |
18 |
| -much warning, so please vendor your dependencies w/ Godep or similar. |
| 11 | +The SDK is currently in the process of being developed, and not everything |
| 12 | +may be working fully yet. Please be patient and report any bugs or problems |
| 13 | +you experience. The APIs may change radically without much warning, so please |
| 14 | +vendor your dependencies with Godep or similar. |
19 | 15 |
|
20 | 16 | Please do not confuse this for a stable, feature-complete library.
|
21 | 17 |
|
22 |
| -Note that many services are currently not fully implemented. Some operations |
23 |
| -might work, but not all, especially for XML-based services. We are currently |
24 |
| -working to build out better service support, please bear with us! |
| 18 | +Note that while most AWS protocols are currently supported, not all services |
| 19 | +available in this package are implemented fully, as some require extra |
| 20 | +customizations to work with the SDK. If you've encountered such a scenario, |
| 21 | +please open a [GitHub issue](https://github.com/awslabs/aws-sdk-go/issues) |
| 22 | +so we can track work for the service. |
25 | 23 |
|
26 | 24 | ## Installing
|
27 | 25 |
|
28 |
| -Let's say you want to use EC2: |
| 26 | +Install your specific service package with the following `go get` command. |
| 27 | +For example, EC2 support might be installed with: |
29 | 28 |
|
30 | 29 | $ go get github.com/awslabs/aws-sdk-go/service/ec2
|
31 |
| - |
32 |
| -**NOTE**: If you are trying to use the development branch, after performing the command above, you must additionally check out the development branch: |
33 |
| - |
34 |
| - $ cd $GOPATH/src/github.com/awslabs/aws-sdk-go; git checkout develop |
| 30 | + |
| 31 | +You can also install the entire SDK by installing the root package: |
| 32 | + |
| 33 | + $ go get github.com/awslabs/aws-sdk-go/service/ec2 |
| 34 | + |
| 35 | +## Configuring Credentials |
| 36 | + |
| 37 | +Before using the SDK, ensure that you've configured credentials. The best |
| 38 | +way to configure credentials on a development machine is to use the |
| 39 | +`~/.aws/credentials` file, which might look like: |
| 40 | + |
| 41 | +``` |
| 42 | +[default] |
| 43 | +aws_access_key_id = AKID1234567890 |
| 44 | +aws_secret_access_key = MY-SECRET-KEY |
| 45 | +``` |
| 46 | + |
| 47 | +You can learn more about the credentials file from this |
| 48 | +[blog post](http://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs). |
35 | 49 |
|
36 | 50 | ## Using
|
37 | 51 |
|
| 52 | +To use a service in the SDK, create a service variable by calling the `New()` |
| 53 | +function. Once you have a service, you can call API operations which each |
| 54 | +return response data and a possible error. |
| 55 | + |
| 56 | +To list a set of instance IDs from EC2, you could run: |
| 57 | + |
38 | 58 | ```go
|
39 |
| -import "github.com/awslabs/aws-sdk-go/aws" |
40 |
| -import "github.com/awslabs/aws-sdk-go/service/ec2" |
41 |
| - |
42 |
| -creds := aws.Creds(accessKey, secretKey, "") |
43 |
| -cli := ec2.New(creds, "us-west-2", nil) |
44 |
| -resp, err := cli.DescribeInstances(nil) |
45 |
| -if err != nil { |
46 |
| - panic(err) |
| 59 | +package main |
| 60 | + |
| 61 | +import ( |
| 62 | + "fmt" |
| 63 | + |
| 64 | + "github.com/awslabs/aws-sdk-go/aws" |
| 65 | + "github.com/awslabs/aws-sdk-go/service/ec2" |
| 66 | +) |
| 67 | + |
| 68 | +func main() { |
| 69 | + // Create an EC2 service object in the "us-west-2" region |
| 70 | + // Note that you can also configure your region globally by |
| 71 | + // exporting the AWS_REGION environment variable |
| 72 | + svc := ec2.New(&aws.Config{Region: "us-west-2"}) |
| 73 | + |
| 74 | + // Call the DescribeInstances Operation |
| 75 | + resp, err := svc.DescribeInstances(nil) |
| 76 | + if err != nil { |
| 77 | + panic(err) |
| 78 | + } |
| 79 | + |
| 80 | + // resp has all of the response data, pull out instance IDs: |
| 81 | + fmt.Println("> Number of reservation sets: ", len(resp.Reservations)) |
| 82 | + for _, res := range resp.Reservations { |
| 83 | + fmt.Println(" > Number of instances: ", len(res.Instances)) |
| 84 | + for _, inst := range resp.Reservations[0].Instances { |
| 85 | + fmt.Println(" - Instance ID: ", *inst.InstanceID) |
| 86 | + } |
| 87 | + } |
47 | 88 | }
|
48 |
| -fmt.Println(resp.Reservations) |
49 | 89 | ```
|
| 90 | + |
| 91 | +You can find more information and operations in our |
| 92 | +[API documentation](http://godoc.org/github.com/awslabs/aws-sdk-go). |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +This SDK is distributed under the |
| 97 | +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0), |
| 98 | +see LICENSE.txt and NOTICE.txt for more information. |
0 commit comments