0

I want to create .config files with option_settings depending on whether I am in a devevlopment or production environment. So far I have tried using condition, but it seems as though they are not allowed in option_settings.

I was thinking of using commands to run a script that will copy config files into .ebextensions folder. Here is the script in question:

#!/bin/bash

ENV_VAR = /opt/elasticbeanstalk/bin/get-config environment -k CURRENT_ENV

if [ "$ENV_VAR" == "prod" ]; then
  cp "../config/prod_config.yml" "../.ebextensions/prod_config.config";
  echo "prod"
else
  cp "../config/dev_config.yml" "../.ebextensions/dev_config.config";
  echo "dev"
fi

I am having trouble seeing the echos, and the ec2 instances are remaining default. Unsure if this is because I am not managing the files correctly or because this option is just not viable. Does anyone have recommendations or know if this approach could work?

2 Answers2

0

The ENV_VAR is set incorrectly. You have a space and do not execute command correctly. It should be:

ENV_VAR=$(/opt/elasticbeanstalk/bin/get-config environment -k CURRENT_ENV)
Marcin
  • 215,873
  • 14
  • 235
  • 294
0

The best solution I have found is to just run the script during the pipeline build.