jeudi 2 avril 2015

Accessing environment variables in AWS Beanstalk ebextensions

I am trying to access an environment variable that I have defined in the AWS Beanstalk configuration. I need to access it within a config file in .ebextensions or in a file that is copied in place in a config file. I have tried the following:



container_commands:
update_nginx_config:
command: "cp .ebextensions/files/nginx/nginx.conf /etc/nginx/nginx.conf"


And in my nginx.conf file, I have tried to access $MYVAR, ${MYVAR} and {$MYVAR}, some of which was suggested here and here (the latter being directly within a config file).



files:
"/etc/nginx/nginx.conf" :
mode: "000644"
owner: root
group: root
content: |
$MYVAR ${MYVAR} {$MYVAR}


This does not work either. In all cases, the variable names are just output such as $MYVAR, so Beanstalk does not recognize my variables. I found the below in the AWS documentation about container_commands:



They also have access to environment variables such as your AWS security credentials.



This is great, but it does not say how.


How can I access an environment variable with ebextensions, be it within a config file itself or in a separate file that is copied in place?


Thank you in advance!





Aucun commentaire:

Enregistrer un commentaire