Cannot deploy Flask application with Elastic Beanstalk

0

I have a simple use case. I want to deploy my Flask application with Elastic Beanstalk, however after trying for multiple hours I cannot seem to make it happen.

My application is pretty standard: -I have "app.py" file with my python code where I only have to import "flask" and "sqlite". -I have "templates" folder with my .HTML files and "static" folder with my .CSS and .PNG files. -I have an "expenses.db" and "users.db" databases with less than 50KB of data in both combined.

My application works when I run the "python app.py" command in CMD through my virtual environment.

My requirements.txt only includes the basic libraries: blinker==1.6.2 click==8.1.3 colorama==0.4.6 Flask==2.3.2 itsdangerous==2.1.2 Jinja2==3.1.2 MarkupSafe==2.1.2 Werkzeug==2.3.4

Unfortunately it is my first time using AWS, but after a few hours I managed to successfully set up the environment, however I now cannot deploy my application, and I am guessing it is a pretty standard use case.

The EVENTS say: May 26, 2023 15:25:44 (UTC+2) INFO The environment was reverted to the previous configuration setting. May 26, 2023 15:25:26 (UTC+2) 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. May 26, 2023 15:25:26 (UTC+2) ERROR Failed to deploy application. May 26, 2023 15:25:26 (UTC+2) ERROR Unsuccessful command execution on instance id(s) 'i-0dcd82ee6b813bdf4'. Aborting the operation. May 26, 2023 15:25:26 (UTC+2) INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. May 26, 2023 15:25:26 (UTC+2) ERROR [Instance: i-0dcd82ee6b813bdf4] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. May 26, 2023 15:25:23 (UTC+2) ERROR Instance deployment failed. For details, see 'eb-engine.log'. May 26, 2023 15:25:23 (UTC+2) ERROR Instance deployment: Your source bundle has issues that caused the deployment to fail. For details, see 'eb-engine.log'. May 26, 2023 15:25:19 (UTC+2) INFO Deploying new version to instance(s). May 26, 2023 15:24:45 (UTC+2) INFO Updating environment IU-Appl-env-1's configuration settings. May 26, 2023 15:24:36 (UTC+2) INFO Environment update is starting. May 26, 2023 15:18:25 (UTC+2) INFO Deleted log fragments for this environment.

and my "cb-engine.log" sayss 2023/05/26 12:17:56.699238 [INFO] Starting... 2023/05/26 12:17:56.699296 [INFO] Starting EBPlatform-PlatformEngine 2023/05/26 12:17:56.699372 [INFO] reading event message file 2023/05/26 12:17:56.699551 [INFO] Engine received EB command userdata-exec

2023/05/26 12:17:56.709787 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBAutoScalingGroup --region eu-central-1 2023/05/26 12:17:57.441546 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBBeanstalkMetadata --region eu-central-1 2023/05/26 12:17:58.300973 [INFO] This is a workflow controlled instance. 2023/05/26 12:17:58.301072 [INFO] Engine command: (env-launch)

2023/05/26 12:17:58.301211 [INFO] Executing instruction: SyncClock 2023/05/26 12:17:58.301215 [INFO] Starting SyncClock 2023/05/26 12:17:58.301230 [INFO] Running command /bin/sh -c /usr/bin/chronyc tracking 2023/05/26 12:17:58.308629 [INFO] Reference ID : 00000000 () Stratum : 0 Ref time (UTC) : Thu Jan 01 00:00:00 1970 System time : 0.000000000 seconds fast of NTP time Last offset : +0.000000000 seconds RMS offset : 0.000000000 seconds Frequency : 31.829 ppm fast Residual freq : +0.000 ppm Skew : 0.000 ppm Root delay : 1.000000000 seconds Root dispersion : 1.000000000 seconds Update interval : 0.0 seconds Leap status : Not synchronised

2023/05/26 12:17:58.308661 [INFO] Running command /bin/sh -c /usr/bin/chronyc -a makestep 2023/05/26 12:17:58.315713 [INFO] 200 OK

2023/05/26 12:17:58.315794 [INFO] Skipping Configure OS 2023/05/26 12:17:58.315802 [INFO] Skipping LockRepo 2023/05/26 12:17:58.315808 [INFO] Skipping GenerateEBBanner 2023/05/26 12:17:58.315815 [INFO] Skipping Install Process Manager 2023/05/26 12:17:58.315821 [INFO] Skipping install syslog 2023/05/26 12:17:58.315826 [INFO] Skipping install cron 2023/05/26 12:17:58.315831 [INFO] Skipping install proxy 2023/05/26 12:17:58.315837 [INFO] Skipping installhealthd 2023/05/26 12:17:58.315842 [INFO] Skipping Install Log Streaming Manager 2023/05/26 12:17:58.315847 [INFO] Skipping install X-Ray 2023/05/26 12:17:58.315852 [INFO] Skipping install Third Party License 2023/05/26 12:17:58.315857 [INFO] Skipping install httpd 2023/05/26 12:17:58.315865 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:17:58.315869 [INFO] Executing instruction: installSqsd 2023/05/26 12:17:58.315873 [INFO] This is a web server environment instance, skip install sqsd daemon ... 2023/05/26 12:17:58.315878 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:17:58.315882 [INFO] Executing instruction: bootstraphealthd 2023/05/26 12:17:58.315886 [INFO] this is a basic health env, skip bootstrap healthd instruction... 2023/05/26 12:17:58.315890 [INFO] Executing instruction: GetSetupProxyLog 2023/05/26 12:17:58.316034 [INFO] Skipping Install yum packages 2023/05/26 12:17:58.316041 [INFO] Skipping Configure Python site-packages 2023/05/26 12:17:58.316047 [INFO] Skipping Install Python Modules 2023/05/26 12:17:58.316052 [INFO] Skipping MarkBaked 2023/05/26 12:17:58.316058 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:17:58.316062 [INFO] Executing instruction: TuneSystemSettings 2023/05/26 12:17:58.316065 [INFO] Starting TuneSystemSettings 2023/05/26 12:17:58.316070 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:17:58.316998 [INFO] Executing instruction: GetSetupLogRotate 2023/05/26 12:17:58.317003 [INFO] Initialize LogRotate files and directories 2023/05/26 12:17:58.328678 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:17:58.328691 [INFO] Executing instruction: BootstrapCFNHup 2023/05/26 12:17:58.328694 [INFO] Bootstrap cfn-hup 2023/05/26 12:17:58.329979 [INFO] Copying file /opt/elasticbeanstalk/config/private/aws-eb-command-handler.conf to /etc/cfn/hooks.d/aws-eb-command-handler.conf 2023/05/26 12:17:58.331277 [INFO] Executing instruction: StartCFNHup 2023/05/26 12:17:58.331290 [INFO] Start cfn-hup 2023/05/26 12:17:58.331318 [INFO] Running command /bin/sh -c systemctl show -p PartOf cfn-hup.service 2023/05/26 12:17:58.354167 [INFO] cfn-hup is not registered with EB yet, registering it now 2023/05/26 12:17:58.354216 [INFO] Running command /bin/sh -c systemctl show -p PartOf cfn-hup.service 2023/05/26 12:17:58.385914 [INFO] Running command /bin/sh -c systemctl daemon-reload 2023/05/26 12:17:58.918397 [INFO] Running command /bin/sh -c systemctl reset-failed 2023/05/26 12:17:58.940875 [INFO] Running command /bin/sh -c systemctl is-enabled aws-eb.target 2023/05/26 12:17:58.952586 [INFO] Running command /bin/sh -c systemctl enable aws-eb.target 2023/05/26 12:17:59.483576 [INFO] Running command /bin/sh -c systemctl start aws-eb.target 2023/05/26 12:17:59.496835 [INFO] Running command /bin/sh -c systemctl enable cfn-hup.service 2023/05/26 12:18:00.006690 [INFO] Synchronizing state of cfn-hup.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable cfn-hup Created symlink /etc/systemd/system/multi-user.target.wants/cfn-hup.service → /etc/systemd/system/cfn-hup.service.

2023/05/26 12:18:00.006724 [INFO] Running command /bin/sh -c systemctl is-active cfn-hup.service 2023/05/26 12:18:00.018338 [INFO] cfn-hup process is not running, starting it now 2023/05/26 12:18:00.018367 [INFO] Running command /bin/sh -c systemctl show -p PartOf cfn-hup.service 2023/05/26 12:18:00.038791 [INFO] Running command /bin/sh -c systemctl is-active cfn-hup.service 2023/05/26 12:18:00.056752 [INFO] Running command /bin/sh -c systemctl start cfn-hup.service 2023/05/26 12:18:00.123535 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:18:00.123559 [INFO] Executing instruction: SetupPublishLogCronjob 2023/05/26 12:18:00.123564 [INFO] Setup publish logs cron job... 2023/05/26 12:18:00.123569 [INFO] Copying file /opt/elasticbeanstalk/config/private/logtasks/cron/publishlogs to /etc/cron.d/publishlogs 2023/05/26 12:18:00.125438 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:18:00.125453 [INFO] Executing instruction: MarkBootstrapped 2023/05/26 12:18:00.125458 [INFO] Starting MarkBootstrapped 2023/05/26 12:18:00.125463 [INFO] Instance has NOT been bootstrapped 2023/05/26 12:18:00.125581 [INFO] Marked instance as Bootstrapped 2023/05/26 12:18:00.125588 [INFO] Executing instruction: Save CFN Stack Info 2023/05/26 12:18:00.125648 [INFO] Starting SwitchCFNStack 2023/05/26 12:18:00.125653 [INFO] Executing cleanup logic 2023/05/26 12:18:00.125662 [INFO] Platform Engine finished execution on command: env-launch

2023/05/26 12:18:26.492401 [INFO] Starting... 2023/05/26 12:18:26.492449 [INFO] Starting EBPlatform-PlatformEngine 2023/05/26 12:18:26.492468 [INFO] reading event message file 2023/05/26 12:18:26.492707 [INFO] Engine received EB command cfn-hup-exec

2023/05/26 12:18:26.636618 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBAutoScalingGroup --region eu-central-1 2023/05/26 12:18:27.081083 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBBeanstalkMetadata --region eu-central-1 2023/05/26 12:18:27.585979 [INFO] checking whether command app-deploy is applicable to this instance... 2023/05/26 12:18:27.585990 [INFO] this command is applicable to the instance, thus instance should execute command 2023/05/26 12:18:27.585993 [INFO] Engine command: (app-deploy)

2023/05/26 12:18:27.585997 [INFO] Downloading EB Application... 2023/05/26 12:18:27.585999 [INFO] Region: eu-central-1 2023/05/26 12:18:27.586001 [INFO] envID: e-rr9c3sfmup 2023/05/26 12:18:27.586004 [INFO] envBucket: elasticbeanstalk-eu-central-1-159258688165 2023/05/26 12:18:27.586006 [INFO] Using manifest file name from command request 2023/05/26 12:18:27.586012 [INFO] Unable to get version manifest file. 2023/05/26 12:18:27.586020 [INFO] Downloading latest manifest available. 2023/05/26 12:18:27.586024 [INFO] Download latest app version manifest 2023/05/26 12:18:27.586121 [INFO] resources/environments/e-rr9c3sfmup/_runtime/versions/manifest 2023/05/26 12:18:27.634805 [INFO] latestManifest key *: resources/environments/e-rr9c3sfmup/_runtime/versions/manifest_1685103406248

2023/05/26 12:18:27.635009 [INFO] Downloading: bucket: elasticbeanstalk-eu-central-1-159258688165, object: /resources/environments/e-rr9c3sfmup/_runtime/versions/manifest_1685103406248 2023/05/26 12:18:27.652050 [INFO] Download successful100bytes downloaded 2023/05/26 12:18:27.652139 [INFO] Trying to read and parse version manifest... 2023/05/26 12:18:27.652476 [INFO] Downloading: bucket: elasticbeanstalk-eu-central-1-159258688165, object: /resources/environments/e-rr9c3sfmup/_runtime/_versions/IU-Appl/4.0 2023/05/26 12:18:27.727270 [INFO] Download successful1636869bytes downloaded 2023/05/26 12:18:27.727384 [INFO] Executing instruction: ElectLeader 2023/05/26 12:18:27.727390 [INFO] Running leader election for instance i-0dcd82ee6b813bdf4... 2023/05/26 12:18:27.727392 [INFO] Calling the cfn-elect-cmd-leader to elect the command leader. 2023/05/26 12:18:27.727405 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-elect-cmd-leader --stack arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a --command-name ElasticBeanstalkCommand-AWSEBAutoScalingGroup --invocation-id 81fc8159-b362-4ef0-b1fe-ae448bfa9802 --listener-id i-0dcd82ee6b813bdf4 --region eu-central-1 2023/05/26 12:18:28.085028 [INFO] Instance is Leader. 2023/05/26 12:18:28.085080 [INFO] Executing instruction: stopSqsd 2023/05/26 12:18:28.085086 [INFO] This is a web server environment instance, skip stop sqsd daemon ... 2023/05/26 12:18:28.085089 [INFO] Executing instruction: PreBuildEbExtension 2023/05/26 12:18:28.085093 [INFO] Starting executing the config set Infra-EmbeddedPreBuild. 2023/05/26 12:18:28.085114 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBAutoScalingGroup --region eu-central-1 --configsets Infra-EmbeddedPreBuild 2023/05/26 12:18:28.577001 [INFO] Finished executing the config set Infra-EmbeddedPreBuild.

2023/05/26 12:18:28.577038 [INFO] Executing instruction: StageApplication 2023/05/26 12:18:28.577570 [ERROR] An error occurred during execution of command [app-deploy] - [StageApplication]. Stop running the command. Error: staging application failed due to invalid zip file

2023/05/26 12:18:28.577576 [INFO] Executing cleanup logic 2023/05/26 12:18:28.577664 [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: Your source bundle has issues that caused the deployment to fail. For details, see 'eb-engine.log'.","timestamp":1685103508577,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1685103508577,"severity":"ERROR"}]}]}

2023/05/26 12:18:28.577680 [INFO] Platform Engine finished execution on command: app-deploy

2023/05/26 12:20:37.766827 [INFO] Starting... 2023/05/26 12:20:37.766955 [INFO] Starting EBPlatform-PlatformEngine 2023/05/26 12:20:37.766976 [INFO] reading event message file 2023/05/26 12:20:37.767162 [INFO] Engine received EB command cfn-hup-exec

2023/05/26 12:20:37.873560 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBAutoScalingGroup --region eu-central-1 2023/05/26 12:20:38.417209 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-central-1:159258688165:stack/awseb-e-rr9c3sfmup-stack/2f3744f0-fbbf-11ed-8d54-064cd1f3cb1a -r AWSEBBeanstalkMetadata --region eu-central-1 2023/05/26 12:20:38.807697 [INFO] checking whether command bundle-log is applicable to this instance... 2023/05/26 12:20:38.807711 [INFO] this command is applicable to the instance, thus instance should execute command 2023/05/26 12:20:38.807714 [INFO] Engine comman

gefragt vor einem Jahr112 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen