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?

【AWS】SessionManagerPlugin is not found エラーの原因と解決方法(Mac / AWS CLI)

0
Posted at

AWS CLI で Session Manager や ECS Exec を利用しようとした際に、以下のエラーが発生することがあります。

SessionManagerPlugin is not found. Please refer to SessionManager Documentation here:
http://docs.aws.amazon.com/console/systems-manager/session-manager-plugin-not-found

この記事では、このエラーの原因と解決方法を解説します。

発生する場面

このエラーは主に以下のコマンドを実行した際に発生します。

aws ssm start-session
aws ecs execute-command
aws ssm start-port-forwarding-session

例えば ECS のコンテナへ接続しようとした場合です。

aws ecs execute-command \
  --cluster example-cluster \
  --task example-task \
  --container app \
  --interactive \
  --command "/bin/sh"

原因

AWS CLI は Session Manager Plugin という別のバイナリを利用して接続を行います。
つまり内部的には次のような構造になっています。

AWS CLI
   ↓
session-manager-plugin
   ↓
AWS Systems Manager
   ↓
EC2 / ECS

そのため session-manager-plugin がインストールされていない場合、このエラーが発生します。

解決方法

方法① Homebrew でインストール(Mac)

Mac では Homebrew を利用するのが簡単です。

brew install --cask session-manager-plugin

方法② 手動インストール

AWS公式のインストーラを利用する方法です。

curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac/sessionmanager-bundle.zip" -o "sessionmanager-bundle.zip"

unzip sessionmanager-bundle.zip

sudo ./sessionmanager-bundle/install \
  -i /usr/local/sessionmanagerplugin \
  -b /usr/local/bin/session-manager-plugin

インストール確認

インストール後、以下のコマンドで確認できます。

session-manager-plugin

または

which session-manager-plugin

正常にインストールされていれば次のようなメッセージが表示されます。

The Session Manager plugin was installed successfully

AWS CLI バージョン確認

念のため AWS CLI のバージョンも確認しておきます。

aws --version

aws-cli/2.13.36 Python/3.11

ECS Exec を使う場合の注意

ECS の Execute Command を利用する場合、以下の条件も満たす必要があります。

  • enableExecuteCommand が有効
  • Task Role に SSM 権限がある
  • session-manager-plugin がインストールされている
  • AWS CLI v2

まとめ

SessionManagerPlugin is not found エラーは ローカル環境に plugin がインストールされていないことが原因です。
Mac 環境であれば以下のコマンドで簡単に解決できます。

brew install --cask session-manager-plugin

ECS Exec や SSM を利用する際は、事前にインストールしておくとスムーズです。

参考

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?