App Engine: various environment-based app.yaml files

I am currently porting the application to Google App Engine, which uses environment variables for various external connections. It looks like the app.yaml file is where I have to configure these configurations, but how do I manage different environments (development, testing, formulation, production) where these variables can be different?

Is this the easiest solution to create a branch for each of these environments with just a different app.yaml file?

+9
source share
2 answers

app.yaml can set environment variables for the rest of the application, but it does not have the ability to check them and do different things depending on their input values. Thus, you need to submit various app.yaml files for any deployment procedure used.

As for the best way to prepare the right app.yaml as a preliminary step to deploying GAE, there is a problem with finer decompression. Branches in your git or hg, etc., as you mention, will work, but in person (maybe just a failure?). I often found that the simpler my structure, the better the branches intended for longevity (unlike temporary deviations, which should soon merge back into the trunk), gave me worse headaches.

So, it all depends on me, I would have a preapp.yaml template (maybe jinja2, whatever) with the necessary if / else logic and prepare the correct app.yaml from it, as the very first step of any deployment with a simple Python script.

A largely used architecture (for all types of configuration files, and therefore with more inevitable complications) for the gcloud preview deployment-manager beta, see https://cloud.google.com/deployment-manager/ , so of course , I could be biased towards the approach (but, as I mentioned, my bias is essentially due to previous failed deployment events :-).

+9
source

I need a solution for this that will work with the CD pipeline. I use build triggers in my git repositories. Using them, I can create a template for the name of the branch from which I run into my cloudbuild.yaml file. My first build step is to create app.yaml from a shell script using the branch_name value as a conditional value.

 # cloudbuild.yaml - name: 'ubuntu' args: ['bash', 'app.yaml.sh', '$BRANCH_NAME'] 
0
source

Source: https://habr.com/ru/post/1212452/


All Articles