0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Private な ECS で execute-command を有効にするメモ

Last updated at Posted at 2025-10-14

条件

必要な VPC Endpoint

  • 以下エンドポイントを作成(interface)
    ssmmessages
    ec2messages
    ssm
    

Security Group

  1. ECS Task にアタッチされている Security Group から VPC Endpoint への接続ができるようにアウトバウンドを設定する
  2. 以下の方法などで VPC Endpoint の Security Group で 443 ポートに TCP プロトコルでアクセスできるようにする
    • ECS Task にアタッチされている Security Group からの接続を許可する
    • ECS Task が配置されている Subnet の範囲からの接続を許可する

Task Definition

  • EnableExecuteCommand を有効化する
    • EnableExecuteCommand を true にする
  • readonlyRootFileSystem を true にしない
    • null か false(false は検証してないので不明)

IAM

  • ECS の TaskRole に AmazonSSmManagedInstanceCore をアタッチする

AWS CLI

  • session-manager-plugin をインストールする

Platform Version

  • 1.4.0 以上である必要があり(基本勝手に更新されそう)

確認

  • AWS Management Console 上で ECS のアクセスしたいタスクのコンテナを選択し、接続ボタンが押せるようになっていたら接続可能

蛇足

  • readonlyRootFileSystem で普通にハマってずっと SecurityGroup と Subnet 眺めてた
  • セキュリティー的には推奨されないし ECS で使うのはベストプラクティスに反するので開発環境でのみ有効化したい
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?