【Elastic Beanstalk】ebextentionsに設定したコマンドの実行ログを確認する

.ebextensionsの中にデプロイ時に実行したいコマンドを書いたconfigファイルを設置して
Elastic Beanstalkにアプリをデプロイしたところエラーが発生。
その時実行したコマンドのログファイルを見つけるのに悩んだので書き残しておく。

```sh
eb deploy

ERROR   Instance deployment failed. For details, see 'eb-engine.log'.
```

エラー内容に書かれている通りElastic Beanstalkのログからエラー内容を確認してみる。

```:cfn-init.log
2022-09-24 01:22:09,313 [INFO] -----------------------Starting build-----------------------
2022-09-24 01:22:09,319 [INFO] Running configSets: Infra-EmbeddedPostBuild
2022-09-24 01:22:09,322 [INFO] Running configSet Infra-EmbeddedPostBuild
2022-09-24 01:22:09,325 [INFO] Running config postbuild_0_blog
2022-09-24 01:22:10,720 [ERROR] Command next_build (npm run build) failed
2022-09-24 01:22:10,722 [ERROR] Error encountered during build of postbuild_0_blog: Command next_build failed
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 576, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 276, in build
    self._config.commands)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
    raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command next_build failed
2022-09-24 01:22:10,725 [ERROR] -----------------------BUILD FAILED!------------------------
2022-09-24 01:22:10,725 [ERROR] Unhandled exception during build: Command next_build failed
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 176, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 137, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 564, in build
    self.run_config(config, worklog)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 576, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 276, in build
    self._config.commands)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
    raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command next_build failed

```

うーん、ebextensionsの設定通り実行されているみたいだけどコマンドの実行ログまではわからない。。。

悩んでいたところElastic Beanstalkのフルログの中にcfn-init-cmd.logというファイルを発見。
見てみると。。。

```:cfn-init-cmd.log
2022-09-24 01:33:48,161 P7411 [INFO] ************************************************************
2022-09-24 01:33:48,161 P7411 [INFO] ConfigSet Infra-EmbeddedPreBuild
2022-09-24 01:34:07,125 P7596 [INFO] ************************************************************
2022-09-24 01:34:07,125 P7596 [INFO] ConfigSet Infra-EmbeddedPostBuild
2022-09-24 01:34:07,128 P7596 [INFO] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2022-09-24 01:34:07,128 P7596 [INFO] Config postbuild_0_blog
2022-09-24 01:34:07,136 P7596 [INFO] ============================================================
2022-09-24 01:34:07,136 P7596 [INFO] Command next_build
2022-09-24 01:34:08,505 P7596 [INFO] -----------------------Command Output-----------------------
2022-09-24 01:34:08,506 P7596 [INFO] 	
2022-09-24 01:34:08,506 P7596 [INFO] 	> blog@0.1.0 build
2022-09-24 01:34:08,506 P7596 [INFO] 	> next build
2022-09-24 01:34:08,506 P7596 [INFO] 	
2022-09-24 01:34:08,506 P7596 [INFO] 	info  - Linting and checking validity of types...
2022-09-24 01:34:08,506 P7596 [INFO] 	It looks like you're trying to use TypeScript but do not have the required package(s) installed.
2022-09-24 01:34:08,506 P7596 [INFO] 	Installing dependencies
2022-09-24 01:34:08,506 P7596 [INFO] 	
2022-09-24 01:34:08,506 P7596 [INFO] 	If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
2022-09-24 01:34:08,506 P7596 [INFO] 	
2022-09-24 01:34:08,506 P7596 [INFO] 	
2022-09-24 01:34:08,506 P7596 [INFO] 	Installing devDependencies (yarn):
2022-09-24 01:34:08,506 P7596 [INFO] 	- typescript
2022-09-24 01:34:08,506 P7596 [INFO] 	- @types/react
2022-09-24 01:34:08,506 P7596 [INFO] 	- @types/node
2022-09-24 01:34:08,506 P7596 [INFO] 	
2022-09-24 01:34:08,506 P7596 [INFO] 	node:events:491
2022-09-24 01:34:08,507 P7596 [INFO] 	      throw er; // Unhandled 'error' event
2022-09-24 01:34:08,507 P7596 [INFO] 	      ^
2022-09-24 01:34:08,507 P7596 [INFO] 	
2022-09-24 01:34:08,507 P7596 [INFO] 	Error: spawn yarn ENOENT
2022-09-24 01:34:08,507 P7596 [INFO] 	    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
2022-09-24 01:34:08,507 P7596 [INFO] 	    at onErrorNT (node:internal/child_process:478:16)
2022-09-24 01:34:08,507 P7596 [INFO] 	    at processTicksAndRejections (node:internal/process/task_queues:83:21)
2022-09-24 01:34:08,507 P7596 [INFO] 	Emitted 'error' event on ChildProcess instance at:
2022-09-24 01:34:08,507 P7596 [INFO] 	    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
2022-09-24 01:34:08,507 P7596 [INFO] 	    at onErrorNT (node:internal/child_process:478:16)
2022-09-24 01:34:08,507 P7596 [INFO] 	    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2022-09-24 01:34:08,507 P7596 [INFO] 	  errno: -2,
2022-09-24 01:34:08,507 P7596 [INFO] 	  code: 'ENOENT',
2022-09-24 01:34:08,507 P7596 [INFO] 	  syscall: 'spawn yarn',
2022-09-24 01:34:08,507 P7596 [INFO] 	  path: 'yarn',
2022-09-24 01:34:08,507 P7596 [INFO] 	  spawnargs: [
2022-09-24 01:34:08,507 P7596 [INFO] 	    'add',
2022-09-24 01:34:08,507 P7596 [INFO] 	    '--exact',
2022-09-24 01:34:08,508 P7596 [INFO] 	    '--cwd',
2022-09-24 01:34:08,508 P7596 [INFO] 	    '/var/app/staging',
2022-09-24 01:34:08,508 P7596 [INFO] 	    '--dev',
2022-09-24 01:34:08,508 P7596 [INFO] 	    'typescript',
2022-09-24 01:34:08,508 P7596 [INFO] 	    '@types/react',
2022-09-24 01:34:08,508 P7596 [INFO] 	    '@types/node'
2022-09-24 01:34:08,508 P7596 [INFO] 	  ]
2022-09-24 01:34:08,508 P7596 [INFO] 	}
2022-09-24 01:34:08,508 P7596 [INFO] ------------------------------------------------------------
2022-09-24 01:34:08,508 P7596 [ERROR] Exited with error code 1
```

これだー！

ということでコンソールからフルログを落としてきて`cfn-init-cmd.log`を見ればよさそうでした。