user1207727
user1207727

Reputation: 1553

How to specify different file contents for different environments in elastic beanstalk?

Creating files on the server(s) by using config files in .ebextensions is awesome, ie

files:
  "/home/ec2-user/myfile" :
    mode: "000777"
    owner: ec2-user
    group: ec2-user
    source: http://foo.bar/myfile

However, is there a mechanism to create different files for different environments?

My specific need is to provide a different elasticsearch config file for dev, staging & production.

Is the only answer to use commands in .ebextentions? If so is there a way to find out which environment I'm in when running the command?

Upvotes: 1

Views: 176

Answers (1)

Ja͢ck
Ja͢ck

Reputation: 173552

You can manually specify the environment name using the custom environment properties, e.g. use PARAM1 to specify dev, staging or production (you can use your own keys as well.

To use those variables you need to use them inside the container_commands:

container_commands:
  download-config:
    command: wget http://foo.bar/{$PARAM1}/config.ini

Upvotes: 2

Related Questions