2021 03 31 Aws Lambda Deploy

打包签名器 #

$ GOOS=linux GOARCH=amd64 go build -v -o satotx main_aws.go
$ zip main.zip satotx

AWS Lambda 部署签名器步骤 #

  • 进入Lambda服务板块,选择region,并点击“create function”:

IMAGE

  • 选择“from scratch”
  • 填写function name:satotx
  • 选择runtime为go 1.x,并点击“create function”:

IMAGE

  • 点击上传文件包main.zip,并修改Runtime Setting的hello Handler为“satotx”:

IMAGE

  • 点击add trigger,并选择“API Gateway”:

IMAGE

  • 选择“REST API”,Security选择“open”,然后点击“Add”:

IMAGE

  • 点击API Gateway的名字进入修改:

IMAGE

  • 在‘/’增加Method Get

IMAGE

  • 并选好如下几项:

IMAGE

  • 在‘/’增加resource,proxy,并选择lambda:

IMAGE IMAGE

  • 然后选择“deploy api”,并选择“default” stage:

IMAGE IMAGE

  • 回到Function界面,添加私钥环境变量:

IMAGE

IMAGE

然后用Api Gateway的endpoint:https://2yijzccif7.execute-api.us-west-1.amazonaws.com/default 即可测试签名器:

curl -i -s -X POST -H 'Content-type: application/json' -d '{"txHex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"}' https://2yijzccif7.execute-api.us-west-1.amazonaws.com/default/utxo/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b/0

IMAGE

如果需要绑定独立域名,只用配置cname鉴权后就可以了。

IMAGE