最初に
これは個人プロダクトで学んだ内容をまとめたもの。
GitHub - selmertsx/serverless-prpolice
忘れる前に書いておくけれども、後でちゃんと整理する
学んだ内容
AWS
aws s3api create-bucket --bucket prpolice --create-bucket-configuration LocationConstraint=ap-northeast-1
# まずはAPI Gatewayの Method Request レイヤーで受け取る HTTP Method: POST, Resource Path: /index Method request path: {} Method request query string: {} Method request headers: {Accept=*/*, CloudFront-Viewer-Country=US, CloudFront-Forwarded-Proto=https, CloudFront-Is-Tablet-Viewer=false, CloudFront-Is-Mobile-Viewer=false, User-Agent=Slackbot 1.0 (+https://api.slack.com/robots), X-Forwarded-Proto=https, CloudFront-Is-SmartTV-Viewer=false, Host=xxx, Accept-Encoding=gzip,deflate, X-Forwarded-Port=443, X-Amzn-Trace-Id=Root=xxx, Via=1.1 xxx.cloudfront.net (CloudFront), X-Amz-Cf-Id=xx==, X-Forwarded-For=xxxx, CloudFront-Is-Desktop-Viewer=true, Content-Type=application/json} Method request body before transformations: { "token": "xxxx", "challenge": "xxx", "type": "url_verification" } # その後、Integration Requestにリクエストを流す Endpoint request URI: https://lambda.ap-northeast-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:xxx:function:prpolice-xxx/invocations Endpoint request headers: {x-amzn-lambda-integration-tag=xxx, Authorization=***, X-Amz-Date=20180208T122332Z, x-amzn-apigateway-api-id=b3kfmkg7ig, X-Amz-Source-Arn=xxx, Accept=application/json, User-Agent=xxx, X-Amz-Security-Token=xxx [TRUNCATED]
- API Gateway + Lambda インテグレーションでは、event.typeは取れない
- cloudformationで作ったリソースを手動で消したとして、cloudformationを再実行しても復元されない
Slack
- slackでは、outgoing web hooksは既に Legacy
- 最近は Events API を使うのが主流
- Events API を使う場合、url_verification をする必要がある
- LAMBDAで url_verificationをする用