I would like to templatize the target url, so that the same proxy could be promoted from staging to production, and if the environment configuration KVM was set correctly, the proxy targets would be correct. I could not find the correct syntax for accessing the values of the KVMs.
Here's what I tried:
<TargetEndpoint> ... <HTTPTargetConnection> <Properties/> <URL>https://{environment}-info-data.google.com/resource</URL> </HTTPTargetConnection> </TargetEndpoint>
My KVM was called 'target_env', with a key of 'environment' and a value of 'staging' or 'production'.
In staging environment, traffic would hit
https://staging-info-data.google.com/resource
In production environment, traffic would hit:
https://production-info-data.google.com/resource
Solved! Go to Solution.
Hi @jasonbrown
I think you should use TargetServer for this use case. You can configure TargetServer with the same name for each environment. Use this API to configure
For staging env, the payload for Target server will be:
<TargetServer name="target1"> <Host>staging-info-data.google.com</Host> <Port>443</Port> <IsEnabled>true</IsEnabled> <SSLInfo> <Enabled>true</Enabled> </SSLInfo> </TargetServer>
For prod env:
<TargetServer name="target1"> <Host>production-info-data.google.com</Host> <Port>443</Port> <IsEnabled>true</IsEnabled> <SSLInfo> <Enabled>true</Enabled> </SSLInfo> </TargetServer>
NOTE : Make sure in your Mgmt API URL, you provide the correct environment
https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/targetservers
You should be able to see them in the Environment Configuration tab on the UI as well once its done.
After the configuration is all set, you can just configure your TargetEndpoint in proxy as
<HTTPTargetConnection> <LoadBalancer> <Server name="target1"/> </LoadBalancer> <Path>/resource</Path> </HTTPTargetConnection>
Depending on which environment you are calling from, it picks the corresponding Target server configuration. With this its more configuration driven as well.