Question

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:

  • According to this it should be possible: "An API proxy can contain zero or more TargetEndpoints." (TargetEndpoint section)

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

  • According to these, you can make routerules to the proxy endpoint, but I have not been able to implement it to the targetendpoint:

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?

Was it helpful?

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

OTHER TIPS

LoadBalancer and TargetServer settings go in the TargetEndpoint definition, specifically in the HTTPTargetConnection element.

Check the example here:

http://apigee.com/docs/api-services/content/load-balancing-across-backend-servers

If you do want to curl a TargetEndpoint definition to your API proxy, have a look at the following sample script to see working API calls:

https://github.com/apigee/api-platform-samples/blob/master/tools/proxy_gen.sh

This script shows you how to create an API proxy and update ProxyEndpoint and TargetEndpoints via API calls.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top