公式ドキュメント
ECS サービスの
enableExecuteCommand
をtrue
(デフォルト false) にした後に起動したタスクから有効化されるenableExecuteCommand を有効化
aws ecs update-service \ --cluster [クラスター名] \ --enable-execute-command \ --service [サービス名]
ECS コンソールから
新しいデプロイの強制
オプションを使用して、ECS サービスを再デプロイするタスクが入れ替わった後、有効化の確認
aws ecs describe-tasks \ --cluster [クラスター名] \ --tasks [タスク ID] \ | grep enableExecuteCommand
"enableExecuteCommand": true
となっていれば OK
- ECS Exec の実行
aws ecs execute-command \ --cluster [クラスター名] \ --task [タスクID] \ --container [コンテナ名] \ --interactive \ --command [コマンド]