Dynamically changing virtual host in the apiproxy default.xml file

dkumar
Participant I

Hi all,

I am stuck at one point and need help with that. We have environment-specific virtual hosts configured in Apigee. I have created CI/CD pipeline using Maven to deploy apiproxy bundle. How can we achieve virtual host name substitution on fly through maven configuration?

For example: In the maven run if I set DEV profile then it should pick dev specific virtual host name and replace the default virtual host with dev.org_name.com. Similary, if I select QA profile then it should set qa.org_name.com on the fly.

Requirement is exactly similar to this:

https://community.apigee.com/questions/29030/virtual-host-configuration-by-environment.html

But I am trying to achieve it through CI/CD using Maven.

Thank you

Regards,

Dwiz

1 1 316
1 REPLY 1

@Dwiz Kumar - Before giving a solution to your use case. Would like to clarify that you are not using the virtual host the way it is meant to be. You should use the same Virtual host name in each environment and point that to its appropriate URL. For example, create a virtual host called "https" with URL as api-dev.acme.com in the dev environment. Similarly create a virtual host called "https" with URLas api-qa.acme.com in the qa environment.

So in your actual API proxy you just need to have <VirtualHost>https</VirtualHost>. Depending on which environment you are deploying to, the appropriate Virtualhost config will get picked.

This is how it needs to be. The advantage with these are:

1) These are env configurations and easy to manage

2) No code change between environments. You are not pushing different codes to different environments, its just different config values that these proxies use at runtime

I would recommend you change your Virtual host config to use the same name but different values. Hope this clarifies.

If you implement this, then you will not see the issue you have raised. If you still need to do what you have asked, I can provide a solution but that is not recommended.