LoginSignup
1
1

More than 3 years have passed since last update.

Go Lambda は aws-sam-cli@0.16.xでは動かないYO(2019/6/1現在)

Last updated at Posted at 2019-06-01

問題

$ brew tap aws/tap
$ brew install aws-sam-cli
-> v0.16.1が入る (2019/6/1現在)
$ sam init --runtime go --name hoge
$ cd hoge
$ sam local start-api

// 別セッションで
$ curl http://localhost:3000/hello

で、このエラーが起きます。

Invalid API Gateway Response Keys: set([u'multiValueHeaders']) in {u'body': u'{"Status":true,"Message":"OTP Generated"}', u'headers': {u'Content-Type': u'application/json'}, u'multiValueHeaders': {}, u'statusCode': 200}

Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received: {"statusCode":200,"headers":{"Content-Type":"application/json"},"multiValueHeaders":{},"body":"{\"Status\":true,\"Message\":\"OTP Generated\"}"}

詳細はここに書いてあるとおりです。
multivalue headers というフィールドが悪さしているみたいですね。

解決方法

0.15.0にダウングレードさせることで解決します。brewだとダウングレードが難しいので自分はpip経由で行いました。

// 0.16.x系をアンインストール
$ brew uninstall aws-sam-cli

// pipでバージョン指定でインストール
$ pip install --user aws-sam-cli==0.15.0

あとは

$ $(python -m site --user-base)/bin

この出力結果をパス通せば、 sam コマンドが使えるはずです。

よくわからなければ、AWSのチュートリアルをどうぞ。

$ sam --version
-> SAM CLI, version 0.15.0

MEDETASHI MEDETASHI

1
1
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
1
1