Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use environment variables in yaml configuration file?

Dulce Hernandez Cruz June 10, 2020

I'm deploying my Laravel project on App Engine. I need to put some data like the password of the database in the app.yaml configuration file, I would like to do something like this when I have added $DB_PASSWORD in the environment variables of the Bitbucket repo.

runtime: php73
env_variables:

...

 DB_PASSWORD: $DB_PASSWORD 

 Is there any way to accomplish this?

1 answer

0 votes
manuelgeek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 11, 2020

Hi @Dulce Hernandez Cruz ,

I don't really think the `env` set in bitbucket can be read by the App Engine `app.yml`. I suggest you do the following

1. Bitbucket pipelines ships with an awesome feature, Bitbucket pipes, which makes most of deployments easy. The good news, there exists a bitbucket pipe for Google App Engine, See Link below;
https://confluence.atlassian.com/bitbucket/deploy-to-google-cloud-900820342.html

below is a snipe you can apply, do everything you need like building the app and `env` all in within the pipeline, so by the time it's sent to App Engine, the `env` already exists;

image: node:10.15.1
# image: php:7.2-fpm pipelines: default: - step: name: Build and Test script: - cp .env.example .env
# pass environment variables in travis to the app
- sed -ri 's~^DB_PASSWORD=~DB_PASSWORD=\$DB_PASSWORD~' .env - step: name: Deploy script: - pipe: atlassian/google-app-engine-deploy:0.2.1 variables: KEY_FILE: $KEY_FILE PROJECT: 'my-project'

 

2. You can maintain your config and I believe the `env` variables within `app.yml` should be defined in App Engine rather than bitbucket

I hope this helps 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events