0

Inside my .zip source boudle I have:

  • templates/
  • application.py
  • serviceKey.json
  • requirements.txt

It runs locally in my machine with the following code, but when I deploy it in AWS elastic beanstalk it doesn't work.

from flask import Flask, request, jsonify, render_template
import firebase_admin
from firebase_admin import credentials, db

application = app = Flask(__name__)

cred = credentials.Certificate('./serviceKey.json') 
default_app = firebase_admin.initialize_app(cred, {"databaseURL": "<URL_to_my_firebasedb>"})
rensc
  • 1
  • 2
  • What do you mean by "doesn't work". Do you get any errors or some other logs? – Hiranya Jayathilaka May 12 '20 at 18:27
  • Hi @HiranyaJayathilaka. I get an environment health status of **"Degraded"** and in causes it says: "Application deployment failed at 2020-05-12T05:03:20Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed". Also if I go to the URL of the application, the page shows **"Index of/"** – rensc May 12 '20 at 20:43
  • Looks like a deployment problem at the AWS end. The code looks fine, and I'd expect it to work in any environment. – Hiranya Jayathilaka May 13 '20 at 01:17

1 Answers1

0

Ok my code was right, my problem had something to do with an invalid requirements.txt error that says: requirements.txt returned non-zero exit status 1.

My solution of my problem was to create other .zip source boundle that does not include the requirements.txt but the venv foler that I had in my local computer.

So the new .zip source boudle looks like this:

  • templates/
  • venv/
  • application.py
  • serviceKey.json

I get it from this answer. https://stackoverflow.com/a/43967554/13450998

rensc
  • 1
  • 2