I'm trying to deploy a project I've been working on with django. In development, i've been using SQLite, in production i'm trying to use MySQL.
Usually when I create the EB instance, everything runs fine, and the console says the status is OK. Upon trying to deploy (running eb deploy in ebcli), I get met with the following error
2020/06/18 15:59:50.357281 [INFO] Copying file /opt/elasticbeanstalk/config/private/rsyslog.conf to /etc/rsyslog.d/web.conf
2020/06/18 15:59:50.358945 [INFO] Running command /bin/sh -c systemctl restart rsyslog.service
2020/06/18 15:59:50.394223 [INFO] Executing instruction: PostBuildEbExtension
2020/06/18 15:59:50.394243 [INFO] No plugin in cfn metadata.
2020/06/18 15:59:50.394252 [INFO] Starting executing the config set Infra-EmbeddedPostBuild.
2020/06/18 15:59:50.394273 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-west-2:433403353655:stack/awseb-e-qamgvpp7ft-stack/3e6774d0-b17c-11ea-9476-0a5f6fd32d44 -r AWSEBAutoScalingGroup --region eu-west-2 --configsets Infra-EmbeddedPostBuild
2020/06/18 15:59:50.721919 [ERROR] Error occurred during build: Command 01_migrate failed
2020/06/18 15:59:50.721944 [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.
2020/06/18 15:59:50.721949 [INFO] Executing cleanup logic
2020/06/18 15:59:50.722079 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[]}]}
2020/06/18 15:59:50.722249 [INFO] Platform Engine finished execution on command: app-deploy
The culprit seems to be my db migration command, which is as follows, in '.ebextensions', named 'db-migrate.config'
container_commands:
01_migrate:
command: "django-admin.py migrate"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: djangomicroblog.settings
The original error message also points me to the log from '/var/log/cfn-init.log, error seen here is as follows
2020-06-18 14:18:23,279 [ERROR] -----------------------BUILD FAILED!------------------------
2020-06-18 14:18:23,279 [ERROR] Unhandled exception during build: Command 01_migrate 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 01_migrate failed
I've tried searching for these error messages, but the results are very limited & don't seem to work.
The function in my settings.py for setting the database is also as follows
def get_db():
try:
return {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['RDS_DB_NAME'],
'USER': os.environ['RDS_USERNAME'],
'PASSWORD': os.environ['RDS_PASSWORD'],
'HOST': os.environ['RDS_HOSTNAME'],
'PORT': os.environ['RDS_PORT'],
}
}
except:
return {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
DATABASES = get_db()
Any help would be greatly appreciated