9

I have 2 separate environments to manage my application, a primary env, webserver with a load balancer, and a secondary env, a single small tier worker to run crons.

My .ebextensions contains a lot of Instance and load balancer configurations, example:

01amazon.config

Resources:
  # LB SG
  AWSEBLoadBalancerSecurityGroup:
    Type: "AWS::EC2::SecurityGroup"
    Properties:
....

Is there any way to ignore this single file when i deploy to my worker instance via eb deploy worker-env

If the file is not ignored, it causes an error, due to the worker not having a load balancer.

PaulG
  • 13,871
  • 9
  • 56
  • 78
  • 1
    Possible duplicate of [Elastic Beanstalk: How would I run an ebextension command on the worker tier only?](http://stackoverflow.com/questions/28425360/elastic-beanstalk-how-would-i-run-an-ebextension-command-on-the-worker-tier-onl) – Brian Mar 16 '17 at 14:40
  • Does not work for non-container commands. –  Mar 16 '17 at 15:20
  • Unfortunately, that's the only way (that I'm aware of at least) to apply configurations in an environment-specific manner. – Brian Mar 16 '17 at 16:44
  • what i do is run a gulp command to copy all the ebextension files depending on the enviroment args passed to it – astroanu Apr 04 '17 at 04:08
  • 2
    Did you find a solution? I have a similar problem with SSL certificates that can not be deployed on a worker. – qdequippe Jun 29 '19 at 07:40

1 Answers1

1

As astroanu is writing in above comment, one way is to make a version depending on your environment. Following is an extract from my Makefile using eb create with custom-$(ENV_TYPE).config file depending on the environment. The same kind of parameters should be possible with eb deploy.

    git archive -v -o $(ZIP) --format=zip HEAD
    zip $(ZIP) .ebextensions/custom-$(ENV_TYPE).config
    aws s3 cp "$(ZIP)" "s3://$(BUCKET)/$(APP_NAME)/$(VERSION).zip"
    aws elasticbeanstalk create-application-version --application-name "$(APP_NAME)" --version-label "$(VERSION)" --description '$(DESCRIPTION)' --source-bundle "S3Bucket=$(BUCKET),S3Key=$(APP_NAME)/$(VERSION).zip"
    eb create --process --version "$(VERSION)" --branch_default --instance-types "$(INSTANCE_TYPES)" --cname "$(CNAME)"
pba
  • 700
  • 8
  • 18