I have two Environments at AWS Elastic Beanstalk
: Development
and Production
.
I would like that .ebextensions/app.config
only run on Production
environment.
Theres any way to do that?
app.config:
container_commands:
01-command:
command: "crontab .ebextensions/cronjob"
leader_only: true
According to TNICHOLS
idea I found a solution:
Change the environment PARAM1
variable value to MyAppEnv-Production
(or what you want).
app.config:
container_commands:
command-01:
command: "/bin/bash .ebextensions/crontab.sh"
leader_only: true
crontab.sh:
if [ "$PARAM1" == "MyAppEnv-Production" ]; then
crontab -l > /tmp/cronjob
#CRONJOB RULES
echo "00 00 * * * /usr/bin/wget http://localhost/cronexecute > /dev/null 2>&1" >> /tmp/cronjob
crontab /tmp/cronjob
rm /tmp/cronjob
echo 'Script successful executed, crontab updated.'
else
echo 'This script is only executed in the production environment.'
fi
I don't think there's a simple way to do it in the way you're thinking. You could have the config file run and execute a second script (perhaps cron.sh). Inside cron.sh you can check the environment name and then add the cronjobs accordingly. Haven't tested it, but I think that should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With