Getting Started with ECS - Go + S3(AWS SDK)

If you're a Go programmer, you can use AWS SDK for Go to connect to ECS for S3-compatible object storage.

Sample Go Code

Here's a quick example for connecting to EcsTestDrive server using IP on port 443 (HTTPS) and creating a bucket:


Import Aws Go SDK

import (

Get S3 connection

s3Config := &aws.Config{
    Credentials: credentials.NewStaticCredentials("your_access_key", "your_secret_key", ""),
    Endpoint:    aws.String(""),
    Region:      aws.String("us-east-1"),

s3client := s3.New(session.NewSession(s3Config))

Create Bucket

output, err := s3client.CreateBucket(&s3.CreateBucketInput{
    Bucket: aws.String("your_bucket_name"),


Since we're connecting using the default HTTPS protocol and port, we can omit port.


After getting connected to ECS, you can follow the AWS SDK for Go for other operations on buckets and keys. In addition, Go samples in ECS Sample Code demonstrate how to write Go code for these operations.


How to Build Go Application

Where shall we put AWS Go SDK Source Code in local repository for application? Go suggests to put all 3rd party(vendor) code to ./vendor directory in repo and put all source code to ./src directory, and all of them shall be committed to repository (Go Sample Code for ECS pulling vendor code during build is just to limit the size of sample code, it's NOT a recommended approach). There are many build tools besides go itself, and one of them is GB which is a very handy tool to maintain and build your application.


Install gb

go get -v

Fetch vendor code

gb vendor fetch

Build application

gb build



Standard AWS SDK for Go doesn't support ECS specific S3 operations like Metadata Search.