What you're doing in this step
With Apigee now set up and your runtime instance in place, you can deploy a sample proxy. For this step, there are different processes for deploying and requesting the API proxy, depending on whether you chose internal or external access for your runtime in Step 7: Configure routing.
Perform the step
To deploy the example proxy:
(Optional) Set up a DNS entry for your host.
If you do not do this, then you have to send requests to an IP address instead of a friendly URL to hit your newly deployed API proxy.
To make accessing your proxy easier, try the following techniques:
- Add the IP and hostname to your hosts file.
- Define friendlier hostnames on your environment and then use Cloud DNS to map a URL to an IP address.
If you allowed external access to the API proxy:
- Open the Apigee provisioning wizard if it is not currently open. The wizard returns to the most recent incomplete task in the list.
In the Recommended next steps view, click Deploy API.
Apigee starts deploying a sample API proxy called "Hello World".
Wait three to four minutes.
The deployment process is asynchronous and, depending on the number of instances, it can take several minutes for the API proxy to be rolled out across the entire cluster.
You can check the status of the deployment using the Deployments API.
- After waiting a few minutes, or confirming that the deployment process is complete,
test the API proxy by sending the following request:
curl -i -H "Host: test-group.example.com" \ https://PUBLIC_FACING_IP/helloworld
- The value of the
Hostheader is the hostname that you defined on the environment group in Step 6: Create an environment.
- PUBLIC_FACING_IP is the IP address of the load balancer that acts as a gateway to your instance. You can get this value from the wizard.
Be sure to include the
-kswitch to instruct
curlto skip authentication in a testing scenario such as this. Without this option, you will get a security error.
- The value of the
- If you allowed internal access only to the API proxy, see Accessing a privately deployed API proxy.
The response to a successful request should look like the following:
HTTP/2 200 user-agent: curl/7.64.1 accept: */* x-cloud-trace-context: 64a52e6SAMPLE75647424242c981905e/13734264850044428201 x-forwarded-for: 188.8.131.52, 184.108.40.206,10.138.0.3 x-forwarded-proto: https x-request-id: 42454071-9080-4431-bef3-22918fd00ddb x-b3-traceid: 29SAMPLEe5c045ed860463c085fca x-b3-spanid: 5ed860463SAMPLE x-b3-sampled: 0 content-length: 11 access-control-allow-origin: * access-control-allow-headers: origin, x-requested-with, accept access-control-max-age: 3628800 access-control-allow-methods: GET, PUT, POST, DELETE content-type: text/plain date: Mon, 20 Jul 2020 18:53:38 GMT server: apigee via: 1.1 google, 1.1 google alt-svc: clear Hello world%
If your request is not successful, see Troubleshooting.
Note that in the procedures above:
If you set up your load balancer with DNS, then use the hostname instead of the IP address of the target machine. For example:
curl -i -H "Content-Type: application/json" "https://test-group.sandbox.apigeeks.net/helloworld"
If you sent an optional
PATCHrequest in Step 6: Create an environment, use "test-group-new.sandbox.apigeeks.net" for the value of
hostname(rather than "test-group").
curl -i -k -H "Host:test-group-new.sandbox.apigeeks.net" "https://PUBLIC_LOAD_BALANCER_IP/$PROXY_BASEPATH"
Accessing a privately deployed API proxy
This section describes how to access an API proxy that you deployed internally. (As compared to API proxies that are available externally, or from any machine on the internet.) You do this by creating another VM within your cluster and sending requests to the API proxy from the new VM.
To access an internally deployed API proxy:
Create a new virtual machine inside your VPC network. You can use Cloud Console or
gcloudto do this.
The new VM is the machine from which you send requests to the internal load balancer. That load balancer forwards your request to the newly deployed API proxy.
curlor another HTTP client on the new VM, if it isn't installed by default.
- Open a secure connection to the new VM that you just created. You can do this through Cloud Console or another SSH client.
- From the new VM, send a request to the API proxy using the following command:
curl -i -H "Content-Type: application/json" -H "Host: test-group.sandbox.apigeeks.net" https://INTERNAL_LOAD_BALANCER_IP/helloworld
If you encounter errors during this part of the process, see Troubleshooting.