AWS SDK for Golang

AWS SDK for Go

Amazon has published an Amazon Web Services SDK for Go programming language. Currently it’s experimental, so expect bugs, but you can already use it to manage your AWS stuff.

What is AWS SDK

Amazon Web Services provide a lot of pieces of cloud infrastructure, such as EC2 (Elastic Compute Cloud), S3 (Simple Storage Service), Route53 (DNS Management). They can be managed through the web admin console, but the most power lies in the ability to use APIs to communicate with these services: provision new EC2 instances, upload or download files into S3, etc.

SDKs for various programming languages wrap those APIs into convenient libraries, which can be used in an idiomatic way from the language.

Amazon provides official AWS SDKs for many languages: C#, Java, JavaScript, Objective C, PHP, Python, and Ruby. Today they made an experimental version of SDK available for Go.

Amazon Web Services SDK for Golang

The SDK for Go that Amazon released was first developed by Stripe, according to this blog post from AWS blog:

As we began our research, we came across aws-go, an SDK from Stripe. This SDK, principally authored by Coda Hale, was developed using model-based generation techniques very similar to how our other official AWS SDKs are developed. We reached out and began discussing possibly contributing to the project, and Stripe offered to transfer ownership of the project to AWS. We gladly agreed to take over the project and to turn it into an officially supported SDK product.

Installing and using AWS SDK

Currently AWS SDK for Go supports 43 Amazon services, such as AutoScaling, EC2, S3, Glacier, CloudFront, SimpleDB, Route53, and others.

Each service is represented by a separate subpackage. To use it, install the package you need with go get. For example, to use EC2:

go get github.com/awslabs/aws-sdk-go/gen/ec2

This will also automatically install the top-level aws package, which you’ll need for authentication. Here’s an example from README on how to use it:

import (
    "github.com/awslabs/aws-sdk-go/aws"
    "github.com/awslabs/aws-sdk-go/gen/ec2"
)

...

creds := aws.Creds(accessKey, secretKey, "")
cli := ec2.New(creds, "us-west-2", nil)
resp, err := cli.DescribeInstances(nil)
if err != nil {
    panic(err)
}
fmt.Println(resp.Reservations)

Check out documentation for more information.

Source code and license

GitHub: https://github.com/awslabs/aws-sdk-go
Documentation: https://godoc.org/github.com/awslabs/aws-sdk-go
License: Apache License 2

Go mascot by Renée French, used according to Creative Commons 3.0 Attribution License terms.

Learn Go & AWS

Programming in Go: Creating Applications for the 21st Century

Free Amazon Web Services Developer Guides

Leave a Reply

Your email address will not be published. Required fields are marked *