Troubleshooting Deploying a Django Application With Elastic Beanstalk
Overview
An ongoing list of issues, with solutions as they are found, that I have encountered while deploying a Django web application using Elastic Beanstalk.
"No environment found" error with aws eb cli
Use case
Almost all eb commands result in an error the effect of No Environment found for EnvironmentName = 'name-ev'.
Cause
An EB environment was created, but then not deleted entirely.
Fix
Delete the environment through the AWS console, and then delete the .elasticbeanstalk/ and .ebextensions/ directories.
Zip file errors while installing a custom Django module
Use case
pip install path/to/my-custom-package.0.1.zip results in error: BadZipFile: File is not a zip file.
Cause
This happened after using wget to retrieve a .zip archive off GitHub.
Despite the .zip extension, the file type can register as HTML on Linux.
Fix
Test the file type:
$ file myzipfile.zip myzipfile.zip: HTML document, UTF-8 Unicode txt, with very long lines
Upload the zip file to the server using scp:
`scp -i path/to/namekey_pair.pem path/to/source.zip ec2-user@public_dns.us-west-2.compute.amazonaws.com:path/to/dest.zip`
(Where namekey_pair.pem is the actual name of a .pem file, and public_dns is the actual address of the public dns from the EC2 console.)