Skip to content

Amazon Machine Imageの更新作業を簡素化するCLI

License

Notifications You must be signed in to change notification settings

noritama73/update-ami

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coverage Status

update-ami

更新されたAuto Scaling Groupの設定をECSコンテナインスタンスに反映させるため,インスタンスの入れ替え作業を行うCLI

Usage

Install

go install github.com/noritama73/update-ami/cmd/[email protected]

Example

update-ami replace-instances --region ap-northeast-1 --profile <user>@<account> --cluster <cluster> --max-attempt 20 --waiter-delay 10

Arguments

cluster (Required)

対象とするECSクラスタ名.無ければAWS_ECS_CLUSTERを読む

region (Required)

対象のAWSリージョン.無ければAWS_REGIONを読む

profile (Required)

AWS CLIを使用するユーザのprofile,MFA対応.無ければAWS_PROFILEを読む

max-attempt (optional)

インスタンスのステータスチェックを行う最大試行回数.デフォルト40回

delay (optional)

インスタンスのステータスチェックを行う間隔.デフォルト20秒

asg-name (optional)

対象クラスタに紐づくAutoScaling Groupの名前.指定しないとクラスタと同じ文字列が入ります

内部的に実行される手順

  1. 既存のコンテナインスタンスのIDを控える
  2. ASGのmax-sizeとdesired capacityを1増やす
  3. 新しいインスタンスが追加されるのを待つ
  4. 古いインスタンスを1つドレインする
  5. ドレインされたらderegister→terminate
  6. インスタンスが増えるのを待つ
  7. サービスを強制更新
  8. ちょっと待つ
  9. 4.に戻る
  10. 最後のインスタンスをterminateしたら,max-sizeとdesired capacityを1減らす(元に戻す)

About

Amazon Machine Imageの更新作業を簡素化するCLI

Resources

License

Stars

Watchers

Forks

Packages

No packages published