Elastic Beanstalk CMD-AppDeploy Activity failed (Composer issue???)

I've encountered the same problem with a Symfony deployment last week. Somehow the post-install scripts failed because of an issue with the Symfony prod/dev environment.

My temporary fix is disabling the post install scripts and running them later when the correct SYMFONY_ENV has been set.

In my .elasticbeanstalk/application.config:

option_settings:
  - namespace: aws:elasticbeanstalk:container:php:phpini
    option_name: composer_options
    value:  --no-dev --optimize-autoloader --no-scripts

And:

container_commands:
  21_composer_postinstall:
    command: composer.phar run-script post-install-cmd

The actual error why AppDeployPreHook/10_composer_install.sh failed in my case was in one of the other log files, so you might have to dig deeper.


Ive managed to solve the issue I was having. I had some private repos that were failing as composer could not download them as I had not set deploy keys in bitbucket. Adding the following to my config files solved the problem.

files:
  "/root/.ssh/bitbucket_deployment_key":
     mode: "000600"
     owner: root
     group: root
     content: |
       -----BEGIN RSA PRIVATE KEY-----
       PUT YOUR PRIVATE KEY HERE
       -----END RSA PRIVATE KEY-----
  "/root/.ssh/config":
       mode: "000600"
       owner: root
       group: root
       content: |
         Host bitbucket.org
            StrictHostKeyChecking no
            IdentityFile /root/.ssh/bitbucket_deployment_key
            UserKnownHostsFile /dev/null

From https://github.com/modern-media/wordpress-on-beanstalk

I'm not sure if this will fix solve the question asked. The error messages are pretty generic. I had to dig into the full EB logs to get to the bottom of mine.

Additional I have also found that sometimes composer can fail because it gets a 404 when trying to download a repo. This is very strange as I always though the composer.lock file should be reliable. This is an easy fix. Just delete your .lock file and run composer update again to get the correct repo URLs in your .lock file.