A simpler example might be if I have the following code that sets the env vars for both services in the Blueprint.
For example the env var is the source of an inline app:
services:
- name: my-staging-app
branch: staging
envVars:
- key: APP_DOMAIN
value: example.com
- name: my-production-app
branch: production
envVars:
- key: APP_DOMAIN
value: example.com
If the Blueprint is deployed to staging
and I want to change the domain to something else
Option 1:
- I update the Blueprint file changing my-staging-app envVars key to
something-else.com
- I also update the Blueprint file changing my-production-app envVars key to
something-else.com
also - I update some code ready for the new update
- I deploy to staging for testing
- staging env vars have been updated
- production env vars have been updated but the update to production is premature because I haven’t tested it yet, so potential for breakage if new domain and old code don’t align
- merge staging to production
- everything should now work as env vars and code align
Option 2:
- I update my-staging-app envVars key to
something-else.com
- I leave the my-production-app envVars as it was
- I update some code ready for the new update
- I deploy to staging for testing
- staging env vars have been updated and production env vars have not
- I test it on staging and all looks good
- merge staging to production, uh-oh, I can’t merge staging to production because the production service doesn’t have the correct env vars yet
So before merging I need to add another step:
- I update the Blueprint file again changing my-production-app envVars key to
something-else.com
- I deploy to staging
- staging env vars have not been updated, production env vars have been updated
- I then merge staging to master
- everything should now work as env vars and code align
This process would be better if:
- I update the Blueprint file changing my-staging-app envVars key to
something-else.com
- I also update the Blueprint file changing my-production-app envVars key to
something-else.com
also - I update some code ready for the new update
- I deploy to staging for testing and only staging code and staging environment settings are updated concurrently
- I merge to production
- Then production code and production environment settings are updated at the same time
I read and tested this Best practices for staging & prod environments, like a pipeline, using blueprints - #2 by anniesexton which is a similar problem but the two solutions seem to skirt around the issue of setting environment settings.