apirestenvironment-variablesbackendapigee

One Apigee Api Proxy with a different target endpoint for each environment


I am an Apigee beginner. We are doing a migration to Apigee.

We have our environments in our host names, for example:

something.int.other.thing.co.uk
something.test.other.thing.co.uk
something.stage.other.thing.co.uk
something.prod.other.thing.co.uk

I would like to be able to map them to the 4 environments of the apigee api proxy itself, respectively int, test, stage, prod.

I currently have one Rest resource for them, for example: /resource

Basically I would like the apigee api proxy with one rest resource, to map to 4 different target endpoints, depending on the environment.

So far I have tried to do it from the UI and have not been able to do so.

I have been going through the documentation and I have found these so far:

http://apigee.com/docs/api-services/content/api-proxy-configuration-reference

Create a New Endpoint on an existing API Proxy with "No Target Endpoint"

One API proxy calling two different target endpoints

I also tried doing something along the lines of this, for TargetEndpoint, where I tested for the environment name, but it didn't work:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <Description/>
    <Flows/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <HTTPTargetConnection>
        <URL>something.int.other.thing.co.uk</URL>
    </HTTPTargetConnection>
    <RouteRule name="int">
        <Condition>environment.name == "int"</Condition>
        <TargetEndpoint>something.int.other.thing.co.uk</TargetEndpoint>
    </RouteRule>
    <RouteRule name="test">
        <Condition>environment.name == "test"</Condition>
        <TargetEndpoint>something.test.other.thing.co.uk/</TargetEndpoint>
    </RouteRule>
    <RouteRule name="stage">
        <Condition>environment.name == "stage"</Condition>
        <TargetEndpoint>something.stage.other.thing.co.uk/</TargetEndpoint>
    </RouteRule>
    <RouteRule name="prod">
        <Condition>environment.name == "prod"</Condition>
        <TargetEndpoint>something.prod.other.thing.co.uk</TargetEndpoint>
    </RouteRule>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
</TargetEndpoint>

So is this possible?


Solution

  • Apigee supports the concept of Target Servers -which abstracts the backend host from the proxies and also provides load balancing. Same target servers can be configured to point to different host for each environment (this concept is built in to Apigee already).

    Take a look, this should help.

    Srikanth