AWS Bot 対策


AWS で CloudFront + ECS で Web サービスを配信していますが、
Bot が多く、その対策を WAF で実行しようとしたい際にいくつかつまづきましたので、その備忘録になります。

以下 2 点を試しました。

  1. WAF v2 で GEO マッチステートメントで Bot のリクエスト元の海外 IP をブロック
  2. WAF v2 Bot Control で Bot 対策
続きを読む
JavaScript で日付計算の妙

JavaScript で日付計算の妙

問題です。以下コードを実行した際に何と出力されるでしょう?
先月の 1 日を取得したい気持ちです。

1
2
3
4
let dt = new Date('2022-10-31T15:00:00+0900');
dt.setMonth(dt.getMonth() - 1);
dt.setDate(1)
console.log(dt); // => ?
続きを読む
terraform で map 型の値を key 順にソートした上で value のリストを取得する

terraform で map 型の値を key 順にソートした上で value のリストを取得する

terraform で map 型を for で整形した際に key を昇順にソートして並べてくれます。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
> {for k, v in {"a":3, "c":2, "d":1}: v => k}

{
"1" = "d"
"2" = "c"
"3" = "a"
}

> values({for k, v in {"a":3, "c":2, "d":1}: v => k})

[
"d",
"c",
"a",
]

これを利用し、data リソースで取得した Subnet ID を AZ 順 (a → c → d) に list で取得してみます。

続きを読む
AWS ElastiCache Redis バージョンアップ&ノードタイプ変更時の注意点

AWS ElastiCache Redis バージョンアップ&ノードタイプ変更時の注意点

AWS より cache.m3 系から cache.m5 系へのアップグレードを促されました。

One or more of your Amazon ElastiCache clusters is running on our previous generation node type cache.m3.medium. We strongly recommend that you migrate to one of our latest generation node types, and with ElastiCache it is fast and easy to choose a new instance type for your cluster.

Our latest generation node types offer benefits such as better price per compute performance, higher-performing CPUs, improved memory, network performance, and ElastiCache optimizations such as enhanced I/O that provides improved throughput per node.

Migration to the latest generation node types is available via our scale-up feature. To scale up your cluster:
First, determine the best upgrade path from your previous generation node type(s) to the latest generation, see https://aws.amazon.com/elasticache/previous-generation

アップグレード時の注意事項をまとめます。

結論

続きを読む

RPi opencv で笑顔検知して Slack に通知するカメラを作った


概要

以前 RPi bullseye でカメラモジュール周りの設定が変わったことについて記載させていただきました。

RPi で opencv をセットアップする記事をネット上でいくつか見ましたが
bullseye より前のバージョンでの場合が多く、うまくいかないということが多かったです。

その為、 bullseye での設定をまとめます。

続きを読む