メモ程度で Golangの smartystreets/go-aws-auth
軽量認証パッケージを使ってS3のバケット一覧リストをとってくる.
package main
import (
"fmt"
"github.com/smartystreets/go-aws-auth"
"net/http"
"io/ioutil"
)
func main() {
client := new(http.Client)
req, err := http.NewRequest("GET", "https://s3.amazonaws.com/", nil)
awsauth.Sign(req, awsauth.Credentials{
AccessKeyID: "*******************",
SecretAccessKey: "*******************",
})
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
resp_body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(resp.Status)
fmt.Println(string(resp_body))
}