AWSEC2 Systems Manager

EC2 System ManagerのRun Commandをデバッグする

EC2 System ManagerのRun Command実行結果をデバッグしたかったので、いろいろ調べてみました。 エラーログの場所 /var/log/amazon/ssm/errors.log にあります。 下記の […]

広告ここから
広告ここまで

EC2 System ManagerのRun Command実行結果をデバッグしたかったので、いろいろ調べてみました。

エラーログの場所

/var/log/amazon/ssm/errors.log にあります。
下記のようなエラーメッセージが格納されています。

2017-03-07 23:35:39 ERROR [AppendError @ plugin.go.161] [instanceID=i-0a441b6f3a8dfa5dd] [MessageProcessor] [pluginID=aws:runShellScript] failed to run commands: exit status 2
2017-03-07 23:35:39 ERROR [AppendError @ plugin.go.161] [instanceID=i-0a441b6f3a8dfa5dd] [MessageProcessor] [pluginID=aws:runShellScript] /var/lib/amazon/ssm/i-0a441b6f3a8dfa5dd/document/orchestration/f4e82e72-e036-486e-bf32-0fda86add4db/awsrunShellScript/0.awsrunShellScript/_script.sh: line 2: unexpected EOF while looking for matching `"'
/var/lib/amazon/ssm/i-0a441b6f3a8dfa5dd/document/orchestration/f4e82e72-e036-486e-bf32-0fda86add4db/awsrunShellScript/0.awsrunShellScript/_script.sh: line 7: syntax error: unexpected end of file

Run Commandのスクリプト保存場所

エラーメッセージをみる限り、以下のような場所にスクリプトが保存されている様子です。

# cat /var/lib/amazon/ssm/{InstanceID}/document/orchestration/20a193a1-1be8-4683-ac68-ca73062ed0a1/awsrunShellScript/0.awsrunShellScript/_script.sh 
ls -la

ちなみにそのまま実行できます。

# /var/lib/amazon/ssm/{InstanceID}/document/orchestration/20a193a1-1be8-4683-ac68-ca73062ed0a1/awsrunShellScript/0.awsrunShellScript/_script.sh 

total 60
dr-xr-x---  6 root root 4096 Mar  5 23:30 .
dr-xr-xr-x 25 root root 4096 Mar  7 23:16 ..
drwxr-xr-x  2 root root 4096 Mar  5 23:30 .aws
-rw-------  1 root root 3546 Mar  7 00:29 .bash_history
-rw-r--r--  1 root root   18 Jan 16  2011 .bash_logout
-rw-r--r--  1 root root  176 Jan 16  2011 .bash_profile
-rw-r--r--  1 root root  176 Jan 16  2011 .bashrc
-rw-r--r--  1 root root  100 Jan 16  2011 .cshrc
-rw-------  1 root root   32 Mar  5 23:09 .monit.id
-rw-r--r--  1 root root 3924 Mar  7 23:40 .monit.state
drwxr-----  3 root root 4096 Jan 11 13:48 .pki
-rw-------  1 root root 1024 Jan 11 13:48 .rnd
drwx------  2 root root 4096 Jan 11 13:47 .ssh
-rw-r--r--  1 root root  129 Jan 16  2011 .tcshrc
drwxr-xr-x  3 root root 4096 Mar  5 23:11 .wp-cli

ということで、Run Commandで実行したコマンドのデバッグをやりたい場合には、このあたりを探すようにすれば良さそうです。

ブックマークや限定記事(予定)など

WP Kyotoサポーター募集中

WordPressやフロントエンドアプリのホスティング、Algolia・AWSなどのサービス利用料を支援する「WP Kyotoサポーター」を募集しています。
月額または年額の有料プランを契約すると、ブックマーク機能などのサポーター限定機能がご利用いただけます。

14日間のトライアルも用意しておりますので、「このサイトよく見るな」という方はぜひご検討ください。

広告ここから
広告ここまで

Related Category posts