• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..23-Mar-2020-

aws/H23-Mar-2020-6,9534,029

private/H23-Mar-2020-2,3851,910

service/H23-Mar-2020-6,6742,553

README.mdH A D23-Mar-20205.7 KiB11781

README.md

1# AWS SDK for Go
2
3<span style="display: inline-block;">
4[![API Reference](http://img.shields.io/badge/api-reference-blue.svg)](http://docs.aws.amazon.com/sdk-for-go/api)
5[![Join the chat at https://gitter.im/aws/aws-sdk-go](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aws/aws-sdk-go?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6[![Build Status](https://img.shields.io/travis/aws/aws-sdk-go.svg)](https://travis-ci.org/aws/aws-sdk-go)
7[![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/aws/aws-sdk-go/blob/master/LICENSE.txt)
8</span>
9
10aws-sdk-go is the official AWS SDK for the Go programming language.
11
12Checkout our [release notes](https://github.com/aws/aws-sdk-go/releases) for information about the latest bug fixes, updates, and features added to the SDK.
13
14## Installing
15
16If you are using Go 1.5 with the `GO15VENDOREXPERIMENT=1` vendoring flag, or 1.6 and higher you can use the following command to retrieve the SDK. The SDK's non-testing dependencies will be included and are vendored in the `vendor` folder.
17
18    go get -u github.com/aws/aws-sdk-go
19
20Otherwise if your Go environment does not have vendoring support enabled, or you do not want to include the vendored SDK's dependencies you can use the following command to retrieve the SDK and its non-testing dependencies using `go get`.
21
22    go get -u github.com/aws/aws-sdk-go/aws/...
23    go get -u github.com/aws/aws-sdk-go/service/...
24
25If you're looking to retrieve just the SDK without any dependencies use the following command.
26
27    go get -d github.com/aws/aws-sdk-go/
28
29These two processes will still include the `vendor` folder and it should be deleted if its not going to be used by your environment.
30
31    rm -rf $GOPATH/src/github.com/aws/aws-sdk-go/vendor
32
33## Reference Documentation
34[`Getting Started Guide`](https://aws.amazon.com/sdk-for-go/) - This document is a general introduction how to configure and make requests with the SDK. If this is your first time using the SDK, this documentation and the API documentation will help you get started. This document focuses on the syntax and behavior of the SDK. The [Service Developer Guide](https://aws.amazon.com/documentation/) will help you get started using specific AWS services.
35
36[`SDK API Reference Documentation`](https://docs.aws.amazon.com/sdk-for-go/api/) - Use this document to look up all API operation input and output parameters for AWS services supported by the SDK. The API reference also includes documentation of the SDK, and examples how to using the SDK, service client API operations, and API operation require parameters.
37
38[`Service Developer Guide`](https://aws.amazon.com/documentation/) - Use this documentation to learn how to interface with an AWS service. These are great guides both, if you're getting started with a service, or looking for more information on a service. You should not need this document for coding, though in some cases, services may supply helpful samples that you might want to look out for.
39
40[`SDK Examples`](https://github.com/aws/aws-sdk-go/tree/master/example) - Included in the SDK's repo are a several hand crafted examples using the SDK features and AWS services.
41
42## Configuring Credentials
43
44Before using the SDK, ensure that you've configured credentials. The best
45way to configure credentials on a development machine is to use the
46`~/.aws/credentials` file, which might look like:
47
48```
49[default]
50aws_access_key_id = AKID1234567890
51aws_secret_access_key = MY-SECRET-KEY
52```
53
54You can learn more about the credentials file from this
55[blog post](http://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs).
56
57Alternatively, you can set the following environment variables:
58
59```
60AWS_ACCESS_KEY_ID=AKID1234567890
61AWS_SECRET_ACCESS_KEY=MY-SECRET-KEY
62```
63
64### AWS shared config file (`~/.aws/config`)
65The AWS SDK for Go added support the shared config file in release [v1.3.0](https://github.com/aws/aws-sdk-go/releases/tag/v1.3.0). You can opt into enabling support for the shared config by setting the environment variable `AWS_SDK_LOAD_CONFIG` to a truthy value. See the [Session](https://github.com/aws/aws-sdk-go/wiki/sessions) wiki for more information about this feature.
66
67## Using the Go SDK
68
69To use a service in the SDK, create a service variable by calling the `New()`
70function. Once you have a service client, you can call API operations which each
71return response data and a possible error.
72
73To list a set of instance IDs from EC2, you could run:
74
75```go
76package main
77
78import (
79	"fmt"
80
81	"github.com/aws/aws-sdk-go/aws"
82	"github.com/aws/aws-sdk-go/aws/session"
83	"github.com/aws/aws-sdk-go/service/ec2"
84)
85
86func main() {
87	// Create an EC2 service object in the "us-west-2" region
88	// Note that you can also configure your region globally by
89	// exporting the AWS_REGION environment variable
90	svc := ec2.New(session.NewSession(), &aws.Config{Region: aws.String("us-west-2")})
91
92	// Call the DescribeInstances Operation
93	resp, err := svc.DescribeInstances(nil)
94	if err != nil {
95		panic(err)
96	}
97
98	// resp has all of the response data, pull out instance IDs:
99	fmt.Println("> Number of reservation sets: ", len(resp.Reservations))
100	for idx, res := range resp.Reservations {
101		fmt.Println("  > Number of instances: ", len(res.Instances))
102		for _, inst := range resp.Reservations[idx].Instances {
103			fmt.Println("    - Instance ID: ", *inst.InstanceId)
104		}
105	}
106}
107```
108
109You can find more information and operations in our
110[API documentation](http://docs.aws.amazon.com/sdk-for-go/api/).
111
112## License
113
114This SDK is distributed under the
115[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0),
116see LICENSE.txt and NOTICE.txt for more information.
117