1 Answer
- Newest
- Most votes
- Most comments
0
OK. You want to start gunicorn with environment variable SECRET_KEY stored in AWS Parameter Store. If you can customize service file, write service shell file and change service file.
Service shell file(For example, locate at /opt/bin/django.sh. Do not forget to set execute permission.)
#!/bin/bash
export SECRET_KEY=`aws ssm get-parameter --name [parameter name] | jq -r '.Parameter.Value'`
/path/to/project/bin/gunicorn --access-logfile - --workers 3 --bind unix:/var/run/gunicorn.sock site_mod.wsgi
Service file(For example, locate at /etc/systemd/system/django.service)
[Unit]
Description=gunicorn daemon
Requires=gunicorn.sock
After=network.target
[Service]
User=service-user
Group=service-group
WorkingDirectory=/path/to/project
ExecStart=/opt/bin/django.sh
[Install]
WantedBy=multi-user.target
I run this service, and it can run. I do not test on CodeDeploy, but this solution would help you.
answered 13 days ago
Relevant content
- asked a year ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 9 months ago