Help us understand the problem. What is going on with this article?

Lambda+Golang版 CloudWatchアラームをChatWorkに通知

More than 1 year has passed since last update.

たぶんみんな作るので自分で作るには初日にやるしかない。
SNSイベントを受け取って ChatWork に投稿するだけなので簡単。
実際 Golang での開発部分よりその後のデプロイ部分で試行錯誤した時間のほうが長いかも。
この前使った CodeBuild と CodePipeline の経験が早速役に立った。

https://github.com/kawax/lambda-alarm-chatwork

注意点

公式のドキュメントが間違ってる。すぐに直るだろうけど。上のURLが現時点。
https://github.com/aws/aws-lambda-go/blob/6e2e37798efbb1dfd8e9c6681702e683a6046517/events/README_SNS.md
https://github.com/aws/aws-lambda-go/blob/master/events/README_SNS.md

import (
    "strings"
    "github.com/aws/aws-lambda-go/events")

func handler(ctx context.Context, events.SnsEvent snsEvent) {
    for _, record := range snsEvent.Records {
        snsRecord := record.Sns

        fmt.Printf("[%s %s] Message = %s \n", record.EventSource, snsRecord.Timestamp, snsRecord.Message) 
    }
}

引数部分が逆。
snsEvent events.SNSEvent

大文字。
record.SNS

戻り値返さないとLambdaでは失敗扱いになるかも。
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/go-programming-model-handler-types.html

おわり

他の言語のスキルがあれば Golang は今から始めても大丈夫。
特に Lambda との組み合わせは最高の予感しかしないので Golang もやっていく。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away