Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Environment-specific ebextensions on Elastic Beanstalk

I deploy the same application to two different environments app-web and app-worker. The configuration of these environments differs slightly (e.g. they run different processes) so some different .ebextensions will be required for each. Is there a way to specify that a certain config file should only be run for a certain environment?

Here's the config file that needs to be set for the worker environment only:

packages:
  yum:
    monit: []

files:
  "/etc/monit.d/resque_worker":
    mode: "000644"
    owner: root
    group: root
    content: |
      check process resque_worker_QUEUE
        with pidfile /var/app/resque_worker_QUEUE.pid
        start program = "/bin/sh -l -c 'cd /var/app/current; nohup rake environment resque:work QUEUE=* VERBOSE=1 PIDFILE=/var/app/resque_worker_QUEUE.pid >> log/resque_worker_QUEUE.log 2>&1'" as uid webapp and gid webapp
        stop program = "/bin/sh -c 'cd /var/app/current && kill -9 $(cat tmp/pids/resque_worker_QUEUE.pid) && rm -f /var/app/resque_worker_QUEUE.pid; exit 0;'"
        if totalmem is greater than 300 MB for 10 cycles then restart  # eating up memory?
        group resque_workers

commands:
  remove_bak:
    command: "rm /etc/monit.d/resque_worker.bak"
    ignoreErrors: true

service:
  sysvinit:
    monit:
      ensureRunning: true
      enabled: true

I know I can test for the presence of an environmental variable to stop commands from running with the commands/test, but I'm not sure what to do with the rest.

like image 608
fny Avatar asked May 10 '15 12:05

fny


People also ask

How do I set environment variables in Elastic Beanstalk?

Elastic Beanstalk lets you enter the environment variables for each environment using the management panel. On AWS, open Elastic Beanstalk. Go to your Application > Environment > Configuration > Software Configuration . Under Environment Properties you will find a list of properties you can configure.

What two types of environments can be created when using Elastic Beanstalk?

In AWS Elastic Beanstalk, you can create a load-balanced, scalable environment or a single-instance environment. The type of environment that you require depends on the application that you deploy.

What is the worker environment used for in Elastic Beanstalk?

Worker environments run a daemon process provided by Elastic Beanstalk. This daemon is updated regularly to add features and fix bugs. To get the latest version of the daemon, update to the latest platform version.


1 Answers

So as far as I can tell, there's no way to do this at this time, which is pretty obnoxious... I ended up writing a script which conditionally enables worker extensions for deploys.

Basically during a worker deploy, the script enables certain files by changing the extension from worker-config to config, create a temporary commit, deploy, then reset the commit.

like image 102
fny Avatar answered Oct 06 '22 21:10

fny