Mason8r
Mason8r

Reputation: 282

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

I have php application (Laravel) and the eb CLI installed. Locally, everything is fine.

The initial application is working as expected (uploaded as an archive.zip on created).

When I push my repo to my application using:

git aws.push

It fails. The logs say this:

[2014-12-12T16:53:38.652Z] INFO  [28264] - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/10_composer_install.sh] : Activity failed.
[2014-12-12T16:53:38.652Z] INFO  [28264] - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2014-12-12T16:53:38.652Z] INFO  [28264] - [CMD-AppDeploy/AppDeployStage0] : Activity failed.
[2014-12-12T16:53:38.653Z] INFO  [28264] - [CMD-AppDeploy] : Completed activity. Result:
Command CMD-AppDeploy failed.

and this

[2014-12-12T16:53:38.653Z] ERROR [28264] : Command CMD-AppDeploy failed!
[2014-12-12T16:53:38.654Z] INFO  [28264] : Command processor returning results: 
{"status":"FAILURE","api_version":"1.0","truncated":"true","results":
[{"status":"FAILURE","msg":"[CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/10_composer_install.sh] 
command failed with error code 1:
/opt/elasticbeanstalk/hooks/appdeploy/pre/10_composer_install.sh\n++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir\n+ EB_APP_STAGING_DIR=/var/app/ondeck\n+ 
cd /var/app/ondeck\n+ '[' -f composer.json ']'\n+ 
export COMPOSER_HOME=/root\n+ COMPOSER_HOME=/root\n+ '[' -d vendor ']'\n++ /opt/elasticbeanstalk/bin/get-config optionsettings -n aws:elasticbeanstalk:container:php:phpini -o composer_options\n+ PHP_COMPOSER_OPTIONS=\n+ 
echo 'Found composer.json file. Attempting to install vendors.'\nFound composer.json file.   
Attempting to install vendors.\n+ composer.phar install --no-ansi --no-interaction\nLoading composer repositories with package information\nInstalling dependencies (including require-dev) from lock file\n  - Installing symfony/finder (v2.5.8)\n ","returncode":1,"events":[]}]}

I was thinking it was a Composer issue, I have gone into the instance and done a composer update within the machine but that worked fine.

I have removed the composer.lock file from the .gitignore

I can't find anything similar online so I am assuming I am doing something / missing something very obvious here.

Upvotes: 8

Views: 3699

Answers (3)

Hobbis
Hobbis

Reputation: 1

I had the same problem setting up wordpress on aws beanstalk. My problem was that I zipped up the files locally on my windows machine then uploaded them which always failed to deploy. However, zipping the files on the server, then downloading them and using that zip as the deployment application for future always worked. So, copying files from the /var/app/current/ to the /home/ec2-user/ folder then zipping them from there, downloading the zip and keeping it as the package works.

Upvotes: 0

GWed
GWed

Reputation: 15673

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.

Upvotes: 5

Dylan Schoenmakers
Dylan Schoenmakers

Reputation: 171

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.

Upvotes: 6

Related Questions