shd-notifier

shd-notifierをセットアップしようとしたメモ。

手順

クローンする。2行目のコマンドはサブディレクトリを新たなルートにしている。

git clone https://github.com/aws/aws-health-tools.git && cd aws-health-tools
git filter-branch --subdirectory-filter shd-notifier/ HEAD

マネコンから東京リージョンにSNSトピックを作成し、Eメールでサブスクライブしておく。

東京リージョンにCloudFormationでデプロイする。

ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text)
aws cloudformation deploy \
    --stack-name ShdNotifier \
    --template-file shd-notifier.yml \
    --parameter-overrides ChatClient="sns" \
        EndpointArray="[arn:aws:sns:ap-northeast-1:${ACCOUNT_ID}:shd-notifier-topic]]" \
        Bail=0 \
        DEBUG=1 \
    --capabilities CAPABILITY_NAMED_IAM

この時点で各Lambda関数は中身がない。

f:id:sotoiwa:20210729173333p:plain

deploy.shを実行する

deploy.sh Health-Event ap-northeast-1

Lambda関数がデプロイされる。

f:id:sotoiwa:20210729173355p:plain

Bail=0としたので15分でメールが来るはず。

しかしメールが来ない。

関数のログを見ると、以下のエラーが発生しており、どうやらHealth APIを実行しているため、ビジネス以上のサポートがないとダメな模様。

[ERROR] ClientError: An error occurred (SubscriptionRequiredException) when calling the DescribeEvents operation: 
Traceback (most recent call last):
  File "/var/task/index.py", line 77, in lambda_handler
    maxResults=maxEvents
  File "/var/runtime/botocore/client.py", line 386, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/var/runtime/botocore/client.py", line 705, in _make_api_call
    raise error_class(parsed_response, operation_name)