Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

Today I Learned - 2026-06-08

今日学んだことを雑多に書く。

CloudFormationパラメータのTips

デフォルト値。

Parameters:
  StateMachineArn:
    Type: String
    Description: ARN of the Step Functions state machine to start.
    Default: arn:aws:states:ap-northeast-1:123456789:stateMachine:AddRdsReader

許可リスト。

Parameters:
  DBInstanceClass:
    Type: String
    AllowedValues: 
      - db.r8g.xlarge
      - db.r8g.2xlarge
      - db.r8g.4xlarge
      - db.r8g.8xlarge
      - db.r8g.12xlarge
      - db.r8g.16xlarge
      - db.r8g.24xlarge
      - db.r8g.48xlarge

入力パターン。正規表現で指定。

Parameters:
  DBInstanceClass:
    Type: String
    AllowedPattern: ^db\.r8g\.(\d+)?xlarge$

AWS リソース。

Parameters:
  AvailabilityZone:
    Type: AWS::EC2::AvailabilityZone::Name

AWS リソースのリスト。複数選択可。

Parameters:
  AvailabilityZone:
    Type: List<AWS::EC2::AvailabilityZone::Name>

最小値。最大値。

Parameters:
  PromotionTier:
    Type: Number
    MinValue: 0
    MaxValue: 15

参考。

https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/cloudformation-supplied-parameter-types.html

ncコマンドでの疎通確認

Ubuntsu on WSL で確認。

待ち受けておく。

nc -lk 8443

別ターミナルから接続。

echo "OK" | nc -q 0 localhost 8443

出力される。

nc -lk 8443
# OK

-l: Listen モード

-k: Keep inbound sockets open for multiple connects. 切断後も同じポートで次の接続を待ち続ける。

-q 0: quit after EOF on stdin and delay of secs. STDIN で EOF 後すぐに閉じる。

ncコマンドで200を返す

while true; do
  echo -e "HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nOK\n" | nc -l 8443
done

別ターミナルから接続。

echo "hello" | nc -q 0 localhost 8443
# HTTP/1.1 200 OK
# Content-Length: 3
# 
# OK
# 

-q 0によるクローズを発動させるには、echo をパイプでつなぐ。パイプの書き込み側が閉じられると、読み込み側(nc の stdin)は「もう読むデータはない」(EOF) と認識する。