I added .ebextensions/start.config
file to the root folder of my WAR bundle (as suggested by AWS), deployed it to Elastic Beanstalk, but nothing happened. Where
On a Linux 32 bits Tomcat 7 container, I was able to find logs at: /var/log/eb-tools.log
, where I was able to see which of my commands failed.
Snapshot the Logs for your Elastic Beanstalk environment through the online console.
When you view the logs, search for a section beginning "cfn-init.log".
In that section you'll see entries like
2013-08-30 10:25:13,517 [INFO] Command 01-ec2setcomputername-enable succeeded
2013-08-30 10:25:24,516 [INFO] Command 02-install-server-monitor succeeded
2013-08-30 10:25:30,115 [INFO] Command 03-install-agent succeeded
where 01-ec2setcomputername-enable, etc. are the names of the commands in my .config file. If the command fails, you should see the error message here too.
install and configure the eb cli than:
eb logs development
For Windows, the log file that contains your custom ebextension output is not part of the EB logs that you get via the EB console "request logs" command. But, you can easily add that log file to the bundle via this file command in an .ebextension file:
files:
"C:\\Program Files\\Amazon\\ElasticBeanstalk\\config\\taillogs.d\\cfn-init-cmd.conf" :
content: |
c:\cfn\log\cfn-init-cmd.log
All it does is create a new config file (cfn-init-cmd.conf) with the name of the log file (cfn-init-cmd.log) that you want added to the log bundle.
You can tail some logs in the web UI to see whether your .ebextensions
worked (via Elastic Beanstalk → view an environment → Logs). You should see a success or fail message for each command you define. (For example, for a command named 01_setup
you'll see a message like command 01_setup succeeded
.)
Although the log snapshot will show that a command failed, it won't show the command output:
[ERROR] Command 01_setup (setup.cmd) failed
[ERROR] Error encountered during build of postbuild_0_server: Command 01_setup failed
Traceback (most recent call last):
<irrelevant traceback>
You can connect to the underlying EC2 server and view the command output in the cfn-init-cmd.log
file (that's c:\cfn\log\cfn-init-cmd.log
in Windows, or /var/log/cfn-init-cmd.log
in Linux). This provides more useful information:
[INFO] Running command "setup.cmd"
[INFO] -----------------------Command Output-----------------------
[INFO] 'setup.cmd' is not recognized as an internal or external command,
[INFO] operable program or batch file.
[INFO] ------------------------------------------------------------
[ERROR] Exited with error code 1
For help connecting to an EC2 instance, see Windows instructions.
The command output also lets you run arbitrary commands to figure out what's going on. For example, which directory are the commands being executed in?
Here's the .ebextensions
file:
container_commands:
where_am_i:
command: dir
And here's the output in cfn-init-cmd.log
:
[INFO] Running command "dir"
[INFO] -----------------------Command Output-----------------------
[INFO] Volume in drive C has no label.
[INFO] Volume Serial Number is 12A7-BAEB
[INFO]
[INFO] Directory of C:\inetpub\wwwroot
[INFO]
[INFO] 05/29/2015 05:42 PM <DIR> .
[INFO] 05/29/2015 05:42 PM <DIR> ..
[INFO] 05/29/2015 05:42 PM <DIR> .ebextensions
[INFO] 05/29/2015 05:31 PM <DIR> bin
[INFO] 05/28/2015 05:20 PM 106 Global.asax
[INFO] 05/28/2015 05:20 PM 498 packages.config
[INFO] 05/28/2015 05:20 PM 2,054 README.md
[INFO] 05/29/2015 06:56 PM 3,064 Web.config
[INFO] 4 File(s) 5,722 bytes
[INFO] 4 Dir(s) 4,553,273,344 bytes free
[INFO] ------------------------------------------------------------
[INFO] Completed successfully.