7

My Elastic Beanstalk container uses container_commands to run a script to patch the database on every deployment.

I run the deployments with a home-brewed script that calls the UpdateEnvironment on the Elastic Beanstalk API.

The problem is, I have no visibility on the output of my container_commands, which is pretty scary during deployment. The only way I can tell if something went wrong is when a command returns a non-zero value: in that case DescribeEvents will report a problem. But still, I have no way to get the actual output of the command.

How can I get my container_commands output after the deployment has finished?

Ideally, with the Elastic Beanstalk API, but any other programmatic way will be fine!

BenMorel
  • 4,507
  • 10
  • 57
  • 85

3 Answers3

15

Not a console view, but it is (now) visible in the logs.

.ebextensions/10-log.config

container_commands:
  05-whoami:
    command: "whoami"

/var/log/cfn-init.log after deployment

2014-07-01 22:08:10,695 [DEBUG] Running command 05-whoami
2014-07-01 22:08:10,695 [DEBUG] Generating defaults for command 05-whoami
2014-07-01 22:08:11,014 [DEBUG] Defaults script for 05-whoami output: {"env":{"EB_REQUEST_ID":"110d0932-016c-11e4-9f71-3fe967c5cd60", [long list of params omitted for brevity]}
2014-07-01 22:08:11,015 [DEBUG] No test for command 05-whoami
2014-07-01 22:08:11,050 [INFO] Command 05-whoami succeeded
2014-07-01 22:08:11,050 [DEBUG] Command 05-whoami output: root
Mark Berry
  • 273
  • 3
  • 18
3

Reply from the AWS support:

The easiest way to see the output would be to pipe the command or script output to a file using >>. Unfortunately there isn't a live console that can be viewed to show the process live.

So unfortunately there is no way to do that (yet).

BenMorel
  • 4,507
  • 10
  • 57
  • 85
0

Like @otaku mentioned above in one of the comments, I also located my command output in /var/log/cfn-init-cmd.log.

Here's what I was trying to run:

container_commands:
  20-migrate_database:
    command: |
      bash ./bin/export_database_migrations_url.sh
      bash ./bin/run_migrations.sh
    leader_only: true

The originally accepted answers are now a bit dated (as of May 2023). I'm sure they were right at the time, but this might be where to look if you're reading this nowadays.

Jon Worek
  • 1
  • 1