0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

go-aws-authでS3バケット一覧を取得

0
Posted at

メモ程度で 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))
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?