Git Product home page Git Product logo

laravel-aws-eb's Introduction

Laravel Elastic Beanstalk

Laravel EB is a sample configuration to help you deploy a Laravel app on an AWS Elastic Beanstalk PHP environment without any super rockety-like knowledge.

๐Ÿค Supporting

If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, spread some kind words about our work or sponsor our work via Patreon. ๐Ÿ“ฆ

You will sometimes get exclusive content on tips about Laravel, AWS or Kubernetes on Patreon and some early-access to projects or packages.

Amazon Linux 2

This branch is working with the new Amazon Linux 2.

It's highly recommended to upgrade to the Amazon Linux 2 version, since it's faster and more secure. (see AWS's announcement)

To upgrade to AL2 from your Amazon Linux AMI, please see the Amazon Linux 2 migration guide

If you still work with Amazon Linux AMI, please switch to the amazon-ami branch to read the older docs.

Packaged

The sample configuration comes with:

  • Automation for copying .env file from AWS EB's S3 bucket (so you won't have to add the env variables from the AWS Console)
  • Laravel Artisan Scheduler CRON configuration
  • Supervisor for Queues
  • HTTP to HTTPS support
  • Nginx configuration support
  • Chromium binary

Updating

The repo works with semantic versioning, so please check the Releases page for latest updates & changes.

Installation

Clone the repo and drop the .ebextensions and .platform folders in your root project.

Make sure that the .sh files from the .platform folder are executable before deploying your project:

$ chmod +x .platform/hooks/prebuild/*.sh
$ chmod +x .platform/hooks/predeploy/*.sh
$ chmod +x .platform/hooks/postdeploy/*.sh
$ chmod +x .platform/scripts/*.sh

AWS EB Should-Know

Deployment Stages

Elastic Beanstalk helps you deploy apps while keeping them up, so you won't have to turn your app down during deployments. For this, there are two paths:

  • /var/app/staging that holds the app between deployments. This folder is not pointed to until the deployment finishes
  • /var/app/current that holds the live app and that serves requests actively

Each deploy makes you lose everything you have in the current folder. DO NOT rely on local storage, use S3 instead with CloudFront to avoid data loss and speed up the things.

.ebextensions/

The .ebextensions folder contains information about which commands to run during the deployment, such as migrations or copying files in the instance.

In this repo, see 01_deploy.config for a list of commands that will be ran upon deployment.

On the other hand, the 00_copy_env_file.config will copy the .env file from your S3 bucket and put it temporarily in the /tmp folder, to later be copied in the deployment process.

Please open the files to see further comments on the particular sections and change them.

.platform/

The .platform folder contains mostly shell scripts that will be ran during the deployment, like configuring or installing software, like supervisor, or running scripts after the deployment finished.

Consider looking in the files/ folder for Supervisor and PHP custom configurations that will be automatically be applied, out-of-the-box.

Additionally, the hooks/folder contains scripts that will be ran during various deployment stages. All scripts contain comments about details and best practices, so take a look.

Please refer to this scheme to understand the execution workflow: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/images/platforms-linux-extend-order.png

Use Cases

HTTP to HTTPS

Check the .platform/nginx/conf.d/elasticbeanstalk/https.conf file to enable HTTP to HTTPS redirect.

Laravel Passport

Since Laravel Passport uses local storage to keep the public and private key, there is no way of using this method. Instead, you might use what this PR added: laravel/passport#683

In your .env file, add the following variables and make sure that there is a \\n for each newline:

PASSPORT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\\nMIIJJwIBAAKCAgEAw3KPag...\\n-----END RSA PRIVATE KEY-----"
PASSPORT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\\nMIICIjANBgkqhkiG9w0BAQEFAAOC...\\n-----END PUBLIC KEY-----\\n"

Spatie Media Library & other Imagick-based packages

Some packages require Imagick to run.

To enable Imagick installation on the instance via Amazon Linux Extras, check install_imagick.sh file for details.

Memcached Auto Discovery

Memcached Auto Discovery for AWS Memcached is a PHP extension that replace the default Memcached extension, in order to use Memcached clusters in multi-node mode.

Plese see install_memcached_discovery.sh file to enable the installation for your PHP version.

For the Laravel app, edit your memcached connection in cache.php to make it suitable for multi-node configuration:

'memcached' => [
    'driver' => 'memcached',
    
    'persistent_id' => env('MEMCACHED_PERSISTENT_ID', 1), // make sure you also set a default to the persistent_id
    
    'options' => array_merge([
        Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
        Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
        Memcached::OPT_SERIALIZER => Memcached::SERIALIZER_PHP,
    ], in_array(env('APP_ENV'), ['production', 'staging']) ? [
        Memcached::OPT_CLIENT_MODE => Memcached::DYNAMIC_CLIENT_MODE,
    ] : []),
]

For production & staging workloads (when AWS Elasticache is used), Memcached::OPT_CLIENT_MODE should be set. OPT_CLIENT_MODE and DYNAMIC_CLIENT_MODE are Memcached Auto Discovery extension-related constants, not available in the default Memcached extension.

Chromium binary support

Some Laravel apps, like crawlers, might need a Chrome binary to run upon. A good example is spatie/browsershot. It lets you take browser screenshots using PHP and a Chromium binary.

To install Chromium, seek for the install_latest_chromium_binary.sh script and uncomment the code.

The binary can be then accessed from /usr/bin/google-chrome-stable

Run on Spot Instances

Spot instances are the cheapest EC2 instances from AWS, but they can be terminated anytime. Please refer to this to understand how they can be used: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html

Spot instances can be configured from the console. Check out AWS announcement: https://aws.amazon.com/about-aws/whats-new/2019/11/aws-elastic-beanstalk-adds-support-for-amazon-ec2-spot-instances/

Multi-environment

Sometimes you might have more than one environment, for example production and staging. Having duplicate configuration can be tricky, but you can workaround this problem by seeking a CloudFromation-like appoach as presented in one of the issues: #30 (comment)

The idea behind it is to use, for example, {"Ref": "AWSEBEnvironmentName"} value to concatenate to the name of the .env file that should be downloaded from S3. This way, you can have .env.staging-app if your AWS EB environment is named staging-app.

Deploying from the CI/CD Pipeline

To deploy to the EB environment, you have two choices:

  • Archive the ZIP by your own and upload it.
  • Pull from git, and use AWS EB CLI in the current folder (with no additional ZIP-ing)

AWS EB CLI make use of .gitignore and .ebignore. The only pre-configuration you need is to add the following environment variables to your CI/CD machine:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_EB_REGION

If you use a dockerized CI/CD pipeline (like Gitlab CI), you can make use of the renokico/aws-cli:latest image.

The following commands let you deploy an app on a certain environment within Gitlab CI on tag creation, for example:

$ git checkout $CI_COMMIT_TAG
$ eb init --region=$AWS_EB_REGION --platform=php [project-name]
$ eb use [environment-name]
$ eb deploy [environment-name] --label=$CI_COMMIT_TAG

laravel-aws-eb's People

Contributors

alexcode avatar ali-shaikh avatar dhrumil4u360 avatar galabl avatar maxvisser avatar rennokki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-aws-eb's Issues

Error: Command .platform/hooks/prebuild/update_composer.sh failed with error fork/exec .platform/hooks/prebuild/update_composer.sh: permission denied

Hello Alex, thank you for this awesome repo ,
I was trying your scripts but I got this error on prebuild hook:

Amazon Linux 2

2020/05/17 19:39:58.177299 [INFO] Executing instruction: StageApplication
2020/05/17 19:39:58.222485 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2020/05/17 19:39:58.222523 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2020/05/17 19:39:58.486747 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2020/05/17 19:39:58.500972 [INFO] Executing instruction: RunPreBuildHooks
2020/05/17 19:39:58.501029 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2020/05/17 19:39:58.501039 [INFO] No plugin in cfn metadata.
2020/05/17 19:39:58.501071 [INFO] Following platform hooks will be executed in order: [update_composer.sh]
2020/05/17 19:39:58.501077 [INFO] Running platform hook: .platform/hooks/prebuild/update_composer.sh
2020/05/17 19:39:58.501307 [ERROR] An error occurred during execution of command [app-deploy] - [RunPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/update_composer.sh failed with error fork/exec .platform/hooks/prebuild/update_composer.sh: permission denied 

2020/05/17 19:39:58.501316 [INFO] Executing cleanup logic

This is the content (copy-pasted) of .platform/hooks/prebuild/update_composer.sh :

#!/bin/sh

# Update Composer binary.

export COMPOSER_HOME=/root

sudo /usr/bin/composer.phar self-update

I tried executing it manually via SSH (ec2-user) and it worked:

[ec2-user@ip-172-redacted ~]$ export COMPOSER_HOME=/root
[ec2-user@ip-172-redacted ~]$ sudo /usr/bin/composer.phar self-update
Updating to version 1.10.6 (stable channel).
   Downloading (100%)         
Use composer self-update --rollback to return to version 1.9.3

I know it's not crucial for the deploy, but do you have any idea?

P.S: I'm on Windows 10, I tried chmoddin' with git bash and both files are already executable...

Discarding statistic item after validation error

Hi there,

My ebs server is returning "severe" status and my error log is like:

"W, [2020-10-24T05:48:33.136544 #31841] WARN -- : discarding statistic item after validation error (Invalid timestamp): {:id=>"7", :namespace=>"application", :timestamp=>1603516780, :data=>"{"duration":10,"latency_histogram":[[0.024,1]],"http_counters":{"status_302":1,"request_count":1}}"}"

What could be the reason?

Nginx conf is not loaded during self-startup command

First, thanks for your great work.
When EB run a self-startup command during a scale up event, it seems that the nginx conf is not reloaded leading to the following

This is the default index.html page that is distributed with nginx on Amazon Linux. It is located in /usr/share/nginx/html.

You should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file /etc/nginx/nginx.conf.

The config is properly copied in the /etc/nginx/conf.d/elasticbeanstalk/ directory but the nginx is not reloaded.

2021/07/01 08:31:33.561041 [INFO] Executing instruction: start proxy with new configuration
2021/07/01 08:31:33.561076 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2021/07/01 08:31:33.570163 [INFO] Running command /bin/sh -c cp -rp /var/proxy/staging/nginx/* /etc/nginx
2021/07/01 08:31:33.572764 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/07/01 08:31:33.581083 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/07/01 08:31:33.658480 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/07/01 08:31:33.662862 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/07/01 08:31:33.667630 [INFO] Running command /bin/sh -c systemctl is-active nginx.service
2021/07/01 08:31:33.671363 [WARN] startProcess Warning: process "nginx" is already running, skipping...

The solution would be to restart nginx in the hooks/postdeploy step.

Here is the full eb-engine.log

2021/07/01 08:31:00.417375 [INFO] bootstrap healthd....
2021/07/01 08:31:00.417401 [INFO] Running command /bin/sh -c /usr/bin/id -u healthd || /usr/sbin/useradd --user-group healthd -s /sbin/nologin --create-home
2021/07/01 08:31:00.419886 [INFO] 1001

2021/07/01 08:31:00.420139 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.420145 [INFO] Executing instruction: GetSetupProxyLog
2021/07/01 08:31:00.420270 [INFO] Skipping Install yum packages
2021/07/01 08:31:00.420279 [INFO] Skipping Install php dependency (composer/phpunit)
2021/07/01 08:31:00.420290 [INFO] Skipping Configure pear dependency
2021/07/01 08:31:00.420295 [INFO] Skipping MarkBaked
2021/07/01 08:31:00.420301 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.420305 [INFO] Executing instruction: TuneSystemSettings
2021/07/01 08:31:00.420308 [INFO] Starting TuneSystemSettings
2021/07/01 08:31:00.420314 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.420337 [INFO] Executing instruction: GetSetupLogRotate
2021/07/01 08:31:00.420341 [INFO] Initialize LogRotate files and directories
2021/07/01 08:31:00.552188 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.552211 [INFO] Executing instruction: BootstrapCFNHup
2021/07/01 08:31:00.552216 [INFO] Bootstrap cfn-hup
2021/07/01 08:31:00.560857 [INFO] Copying file /opt/elasticbeanstalk/config/private/aws-eb-command-handler.conf to /etc/cfn/hooks.d/aws-eb-command-handler.conf
2021/07/01 08:31:00.571364 [INFO] Executing instruction: StartCFNHup
2021/07/01 08:31:00.571383 [INFO] Start cfn-hup
2021/07/01 08:31:00.571403 [INFO] Running command /bin/sh -c systemctl is-active cfn-hup.service
2021/07/01 08:31:00.586259 [INFO] Running command /bin/sh -c systemctl is-active cfn-hup.service
2021/07/01 08:31:00.597277 [INFO] Running command /bin/sh -c systemctl show -p PartOf cfn-hup.service
2021/07/01 08:31:00.608998 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/07/01 08:31:00.685286 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/07/01 08:31:00.689693 [INFO] Running command /bin/sh -c systemctl is-enabled aws-eb.target
2021/07/01 08:31:00.695649 [INFO] Running command /bin/sh -c systemctl enable aws-eb.target
2021/07/01 08:31:00.779960 [INFO] Running command /bin/sh -c systemctl start aws-eb.target
2021/07/01 08:31:00.784562 [INFO] Running command /bin/sh -c systemctl enable cfn-hup.service
2021/07/01 08:31:00.860500 [INFO] Running command /bin/sh -c systemctl show -p PartOf cfn-hup.service
2021/07/01 08:31:00.865637 [INFO] Running command /bin/sh -c systemctl is-active cfn-hup.service
2021/07/01 08:31:00.869195 [INFO] Running command /bin/sh -c systemctl start cfn-hup.service
2021/07/01 08:31:00.914400 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.914414 [INFO] Executing instruction: SetupPublishLogCronjob
2021/07/01 08:31:00.914419 [INFO] Setup publish logs cron job...
2021/07/01 08:31:00.914424 [INFO] Copying file /opt/elasticbeanstalk/config/private/logtasks/cron/publishlogs to /etc/cron.d/publishlogs
2021/07/01 08:31:00.917281 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.917291 [INFO] Executing instruction: MarkBootstrapped
2021/07/01 08:31:00.917296 [INFO] Starting MarkBootstrapped
2021/07/01 08:31:00.917301 [INFO] Instance has NOT been bootstrapped
2021/07/01 08:31:00.917351 [INFO] Marked instance as Bootstrapped
2021/07/01 08:31:00.917356 [INFO] Executing instruction: Save CFN Stack Info
2021/07/01 08:31:00.917391 [INFO] Starting SwitchCFNStack
2021/07/01 08:31:00.917398 [INFO] Executing instruction: stopSqsd
2021/07/01 08:31:00.917406 [INFO] This is a web server environment instance, skip stop sqsd daemon ...
2021/07/01 08:31:00.917409 [INFO] Executing instruction: PreBuildEbExtension
2021/07/01 08:31:00.917414 [INFO] Starting executing the config set Infra-EmbeddedPreBuild.
2021/07/01 08:31:00.917427 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-west-3:285448848580:stack/awseb-e-p83vur8mzi-stack/f4c21400-60e1-11eb-b057-0ab019647cd0 -r AWSEBAutoScalingGroup --region eu-west-3 --configsets Infra-EmbeddedPreBuild
2021/07/01 08:31:01.531475 [INFO] Finished executing the config set Infra-EmbeddedPreBuild.

2021/07/01 08:31:01.531495 [INFO] Executing instruction: StageApplication
2021/07/01 08:31:01.531646 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2021/07/01 08:31:01.531662 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2021/07/01 08:31:02.572700 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2021/07/01 08:31:02.711571 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2021/07/01 08:31:02.711648 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2021/07/01 08:31:02.711725 [INFO] Following platform hooks will be executed in order: [configure_php_ini.sh install_imagick.sh install_latest_chromium_binary.sh install_latest_node_js.sh install_memcached_discovery.sh install_phpredis.sh install_supervisor.sh update_composer.sh]
2021/07/01 08:31:02.711731 [INFO] Running platform hook: .platform/hooks/prebuild/configure_php_ini.sh
2021/07/01 08:31:02.745075 [INFO] Running platform hook: .platform/hooks/prebuild/install_imagick.sh
2021/07/01 08:31:02.751557 [INFO] Running platform hook: .platform/hooks/prebuild/install_latest_chromium_binary.sh
2021/07/01 08:31:02.752739 [INFO] Running platform hook: .platform/hooks/prebuild/install_latest_node_js.sh
2021/07/01 08:31:16.248356 [INFO] Running platform hook: .platform/hooks/prebuild/install_memcached_discovery.sh
2021/07/01 08:31:16.255284 [INFO] Running platform hook: .platform/hooks/prebuild/install_phpredis.sh
2021/07/01 08:31:18.140717 [INFO] Running platform hook: .platform/hooks/prebuild/install_supervisor.sh
2021/07/01 08:31:30.895012 [INFO] Running platform hook: .platform/hooks/prebuild/update_composer.sh
2021/07/01 08:31:30.901887 [INFO] Finished running the platform hooks in .platform/hooks/prebuild/
2021/07/01 08:31:30.901922 [INFO] Executing instruction: Install composer dependencies
2021/07/01 08:31:30.901943 [INFO] vendor folder found, skip installing composer dependencies...
2021/07/01 08:31:30.901948 [INFO] Executing instruction: configure X-Ray
2021/07/01 08:31:30.901954 [INFO] X-Ray is not enabled.
2021/07/01 08:31:30.901958 [INFO] Executing instruction: configure proxy server
2021/07/01 08:31:30.909409 [INFO] Copying file /opt/elasticbeanstalk/config/private/nginx/php-fpm.conf to /var/proxy/staging/nginx/conf.d/php-fpm.conf
2021/07/01 08:31:30.918625 [INFO] Running command /bin/sh -c cp -rp /var/app/staging/.platform/nginx/. /var/proxy/staging/nginx
2021/07/01 08:31:30.927203 [INFO] Executing instruction: configure healthd specific proxy conf
2021/07/01 08:31:30.930173 [INFO] Running command /bin/sh -c systemctl show -p PartOf healthd.service
2021/07/01 08:31:30.938141 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/07/01 08:31:31.013676 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/07/01 08:31:31.018181 [INFO] Running command /bin/sh -c systemctl is-enabled aws-eb.target
2021/07/01 08:31:31.022265 [INFO] Running command /bin/sh -c systemctl enable aws-eb.target
2021/07/01 08:31:31.098027 [INFO] Running command /bin/sh -c systemctl start aws-eb.target
2021/07/01 08:31:31.102904 [INFO] Running command /bin/sh -c systemctl enable healthd.service
2021/07/01 08:31:31.181419 [INFO] Running command /bin/sh -c systemctl show -p PartOf healthd.service
2021/07/01 08:31:31.186715 [INFO] Running command /bin/sh -c systemctl is-active healthd.service
2021/07/01 08:31:31.190365 [INFO] Running command /bin/sh -c systemctl start healthd.service
2021/07/01 08:31:31.214528 [INFO] Copying file /opt/elasticbeanstalk/config/private/healthd/healthd_logformat.conf to /var/proxy/staging/nginx/conf.d/healthd_logformat.conf
2021/07/01 08:31:31.217778 [INFO] Copying file /opt/elasticbeanstalk/config/private/healthd/healthd_nginx.conf to /var/proxy/staging/nginx/conf.d/elasticbeanstalk/healthd.conf
2021/07/01 08:31:31.220838 [INFO] Executing instruction: configure php-fpm
2021/07/01 08:31:31.230611 [INFO] Executing instruction: configure log streaming
2021/07/01 08:31:31.230630 [INFO] log streaming is not enabled
2021/07/01 08:31:31.230634 [INFO] disable log stream
2021/07/01 08:31:31.230650 [INFO] Running command /bin/sh -c systemctl show -p PartOf amazon-cloudwatch-agent.service
2021/07/01 08:31:31.239135 [INFO] Running command /bin/sh -c systemctl stop amazon-cloudwatch-agent.service
2021/07/01 08:31:31.245796 [INFO] Executing instruction: GetToggleForceRotate
2021/07/01 08:31:31.245812 [INFO] Checking if logs need forced rotation
2021/07/01 08:31:31.245827 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-3:285448848580:stack/awseb-e-p83vur8mzi-stack/f4c21400-60e1-11eb-b057-0ab019647cd0 -r AWSEBAutoScalingGroup --region eu-west-3
2021/07/01 08:31:31.677387 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-3:285448848580:stack/awseb-e-p83vur8mzi-stack/f4c21400-60e1-11eb-b057-0ab019647cd0 -r AWSEBBeanstalkMetadata --region eu-west-3
2021/07/01 08:31:32.138829 [INFO] Procfile not found. Generating default rsyslog config
2021/07/01 08:31:32.141602 [INFO] Running command /bin/sh -c systemctl restart rsyslog.service
2021/07/01 08:31:32.165879 [INFO] Executing instruction: PostBuildEbExtension
2021/07/01 08:31:32.165914 [INFO] Starting executing the config set Infra-EmbeddedPostBuild.
2021/07/01 08:31:32.165929 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-west-3:285448848580:stack/awseb-e-p83vur8mzi-stack/f4c21400-60e1-11eb-b057-0ab019647cd0 -r AWSEBAutoScalingGroup --region eu-west-3 --configsets Infra-EmbeddedPostBuild
2021/07/01 08:31:32.608872 [INFO] Finished executing the config set Infra-EmbeddedPostBuild.

2021/07/01 08:31:32.608898 [INFO] Executing instruction: CleanEbExtensions
2021/07/01 08:31:32.609066 [INFO] Cleaned ebextensions subdirectories from app staging directory.
2021/07/01 08:31:32.609074 [INFO] Executing instruction: RunAppDeployPreDeployHooks
2021/07/01 08:31:32.609092 [INFO] Executing platform hooks in .platform/hooks/predeploy/
2021/07/01 08:31:32.609135 [INFO] Following platform hooks will be executed in order: [restart_services.sh]
2021/07/01 08:31:32.609142 [INFO] Running platform hook: .platform/hooks/predeploy/restart_services.sh
2021/07/01 08:31:33.283288 [INFO] Finished running the platform hooks in .platform/hooks/predeploy/
2021/07/01 08:31:33.283309 [INFO] Executing instruction: stop X-Ray
2021/07/01 08:31:33.283315 [INFO] stop X-Ray ...
2021/07/01 08:31:33.283329 [INFO] Running command /bin/sh -c systemctl show -p PartOf xray.service
2021/07/01 08:31:33.297204 [WARN] stopProcess Warning: process xray is not registered
2021/07/01 08:31:33.297236 [INFO] Running command /bin/sh -c systemctl stop xray.service
2021/07/01 08:31:33.304594 [INFO] Executing instruction: stop proxy
2021/07/01 08:31:33.304613 [INFO] Running command /bin/sh -c systemctl show -p PartOf httpd.service
2021/07/01 08:31:33.312196 [WARN] deregisterProcess Warning: process httpd is not registered, skipping...

2021/07/01 08:31:33.312217 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/07/01 08:31:33.316843 [WARN] deregisterProcess Warning: process nginx is not registered, skipping...

2021/07/01 08:31:33.316857 [INFO] Executing instruction: stop php-fpm
2021/07/01 08:31:33.316882 [INFO] Running command /bin/sh -c systemctl show -p PartOf php-fpm.service
2021/07/01 08:31:33.321549 [WARN] stopProcess Warning: process php-fpm is not registered
2021/07/01 08:31:33.321577 [INFO] Running command /bin/sh -c systemctl stop php-fpm.service
2021/07/01 08:31:33.357268 [INFO] Executing instruction: FlipApplication
2021/07/01 08:31:33.357350 [INFO] create soft link from /var/app/current/ to /var/www/html
2021/07/01 08:31:33.357373 [INFO] Executing instruction: start X-Ray
2021/07/01 08:31:33.357380 [INFO] X-Ray is not enabled.
2021/07/01 08:31:33.357384 [INFO] Executing instruction: start php-fpm
2021/07/01 08:31:33.357525 [INFO] Running command /bin/sh -c systemctl show -p PartOf php-fpm.service
2021/07/01 08:31:33.368208 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/07/01 08:31:33.445775 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/07/01 08:31:33.450166 [INFO] Running command /bin/sh -c systemctl show -p PartOf php-fpm.service
2021/07/01 08:31:33.454997 [INFO] Running command /bin/sh -c systemctl is-active php-fpm.service
2021/07/01 08:31:33.458678 [INFO] Running command /bin/sh -c systemctl start php-fpm.service
2021/07/01 08:31:33.561041 [INFO] Executing instruction: start proxy with new configuration
2021/07/01 08:31:33.561076 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2021/07/01 08:31:33.570163 [INFO] Running command /bin/sh -c cp -rp /var/proxy/staging/nginx/* /etc/nginx
2021/07/01 08:31:33.572764 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/07/01 08:31:33.581083 [INFO] Running command /bin/sh -c systemctl daemon-reload
2021/07/01 08:31:33.658480 [INFO] Running command /bin/sh -c systemctl reset-failed
2021/07/01 08:31:33.662862 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2021/07/01 08:31:33.667630 [INFO] Running command /bin/sh -c systemctl is-active nginx.service
2021/07/01 08:31:33.671363 [WARN] startProcess Warning: process "nginx" is already running, skipping...
2021/07/01 08:31:33.671383 [INFO] Executing instruction: configureSqsd
2021/07/01 08:31:33.671389 [INFO] This is a web server environment instance, skip configure sqsd daemon ...
2021/07/01 08:31:33.671394 [INFO] Executing instruction: startSqsd
2021/07/01 08:31:33.671398 [INFO] This is a web server environment instance, skip start sqsd daemon ...
2021/07/01 08:31:33.671402 [INFO] Executing instruction: Track pids in healthd
2021/07/01 08:31:33.671407 [INFO] This is an enhanced health env...
2021/07/01 08:31:33.671417 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf aws-eb.target | cut -d= -f2
2021/07/01 08:31:33.676942 [INFO] php-fpm.service nginx.service healthd.service cfn-hup.service

2021/07/01 08:31:33.676974 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf eb-app.target | cut -d= -f2
2021/07/01 08:31:33.682286 [INFO]

2021/07/01 08:31:33.682424 [INFO] Executing instruction: RunAppDeployPostDeployHooks
2021/07/01 08:31:33.682444 [INFO] Executing platform hooks in .platform/hooks/postdeploy/
2021/07/01 08:31:33.682496 [INFO] Following platform hooks will be executed in order: [create_cron_files.sh restart_supervisorctl.sh run_caches.sh x_make_folders_writable.sh x_optimize_php.sh]
2021/07/01 08:31:33.682502 [INFO] Running platform hook: .platform/hooks/postdeploy/create_cron_files.sh
2021/07/01 08:31:33.700497 [INFO] Running platform hook: .platform/hooks/postdeploy/restart_supervisorctl.sh
2021/07/01 08:31:34.939267 [INFO] Running platform hook: .platform/hooks/postdeploy/run_caches.sh
2021/07/01 08:31:36.686607 [INFO] Running platform hook: .platform/hooks/postdeploy/x_make_folders_writable.sh
2021/07/01 08:31:37.139491 [INFO] Running platform hook: .platform/hooks/postdeploy/x_optimize_php.sh
2021/07/01 08:31:37.141130 [INFO] Finished running the platform hooks in .platform/hooks/postdeploy/
2021/07/01 08:31:37.141148 [INFO] Executing cleanup logic
2021/07/01 08:31:37.141314 [INFO] Platform Engine finished execution on command: self-startup

Instance id(s) - did not pass health check after command execution. Aborting the operation.

When i run eb deploy to update code, it display errors:

022-05-06 15:30:44 UTC+0700 ERROR During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
2022-05-06 15:30:43 UTC+0700 ERROR Failed to deploy application.
2022-05-06 15:30:43 UTC+0700 ERROR Instance id(s) 'i-...' did not pass health check after command execution. Aborting the operation.

i checked logs, I think it's due to this error:

W, [2022-05-06T08:17:23.270992 #4601]  WARN -- : log file "/var/log/nginx/healthd/application.log.2022-05-06-08" does not exist
W, [2022-05-06T08:17:28.271258 #4601]  WARN -- : log file "/var/log/nginx/healthd/application.log.2022-05-06-08" does not exist
W, [2022-05-06T08:17:33.271515 #4601]  WARN -- : log file "/var/log/nginx/healthd/application.log.2022-05-06-08" does not exist
W, [2022-05-06T08:17:38.276736 #4601]  WARN -- : log file "/var/log/nginx/healthd/application.log.2022-05-06-08" does not exist

I found this article, but not sure if it should be the solution: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-serverlogs.html

if yes, i think we can add to your config for this case.

Error encountered during build of postbuild_0_XXXX: Command 00_copy_env_file failed

Hi

I'm facing this issue:

Error encountered during build of postbuild_0_XXXX: Command 00_copy_env_file failed

I've set the bucket name correctly and used instance profile name.

Am I missing anything? BTW I am still new to Elastic Beanstalk

Click to see the full error log

2020-09-21 06:45:25,967 [ERROR] Command 00_copy_env_file (mv /tmp/.env /var/app/staging/.env) failed
2020-09-21 06:45:25,967 [ERROR] Error encountered during build of postbuild_0_XXXX: Command 00_copy_env_file failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command 00_copy_env_file failed
2020-09-21 06:45:25,968 [ERROR] -----------------------BUILD FAILED!------------------------
2020-09-21 06:45:25,968 [ERROR] Unhandled exception during build: Command 00_copy_env_file failed
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 171, in <module>
    worklog.build(metadata, configSets)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
    self.run_config(config, worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
    changes['commands'] = CommandTool().apply(self._config.commands)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
    raise ToolError(u"Command %s failed" % name)
ToolError: Command 00_copy_env_file failed

[pool www] pm.min_spare_servers(0) must be a positive value

In AWS elastic beanstalk getting a php-fpm not running error caused only when the Elastic Beanstalk Load Balancer/Auto Scaler creates a new EC2 instance. Some instances get the Error and some don't

Getting error
[pool www] pm.min_spare_servers(0) must be a positive value

Seems to be caused by

.platform/hooks/postdeploy/x_optimize_php.sh

setting a negative value for pm.min_spare_servers sometimes. Doesn't happen all the time. but just enough to keep bring my site down when ever there is a spike in traffic and the load balance creates new instances.

as a fix I think this should be put in the file to save someone else having the same issue. I have added to mine

if (( ($MAX_CHILDREN > 0) && ($START_SERVERS > 0) && ($MIN_SPARE_SERVERS > 0) && ($MAX_SPARE_SERVERS > 0) && ($MIN_SPARE_SERVERS <= $MAX_CHILDREN) && ($MAX_SPARE_SERVERS <= $MAX_CHILDREN))); then sudo sed -i "s|pm.max_children.*|pm.max_children = $MAX_CHILDREN|g" /etc/php-fpm.d/www.conf sudo sed -i "s|pm.start_servers.*|pm.start_servers = $START_SERVERS|g" /etc/php-fpm.d/www.conf sudo sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = $MIN_SPARE_SERVERS|g" /etc/php-fpm.d/www.conf sudo sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = $MAX_SPARE_SERVERS|g" /etc/php-fpm.d/www.conf fi

No such file or directory

Hi @rennokki How do you fix this error when running eb deploy?

Error: Command .platform/hooks/prebuild/01_configure_php_ini.sh failed with error fork/exec .platform/hooks/prebuild/01_configure_php_ini.sh: no such file or directory

Thank you :)

Database connection [postgres] not configured.

When deploying with PHP 7.4 on AL2 current version 3.3.10, it is giving this problem related to composer install. In version 3.3.9 this does not happen. Is there any way around this?

2022/02/18 20:32:08.174278 [INFO] Executing instruction: StageApplication
2022/02/18 20:32:08.622477 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2022/02/18 20:32:08.622505 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2022/02/18 20:32:08.682970 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2022/02/18 20:32:08.688830 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2022/02/18 20:32:08.688850 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2022/02/18 20:32:08.688914 [INFO] Following scripts will be executed in order: [configure_php_ini.sh update_composer.sh]
2022/02/18 20:32:08.688920 [INFO] Running script: .platform/hooks/prebuild/configure_php_ini.sh
2022/02/18 20:32:08.706856 [INFO] Running script: .platform/hooks/prebuild/update_composer.sh
2022/02/18 20:32:09.061395 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/prebuild
2022/02/18 20:32:09.061416 [INFO] Executing instruction: Install composer dependencies
2022/02/18 20:32:09.061430 [INFO] installing composer dependencies...
2022/02/18 20:32:09.061451 [INFO] Running command /bin/sh -c composer.phar install --no-ansi --no-interaction
2022/02/18 20:32:14.559337 [INFO]
InvalidArgumentException

Database connection [postgres] not configured.

at vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:152
148| // If the configuration doesn't exist, we'll throw an exception and bail.
149| $connections = $this->app['config']['database.connections'];
150|
151| if (is_null($config = Arr::get($connections, $name))) {

152| throw new InvalidArgumentException("Database connection [{$name}] not configured.");
153| }
154|
155| return (new ConfigurationUrlParser)
156| ->parseConfiguration($config);

  ๏ฟฝ[2m+9 vendor frames ๏ฟฝ[22m

10 app/Services/NewService.php:23
Illuminate\Database\Eloquent\Model::query()

11 [internal]:0
App\Services\NewService::__construct(Object(App\Services\FileService), Object(App\Models\Administrator))

2022/02/18 20:32:14.559391 [ERROR] An error occurred during execution of command [app-deploy] - [Install composer dependencies]. Stop running the command. Error: installing composer dependencies failed with error: Command /bin/sh -c composer.phar install --no-ansi --no-interaction failed with error exit status 1. Stderr:Do not run Composer as root/super user! See https://getcomposer.org/root for details

Got Error

I'm using AWS ElasticBeanstalk & Codepipeline with github.

I added .ebextensions folder to my project.
After deploy, it gives error below:
2020-09-07 10:02:39,677 [ERROR] Command 02_install_node_dependencies (sudo npm install) failed
2020-09-07 10:02:39,677 [ERROR] Error encountered during build of postbuild_0_Form: Command 02_install_node_dependencies failed
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
changes['commands'] = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
raise ToolError(u"Command %s failed" % name)
ToolError: Command 02_install_node_dependencies failed
2020-09-07 10:02:39,678 [ERROR] -----------------------BUILD FAILED!------------------------
2020-09-07 10:02:39,678 [ERROR] Unhandled exception during build: Command 02_install_node_dependencies failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 171, in
worklog.build(metadata, configSets)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build
self.run_config(config, worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build
changes['commands'] = CommandTool().apply(self._config.commands)
File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply
raise ToolError(u"Command %s failed" % name)
ToolError: Command 02_install_node_dependencies failed

Seed DB

On .ebextensions/01_deploy.config

for the command: "php artisan migrate --force"
if you change it to "php atisan migrate:fresh --seed --forece"

it fails. Is there any way to seed the DB on EB ?

"sudo npm run prod" fails with "Exited with error code 243"

My deployment script (04-deploy-script.config) inside .ebextensions contains following

container_commands:
  00install_packages:
    command: "composer.phar install"
  01migration:
    command: "php artisan migrate --force"
  02npm_install:
    command: "sudo npm install"
  03build_node_assets:
    command: "sudo npm run prod"  
  04optimize_clear:
    command: "php artisan optimize:clear"

Everything goes normal until 02npm_install the very next command to it which is 03build_node_assets building node assets by running sudo npm run prod always fails, and if I remove the step/command fro building assets deployment goes normal and succeeds.
PS
Instance type running t3.small

Error from cfn-init.log

2022-08-01 08:51:13,354 [ERROR] Command 03build_node_assets (sudo npm run prod) failed
2022-08-01 08:51:13,354 [ERROR] Error encountered during build of postbuild_0_bettrcloudbar_webportal: Command 03build_node_assets 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 03build_node_assets failed
2022-08-01 08:51:13,357 [ERROR] -----------------------BUILD FAILED!------------------------
2022-08-01 08:51:13,357 [ERROR] Unhandled exception during build: Command 03build_node_assets 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 03build_node_assets failed

Error from cfn-init-cmd.log

2022-08-01 08:51:12,565 P12210 [INFO] Command 03build_node_assets
2022-08-01 08:51:13,353 P12210 [INFO] -----------------------Command Output-----------------------
2022-08-01 08:51:13,353 P12210 [INFO] 	
2022-08-01 08:51:13,353 P12210 [INFO] 	> prod
2022-08-01 08:51:13,353 P12210 [INFO] 	> npm run production
2022-08-01 08:51:13,353 P12210 [INFO] 	
2022-08-01 08:51:13,353 P12210 [INFO] 	
2022-08-01 08:51:13,353 P12210 [INFO] ------------------------------------------------------------
2022-08-01 08:51:13,353 P12210 [ERROR] Exited with error code 243

Error from eb-engine.log

2022/08/01 08:51:13.393640 [INFO] Error occurred during build: Command 03build_node_assets failed

2022/08/01 08:51:13.393885 [ERROR] An error occurred during execution of command [app-deploy] - [PostBuildEbExtension]. Stop running the command. Error: Container commands build failed. Please refer to /var/log/cfn-init.log for more details. 

2022/08/01 08:51:13.393889 [INFO] Executing cleanup logic
2022/08/01 08:51:13.405229 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1659343873393,"severity":"ERROR"}]}]}

Multi region environment deployments

What is the best way to insert the .env in a multi region environment?

The deployment would run... ap-southeast-2 (dev > prod) > us-east-1 > eu-central-1

The example works great for a single region (dev>prod), but how can I automatically get the S3 Bucket name, S3 Bucket path for other regions?

image

Would it be easier to add some environment variables and then query them?

image

Error when I try to install php-redis

When i uncomment the line to install php-redis i get an error

2021/08/20 17:10:29.924904 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/install_phpredis.sh failed with error exit status 1. Stderr:Error: Package: php-pecl-redis-2.2.8-1.el7.x86_64 (epel)
           Requires: php(zend-abi) = 20100525-64
           Installed: php-common-8.0.8-1.amzn2.x86_64 (@amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
           Available: php-common-5.4.16-43.amzn2.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.1.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.2.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.3.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.4.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-45.amzn2.0.5.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-45.amzn2.0.6.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-46.amzn2.0.2.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-8.0.0-2.amzn2.x86_64 (amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
           Available: php-common-8.0.2-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
           Available: php-common-8.0.6-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
Error: Package: php-pecl-redis-2.2.8-1.el7.x86_64 (epel)
           Requires: php(api) = 20100412-64
           Installed: php-common-8.0.8-1.amzn2.x86_64 (@amzn2extra-php8.0)
               php(api) = 20200930-64
           Available: php-common-5.4.16-43.amzn2.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.1.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.2.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.3.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.4.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-45.amzn2.0.5.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-45.amzn2.0.6.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-46.amzn2.0.2.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-8.0.0-2.amzn2.x86_64 (amzn2extra-php8.0)
               php(api) = 20200930-64
           Available: php-common-8.0.2-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(api) = 20200930-64
           Available: php-common-8.0.6-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(api) = 20200930-64
Error: Package: php-pecl-igbinary-1.2.1-1.el7.x86_64 (epel)
           Requires: php(api) = 20100412-64
           Installed: php-common-8.0.8-1.amzn2.x86_64 (@amzn2extra-php8.0)
               php(api) = 20200930-64
           Available: php-common-5.4.16-43.amzn2.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.1.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.2.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.3.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-43.amzn2.0.4.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-45.amzn2.0.5.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-45.amzn2.0.6.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-5.4.16-46.amzn2.0.2.x86_64 (amzn2-core)
               php(api) = 20100412-64
           Available: php-common-8.0.0-2.amzn2.x86_64 (amzn2extra-php8.0)
               php(api) = 20200930-64
           Available: php-common-8.0.2-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(api) = 20200930-64
           Available: php-common-8.0.6-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(api) = 20200930-64
Error: Package: php-pecl-igbinary-1.2.1-1.el7.x86_64 (epel)
           Requires: php(zend-abi) = 20100525-64
           Installed: php-common-8.0.8-1.amzn2.x86_64 (@amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
           Available: php-common-5.4.16-43.amzn2.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.1.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.2.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.3.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-43.amzn2.0.4.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-45.amzn2.0.5.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-45.amzn2.0.6.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-5.4.16-46.amzn2.0.2.x86_64 (amzn2-core)
               php(zend-abi) = 20100525-64
           Available: php-common-8.0.0-2.amzn2.x86_64 (amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
           Available: php-common-8.0.2-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(zend-abi) = 20200930-64
           Available: php-common-8.0.6-1.amzn2.x86_64 (amzn2extra-php8.0)
               php(zend-abi) = 20200930-64

Anyone know how to solve this?

Unable to load dynamic library 'imagick.so'

First of thanks for this awesome repo.

I am using PHP 7.4 running on 64bit Amazon Linux 2.

I'm trying to use imagick but composer dependencies failed with error:

Command /bin/sh -c composer.phar install --no-ansi --no-interaction failed with error exit status 2. Stderr:PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib64/php/modules/imagick.so (/usr/lib64/php/modules/imagick.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/imagick.so.so (/usr/lib64/php/modules/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

I'm using install_imagick.sh and it seems to run correctly, but then composing can't be completed.

This is the content (copy-pasted) of .platform/hooks/prebuild/install_imagick.sh :

#!/bin/sh

set +e

sudo amazon-linux-extras enable epel

sudo yum clean metadata

sudo yum install -y epel-release

sudo yum install -y ImageMagick ImageMagick-devel

printf '\n' | : sudo pecl install imagick

This is the content of eb-engine.log

2020/08/12 13:56:00.972697 [INFO] Executing instruction: StageApplication
2020/08/12 13:56:01.239048 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
2020/08/12 13:56:01.239080 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
2020/08/12 13:56:03.219671 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
2020/08/12 13:56:03.303040 [INFO] Executing instruction: RunAppDeployPreBuildHooks
2020/08/12 13:56:03.303058 [WARN] skipping hooks scripts under /opt/elasticbeanstalk/hooks/
2020/08/12 13:56:03.303074 [INFO] Executing platform hooks in .platform/hooks/prebuild/
2020/08/12 13:56:03.303105 [INFO] Following platform hooks will be executed in order: [install_imagick.sh]
2020/08/12 13:56:03.303110 [INFO] Running platform hook: .platform/hooks/prebuild/install_imagick.sh
2020/08/12 13:56:15.351290 [INFO] Finished running the platform hooks in .platform/hooks/prebuild/
2020/08/12 13:56:15.353375 [INFO] Executing instruction: Install composer dependencies
2020/08/12 13:56:15.353402 [INFO] installing composer dependencies...
2020/08/12 13:56:15.353444 [INFO] Running command /bin/sh -c composer.phar install --no-ansi --no-interaction 
2020/08/12 13:56:15.510356 [ERROR] An error occurred during execution of command [app-deploy] - [Install composer dependencies]. Stop running the command. Error: installing composer dependencies failed with error: Command /bin/sh -c composer.phar install --no-ansi --no-interaction  failed with error exit status 2. Stderr:PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib64/php/modules/imagick.so (/usr/lib64/php/modules/imagick.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/imagick.so.so (/usr/lib64/php/modules/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for spatie/pdf-to-image 2.0.0 -> satisfiable by spatie/pdf-to-image[2.0.0].
    - spatie/pdf-to-image 2.0.0 requires ext-imagick * -> the requested PHP extension imagick is missing from your system.
  Problem 2
    - spatie/pdf-to-image 2.0.0 requires ext-imagick * -> the requested PHP extension imagick is missing from your system.
    - spatie/laravel-medialibrary 7.19.2 requires spatie/pdf-to-image ^2.0 -> satisfiable by spatie/pdf-to-image[2.0.0].
    - Installation request for spatie/laravel-medialibrary 7.19.2 -> satisfiable by spatie/laravel-medialibrary[7.19.2].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
    - /etc/php.d/10-opcache.ini
    - /etc/php.d/20-bcmath.ini
    - /etc/php.d/20-bz2.ini
    - /etc/php.d/20-calendar.ini
    - /etc/php.d/20-ctype.ini
    - /etc/php.d/20-curl.ini
    - /etc/php.d/20-dom.ini
    - /etc/php.d/20-exif.ini
    - /etc/php.d/20-fileinfo.ini
    - /etc/php.d/20-ftp.ini
    - /etc/php.d/20-gd.ini
    - /etc/php.d/20-gettext.ini
    - /etc/php.d/20-gmp.ini
    - /etc/php.d/20-iconv.ini
    - /etc/php.d/20-intl.ini
    - /etc/php.d/20-json.ini
    - /etc/php.d/20-mbstring.ini
    - /etc/php.d/20-mysqlnd.ini
    - /etc/php.d/20-odbc.ini
    - /etc/php.d/20-pdo.ini
    - /etc/php.d/20-pgsql.ini
    - /etc/php.d/20-phar.ini
    - /etc/php.d/20-posix.ini
    - /etc/php.d/20-shmop.ini
    - /etc/php.d/20-simplexml.ini
    - /etc/php.d/20-soap.ini
    - /etc/php.d/20-sockets.ini
    - /etc/php.d/20-sodium.ini
    - /etc/php.d/20-sqlite3.ini
    - /etc/php.d/20-sysvmsg.ini
    - /etc/php.d/20-sysvsem.ini
    - /etc/php.d/20-sysvshm.ini
    - /etc/php.d/20-tokenizer.ini
    - /etc/php.d/20-xml.ini
    - /etc/php.d/20-xmlwriter.ini
    - /etc/php.d/20-xsl.ini
    - /etc/php.d/20-zip.ini
    - /etc/php.d/30-mysqli.ini
    - /etc/php.d/30-pdo_mysql.ini
    - /etc/php.d/30-pdo_odbc.ini
    - /etc/php.d/30-pdo_pgsql.ini
    - /etc/php.d/30-pdo_sqlite.ini
    - /etc/php.d/30-xmlreader.ini
    - /etc/php.d/30-xmlrpc.ini
    - /etc/php.d/aws.ini
    - /etc/php.d/project.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Someone has been able to use imagick in PHP 7.4 running on 64bit Amazon Linux 2?

I've tried everything and I don't know what to do :-(

Thanks!

No data after successful deploy

Hey,
first of all thank you for this great kickstart of the eb integration.
Still I couldn't get my project running yet.
The project seems to deploy with a successful state, but actually does nothing.
I can't grasp the problem since the logs seem to be ok.
I need to install grpc, because I use Firebase Cloud Messaging. The installation was successful, but the last line irritates me..
I linked the last lines of the installation...

The AWS-Website has the following events:

2022-01-25 21:49:27 UTC+0100 | INFO | Deleted log fragments for this environment.
2022-01-25 21:49:24 UTC+0100 | INFO | Environment health has transitioned from Info to No Data. None of the instances are sending data.
2022-01-25 21:47:33 UTC+0100 | INFO | Environment update completed successfully.
2022-01-25 21:47:33 UTC+0100 | INFO | Successfully deployed new configuration to environment.
2022-01-25 21:46:24 UTC+0100 | INFO | Removed instance [i-04a9b74a88003a44c] from your environment.

Tail of eb-hooks.logs running: make INSTALL_ROOT="/root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0" install Installing shared extensions: /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0/usr/lib64/php/modules/ running: find "/root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0" | xargs ls -dils 9376810 0 drwxr-xr-x 3 root root 17 Jan 25 17:38 /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0 6163547 0 drwxr-xr-x 3 root root 19 Jan 25 17:38 /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0/usr 9586479 0 drwxr-xr-x 3 root root 17 Jan 25 17:38 /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0/usr/lib64 14078354 0 drwxr-xr-x 3 root root 21 Jan 25 17:38 /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0/usr/lib64/php 1347846 0 drwxr-xr-x 2 root root 21 Jan 25 17:38 /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0/usr/lib64/php/modules 1347847 114128 -rwxr-xr-x 1 root root 116864112 Jan 25 17:38 /root/pear/temp/pear-build-rootqarJMX/install-grpc-1.43.0/usr/lib64/php/modules/grpc.so

Build process completed successfully
Installing '/usr/lib64/php/modules/grpc.so'
install ok: channel://pecl.php.net/grpc-1.43.0
Extension grpc enabled in php.ini

2022/01/25 17:38:08.188993 [INFO] Running command .platform/hooks/prebuild/install_imagick.sh
2022/01/25 17:38:08.190256 [INFO] Running command .platform/hooks/prebuild/install_latest_chromium_binary.sh
2022/01/25 17:38:08.191242 [INFO] Running command .platform/hooks/prebuild/install_latest_node_js.sh
2022/01/25 18:00:01.808004 [INFO] Running command .platform/hooks/prebuild/configure_php_ini.sh
2022/01/25 18:00:01.841823 [INFO] Running command .platform/hooks/prebuild/install_grpc.sh
2022/01/25 18:00:03.488862 [INFO] Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Package autoconf-2.69-11.amzn2.noarch already installed and latest version
No package zlib1g-dev available.
No package php-dev available.
Package 1:php-pear-1.10.12-9.amzn2.noarch already installed and latest version
Nothing to do
pecl/grpc is already installed and is the same as the released version 1.43.0
install failed

eb-engine.logs 2022/01/25 20:34:28.564746 [INFO] Starting... 2022/01/25 20:34:28.564806 [INFO] Starting EBPlatform-PlatformEngine 2022/01/25 20:34:28.564823 [INFO] reading event message file 2022/01/25 20:34:28.564929 [INFO] no eb envtier info file found, skip loading env tier info. 2022/01/25 20:34:28.564991 [INFO] Engine received EB command cfn-hup-exec

2022/01/25 20:34:28.644538 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:715874412273:stack/awseb-e-pqdav8xp9p-stack/345f1150-7e03-11ec-8170-0a3e3157960e -r AWSEBAutoScalingGroup --region eu-central-1
2022/01/25 20:34:28.955618 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:715874412273:stack/awseb-e-pqdav8xp9p-stack/345f1150-7e03-11ec-8170-0a3e3157960e -r AWSEBBeanstalkMetadata --region eu-central-1
2022/01/25 20:34:29.249446 [INFO] checking whether command bundle-log is applicable to this instance...
2022/01/25 20:34:29.249460 [INFO] this command is applicable to the instance, thus instance should execute command
2022/01/25 20:34:29.249465 [INFO] Engine command: (bundle-log)

2022/01/25 20:34:29.249516 [INFO] Executing instruction: GetBundleLogs
2022/01/25 20:34:29.249521 [INFO] Bundle Logs...

install_grpc.sh
#!/bin/sh

set +e

sudo yum -y install autoconf php-pear

sudo pecl install grpc

sed -i -e '/extension="grpc.so"/d' /etc/php.ini
echo 'extension="grpc.so"' > /etc/php.d/41-grpc.ini

Incorrect storage link

Running php artisan storage:link under /var/app/staging creates a link to the staging folder once the application is deployed

[ec2-user@ip-xxxx-xx-xx-xxx log]$ ls -ltr /var/app/current/public/
total 16
drwxrwxr-x 8 webapp webapp 4096 Jan 21 17:17 uploads
-rw-rw-r-- 1 webapp webapp   24 Jan 21 17:17 robots.txt
-rw-rw-r-- 1 webapp webapp 1731 Jan 21 17:17 index.php
drwxrwxr-x 2 webapp webapp   64 Jan 21 17:17 import
drwxrwxr-x 2 webapp webapp 4096 Jan 21 17:17 images
-rw-rw-r-- 1 webapp webapp    0 Jan 21 17:17 favicon.ico
lrwxrwxrwx 1 root   root     35 Jan 21 17:18 storage -> /var/app/staging/storage/app/public

Instead, running it as a postdeploy hook via a script generates the correct symlink

[ec2-user@ip-xxx-xx-xx-xxx log]$ ls -ltr /var/app/current/public/
total 16
drwxrwxr-x 8 webapp webapp 4096 Jan 21 17:26 uploads
-rw-rw-r-- 1 webapp webapp   24 Jan 21 17:26 robots.txt
-rw-rw-r-- 1 webapp webapp 1731 Jan 21 17:26 index.php
drwxrwxr-x 2 webapp webapp   64 Jan 21 17:26 import
drwxrwxr-x 2 webapp webapp 4096 Jan 21 17:26 images
-rw-rw-r-- 1 webapp webapp    0 Jan 21 17:26 favicon.ico
lrwxrwxrwx 1 root   root     35 Jan 21 17:27 storage -> /var/app/current/storage/app/public

It begins to return error on npm

2021-11-04 06:19:15,169 P3917 [INFO] Completed successfully.
2021-11-04 06:19:15,177 P3917 [INFO] ============================================================
2021-11-04 06:19:15,177 P3917 [INFO] Command 02_install_node_dependencies
2021-11-04 06:19:15,186 P3917 [INFO] -----------------------Command Output-----------------------
2021-11-04 06:19:15,187 P3917 [INFO] 	sudo: npm: command not found
2021-11-04 06:19:15,187 P3917 [INFO] ------------------------------------------------------------
2021-11-04 06:19:15,187 P3917 [ERROR] Exited with error code 1

It was working until this morning. But now, all my websites are down because of the same error.

Cloudfront as CDN

Hi,

does anyone have experience using cloudfront as a cdn for elastic beanstalk? This should protect the application DDOS.

Thanks for any help!

Error on deployment - post-autoload-dump event returned with error code 254

Hey,

when I'm trying to deploy my app, i get the following error:

Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Thu Dec  3 20:52:56 2020 (12547): Fatal Error Insufficient shared memory!
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 254
 

2020/12/03 20:52:56.916040 [INFO] Executing cleanup logic
2020/12/03 20:52:56.927649 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed to install Composer dependencies specified in 'composer.json' in your source bundle. The deployment failed.","timestamp":1607028776,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1607028776,"severity":"ERROR"}]}]}

Do anyone know, how to solve it?

Node.Js failed

as using your package, I got one issue with sudo npm install

maybe, I am doing wrong as I'm trying deployed the laravel project with your eb, seems all fine until sudo npm install failed

2021-10-20 10:48:34,072 [INFO] -----------------------Starting build-----------------------
2021-10-20 10:48:34,079 [INFO] Running configSets: Infra-EmbeddedPostBuild
2021-10-20 10:48:34,082 [INFO] Running configSet Infra-EmbeddedPostBuild
2021-10-20 10:48:34,086 [INFO] Running config postbuild_0_Ergnation_rowing
2021-10-20 10:48:34,103 [INFO] Command 00_copy_env_file succeeded
2021-10-20 10:48:36,241 [INFO] Command 01_install_composer_dependencies succeeded
2021-10-20 10:48:36,263 [ERROR] Command 02_install_node_dependencies (sudo npm install) failed
2021-10-20 10:48:36,263 [ERROR] Error encountered during build of postbuild_0_Ergnation_rowing: Command 02_install_node_dependencies failed
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 573, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 273, 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 02_install_node_dependencies failed
2021-10-20 10:48:36,266 [ERROR] -----------------------BUILD FAILED!------------------------
2021-10-20 10:48:36,266 [ERROR] Unhandled exception during build: Command 02_install_node_dependencies 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 135, in build
    Contractor(metadata).build(configSets, self)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 561, in build
    self.run_config(config, worklog)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 573, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 273, 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 02_install_node_dependencies failed

Queues

Hello,

I have two questions.

1 - it's possible to use horizon when using multiple servers on a load balancer?

2 - I'm trying to start multiple queues with the command bellow but it doesn't work. It simply doesn't execute my jobs.

php artisan queue:work --sleep=3 --tries=3 --backoff=3 --timeout=3600 --max-time=3600 --queue=default, notifications, imports

Thank you

Error with deploying: Fail to pre build extension

When I want to deploy my application, EB always fails with this error:

[ERROR] An error occurred during execution of command [app-deploy] - [PreBuildEbExtension]. Stop running the command. Error: EbExtension build failed. Please refer to /var/log/cfn-init.log for more details.

----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2020/11/08 20:30:33.160030 [INFO] Downloading: bucket: elasticbeanstalk-eu-central-1-123, object: /resources/environments/e-25pdmh7zyh/_runtime/_versions/Lala Project/10b5722
2020/11/08 20:30:33.182819 [INFO] Download successful500503bytes downloaded
2020/11/08 20:30:33.182990 [INFO] Executing instruction: ElectLeader
2020/11/08 20:30:33.182997 [INFO] Running leader election for instance i-0dd56f1ff5ada1116...
2020/11/08 20:30:33.183001 [INFO] Calling the cfn-elect-cmd-leader to elect the command leader.
2020/11/08 20:30:33.183018 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-elect-cmd-leader --stack arn:aws:cloudformation:eu-central-1:123:stack/awseb-e-25pdmh7zyh-stack/3988cf60-21fa-11eb-baa9-0a341c5d7b1a --command-name ElasticBeanstalkCommand-AWSEBAutoScalingGroup --invocation-id 40029aac-44d9-4554-a976-ff45def3da0b --listener-id i-0dd56f1ff5ada1116 --region eu-central-1
2020/11/08 20:30:33.524506 [INFO] Instance is Leader.
2020/11/08 20:30:33.524550 [INFO] Executing instruction: stopSqsd
2020/11/08 20:30:33.524557 [INFO] This is a web server environment instance, skip stop sqsd daemon ...
2020/11/08 20:30:33.524572 [INFO] Executing instruction: PreBuildEbExtension
2020/11/08 20:30:33.524576 [INFO] Starting executing the config set Infra-EmbeddedPreBuild.
2020/11/08 20:30:33.524600 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-central-1:123:stack/awseb-e-25pdmh7zyh-stack/3988cf60-21fa-11eb-baa9-0a341c5d7b1a -r AWSEBAutoScalingGroup --region eu-central-1 --configsets Infra-EmbeddedPreBuild
2020/11/08 20:30:48.585923 [ERROR] An error occurred during execution of command [app-deploy] - [PreBuildEbExtension]. Stop running the command. Error: EbExtension build failed. Please refer to /var/log/cfn-init.log for more details. 

2020/11/08 20:30:48.585940 [INFO] Executing cleanup logic

I deploy with eb deploy from my Linux machine.

I have

  • .ebextensions and .platform in the root folder
  • All *.sh scripts have +x perms

I use immutable deployments with a single instance. I also added the AWSElasticBeanstalkFullAccess to my role aws-elasticbeanstalk-ec2-role

This is my first task/entry in .ebextensions, 00_copy_env_file.config:

# Replace `elasticbeanstalk-eu-central-1-xxxxxxxxxxxx` with the bucket that AWS created
# when you created your first Elastic Beanstalk environment.

# Make sure that the IAM Role for the EC2 Instance set in the Elastic Beanstalk configuration
# has attached the `AWSElasticBeanstalkFullAccess` policy.

Resources:
  AWSEBAutoScalingGroup:
    Metadata:
      AWS::CloudFormation::Authentication:
        S3Auth:
          type: "s3"
          buckets: ["elasticbeanstalk-eu-central-1-123"]
          roleName:
            "Fn::GetOptionSetting":
              Namespace: "aws:autoscaling:launchconfiguration"
              OptionName: "IamInstanceProfile"
              DefaultValue: "aws-elasticbeanstalk-ec2-role"

# From the created bucket, point to the .env file which you want to
# copy to this app during deployment.

# The file will be copied first in /tmp/.env, then moved to the app
# in the deployment process.

files:
  "/tmp/.env":
    mode: "000777"
    owner: root
    group: root
    authentication: "S3Auth"
    source: 'https://elasticbeanstalk-eu-central-1-123.s3.eu-central-1.amazonaws.com/.env.`{"Ref": "AWSEBEnvironmentName" }`'

.. of course with the proper user id instead of 123.

Any idea whats wrong?

Thanks in advance.

Should I configure Laravel Queue worker manually?

Hi there, I just saw inside .platform/files/supervise.ini there is the command for artisan horizon. I believe this is the command executed in beanstalk. In my laravel project I haven't use horizon. My current requirement is to just run artisan queue:work. Do I have to change this command to make my way or it comes out of box with horizon. Also Iam using Aws SQS as my queue driver and not Redis. So Can I still use your configuration ?
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/app/current/artisan horizon
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/dev/null

Supervisor running but not processing jobs

Hi, I was able to get supervisor up and running, but for an unkown reason supervisor is not processing the jobs in my default queue.

super_logs

This is my supervisor conf:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/app/current/artisan queue:work --queue=default --tries=1
autostart=true
autorestart=true
user=root
numprocs=4
redirect_stderr=true
stdout_logfile=/dev/null

Is there any log I can read to know what is the possible error? Thanks in advanced for any kind of help.

Access Denied s3 .env

Hi there,

Tried to copy .env file from s3, but It couldn't reach the file. (file doesnt have public access)

Is there anyway to copy it with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY ?

Health Monitor

Hi!!

I have this issue:

image

image

All this data is blank. I'm researching to find a reason but i've found nothing till now.

Does somebody have any clues?

Problem with new instances launched by auto scaling

Hi,

I've been trying to solve this problem.

When I deploy a new application version all instances on the auto scaling group work well.. All of them respond on health checks.

However, when a new instance is launched by auto scaling, this new instance don't pass on health check.

If I have two instances on my environments and one is not healthy and I deploy a new version off the App, then both instances becomes healthy.

I've been investigating all the logs and I've found the problem bellow.. I don't know if this is what cause the problem but it's a problem...

So... Can somebody help me?

[2020-09-19T12:50:14.326Z] Sending signal 0 to CFN wait condition https://cloudformation-waitcondition-us-east-1.s3.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-east-1%3A932404652971%3Astack/awseb-e-38r7gqg8xp-stack/e972b630-f67f-11ea-8859-12bdd946785e/AWSEBInstanceLaunchWaitHandle?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20200914T114629Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86399&X-Amz-Credential=AKIAIIT3CWAIMJYUTISA%2F20200914%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=8853fd1d98a1d6e6d52c261fd42e85edf7834881bcc01e854f699cb1ba577170
Error signaling CloudFormation: [Errno 403] HTTP Error 403 :
AccessDeniedRequest has expired863992020-09-15T11:46:28Z2020-09-19T12:50:14Z974C16058757A26E8T4XS0mKn16PFeWnBbet5ChYS0saDtHeJng3VS0gR5JZ3KAAW0CggQcRVX53PGaenk5BROidV0o=
[2020-09-19T12:50:15.159Z] Wait Condition Signal expired.

Unable to chmod +x .platform/hooks/postdeploy/make_folders_writable.sh permission issue on windows

I am running chmod +x .platform/hooks/postdeploy/make_folders_writable.sh using gitbash on windows and then deploying but I am getting
2020/07/14 19:37:57.634916 [ERROR] An error occurred during execution of command [app-deploy] - [RunPostDeployHooks]. Stop running the command. Error: Command .platform/hooks/postdeploy/make_folders_writable.sh failed with error fork/exec .platform/hooks/postdeploy/make_folders_writable.sh: permission denied

Laravel.log permission issue

"var/app/current/storage/logs/laravel.log" could not be opened. failed to open stream: permission denied.

How can we solve this?

I added

13_permissions:
# fix permissions on the Laravel app folder
command: "chmod 777 -R /var/app/current/storage/logs/"
cwd: "/var/app/current/storage/logs/"

Line to deploy.config, but has no help.

composer not found in /opt/elasticbeanstalk/support

@rennokki First of thanks for this awesome repo. It saves lot of time!

I am using this configurations to deploy laravel on latest aws-elasticbeanstalk-amzn-2.0.20200430.64bit-eb_php74_amazon_linux_2-hvm-2020-05-05T21-06 AMI.

It fails to deploy & cfn-init-cmd.log says :

[INFO] -----------------------Command Output-----------------------
[INFO] 	Could not open input file: /opt/elasticbeanstalk/support/composer.phar
[INFO] ------------------------------------------------------------
[ERROR] Exited with error code 1

When I replace /opt/elasticbeanstalk/support by /user/bin, it works fine! Am I beating any purpose of having /opt/elasticbeanstalk/support in )1_deploy file or you need to update that part in repo?

Error on Deployment

When deploying it seems to go through all the steps (composer, npm... etc) then right at the end it fails with this in the logs (I've masked the eu-west-id)

----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2021/08/05 15:54:10.754600 [INFO] Starting executing the config set Infra-EmbeddedPostBuild.
2021/08/05 15:54:10.754615 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-west-2:0000000000000:stack/awseb-e-ah32j8un2u-stack/df62aa30-f5f5-11fb-99e9-02a866eae334 -r AWSEBAutoScalingGroup --region eu-west-2 --configsets Infra-EmbeddedPostBuild
2021/08/05 15:54:15.735201 [ERROR] An error occurred during execution of command [app-deploy] - [PostBuildEbExtension]. Stop running the command. Error: Container commands build failed. Please refer to /var/log/cfn-init.log for more details. 

2021/08/05 15:54:15.735227 [INFO] Executing cleanup logic
2021/08/05 15:54:15.735338 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1628178855,"severity":"ERROR"}]}]}

Anyone had a similar issue? Or know what the issue could be?

Thanks

Fix Permissions

You're currently setting 777 on the entire application directory, if DevOps see you they'll start crying ๐Ÿ˜ข

777 is global, and for what you need for this, setting 777 recursive on storage is enough, even though this is still deemed dangerous (in case someone uploads a script etc)

Sorry for randomly popping in on this, good job though.

Permission error on aws deploy

Hi I was trying to make use of your repo but can't seem to use it correctly I am getting a permission error on deploy

2020/05/23 01:48:58.813242 [INFO] Following platform hooks will be executed in order: [configure_php_ini.sh install_imagick.sh install_latest_node_js.sh install_memcached_discovery.sh install_supervisor.sh update_composer.sh]
2020/05/23 01:48:58.813249 [INFO] Running platform hook: .platform/hooks/prebuild/configure_php_ini.sh
2020/05/23 01:48:58.813440 [ERROR] An error occurred during execution of command [app-deploy] - [RunPreBuildHooks]. Stop running the command. Error: Command .platform/hooks/prebuild/configure_php_ini.sh failed with error fork/exec .platform/hooks/prebuild/configure_php_ini.sh: permission denied 

I made sure to run the commands:

$ chmod +x .platform/hooks/prebuild/*.sh

$ chmod +x .platform/hooks/predeploy/*.sh

$ chmod +x .platform/hooks/postdeploy/*.sh

And I am generating the zip running the following command

zip ../laravel-default.zip -r * .[^.]* -x "vendor/*" -x ".git/*"

From what I can see its because zips don't save permissions from chmod, got any ideas to overcome this? I am attaching the eb log, it seems like nothing gets run.

eb-engine.log

how to use .env-production and .env-development

This is brilliant and has solved many issues for us, thank you.

Now only stuck with how to use different .env files for master and development instances?

Maybe have different buckets for each environment? Which then requires using a variable in the script to know which env we are in?

Any advice gratefully received. :-)

Error when run eb deploy for the second time

First time laravel app deploys ok, but next time i ran eb deploy EB throws and error. When i check logs seems to be trying to exec the same scripts in .platform

How to avoid this ??

Thanks

composer memory limit?

getting that erorr.

I've added;

Set here your php.ini memory_limit value.

  • namespace: aws:elasticbeanstalk:container:php:phpini
    option_name: memory_limit
    value: 2048M

and added memory_limit=-1 to the php.ini

but nothing changed.
can not install composer. how to remove memory limit?

Fatal error: Out of memory (allocated 1766338560) (tried to allocate 134217736 bytes) in phar:///usr/local/composer.phar/src/Composer/DependencyResolver/RuleSet.php on line 84

2021/06/30 07:36:58.349348 [ERROR] An error occurred during execution of command [app-deploy] - [Install composer dependencies]. Stop running the command. Error: installing composer dependencies failed with error: Command /bin/sh -c composer.phar install --no-ansi --no-interaction  failed with error exit status 255. Stderr:Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Updating dependencies (including require-dev)

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 1766338560) (tried to allocate 134217736 bytes) in phar:///usr/local/composer.phar/src/Composer/DependencyResolver/RuleSet.php on line 84

Delete laravel.log file every now and often

Hi,
As I see in create_cron_files.sh, we have this:

# In some cases, Laravel logs a lot of data in the storage/logs/laravel.log and it sometimes
# might turn out into massive files that will restrict the filesystem.
# Uncomment the following lines to enable a CRON that deletes the laravel.log file
# every now and often.

# echo "0 0 * * */7 root rm -rf /var/app/current/storage/logs/laravel.log 1>> /dev/null 2>&1" \
#   | sudo tee /etc/cron.d/log_deleter

what is meant by 0 0 * * */7?

Run queues / caching in eb evironment

Hey rennokki thank you for the awesome package!

I wanna run queues/ caching in my eb environment.
What is the best way to do this?

Is this a good way to run queues as follows and use sqs as queue driver?

[program:laravel-sqs-queue]
process_name=%(program_name)s_%(process_num)02d
command=php /var/app/current/artisan queue:work sqs
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/dev/null

Or is there a way to install redis to the instance and use it for the above purpose?

Composer install run by EB

According to EB documentation, it seems that composer install is run automatically if a composer.json file is detected:

When a composer.json file is present, Elastic Beanstalk runs composer.phar install to install dependencies.

from https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-configuration-composer.html.

Indeed, if I look to eb-engine.log i see:

2021/06/07 17:27:38.644904 [INFO] Finished running the platform hooks in .platform/hooks/prebuild/
2021/06/07 17:27:38.644932 [INFO] Executing instruction: Install composer dependencies
2021/06/07 17:27:38.644947 [INFO] installing composer dependencies...
2021/06/07 17:27:38.645724 [INFO] Running command /bin/sh -c composer.phar install --no-ansi --no-interaction

That it's not the command sudo php -d memory_limit=-1 /usr/bin/composer.phar install --no-dev --no-interaction --prefer-dist --optimize-autoloader included in step 01_install_composer_dependencies in .ebextensions/01_deploy.config file.

Unfortunately I'm getting

Mon Jun  7 17:27:41 2021 (6549): Fatal Error Insufficient shared memory!
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 254

And I'm not able to raise the memory for the composer process.

Any idea?
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.