Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Deploy Apigee API Proxy with same revision on different environments

I am trying to build a CI/CD pipeline to automate the deployment process of Apigee API Proxies, using the following deploy sample:
https://github.com/GoogleCloudPlatform/apigee-samples/tree/main/deploy-apigee-proxy
https://www.youtube.com/watch?v=8c0RozFEYhs

My issue is, if a proxy deployed on dev environment with revision number 7 for example, and I want to deploy the same proxy on a different environment like test, even if I don't change the code or configurations for the proxy in the folder /apiproxy, it will be deployed with revision 8 on test environment.

How can I deploy same revision on both environments or any other upper environments?

0 1 108
1 REPLY 1

You cannot.  Not really.   

The revision number that Apigee maintains is particular to an environment, and indicates the number of times you have deployed an API proxy by that name, in the environment. Suppose you have a proxy configuration and you deploy it for the first time to dev. The revision will be 1.  Then you deploy it 3 more times to dev, without changing anything. The revision will be 4.  Then you deploy it for the first time to test.  The revision number will be 1 in test.  It has the same configuration as r4 in dev.  Then suppose you modify the API proxy, and deploy it 3 more times in test. The revision number in test will be 4, but it will behave differently than r4 in dev, because you have changed the configuration. 

There is no correlation of revision numbers across Apigee environments. You should not use the revision number that is maintained by Apigee as a way to distinguish between proxy configurations. It's just a counter, and it's local to that environment. 

One way to establish some sort of correlation is, within your CI/CD, compute a hash of the configuration you upload, dynamically insert that into the Description of the API Proxy bundle, and then import THAT.  If you import and deploy that bundle numerous times, without modifying the configuration, always the shasum will be the same. If you modify anything in the proxy configuration, you will get a distinct sha256 checksum. 

HERE is an example bash script that does this: it computes the sha256 checksum, inserts that into the proxy bundle description, then imports and deploys the result.  

Top Solution Authors