Getting Started with Cloud Endpoints and Traffic Policy via API
What you'll need
- An ngrok account.
- The ngrok Agent CLI installed.
- Your ngrok API key.
- A reserved domain.
1. Add your API key to the Agent
Create an API key on your ngrok dashboard and then run the following in your terminal:
Loading…
2. Create your Traffic Policy file
Create a file named policy.yml
with the following contents:
Loading…
This will be the used on your Cloud Endpoint to respond to each HTTP request with a simple “Hello, World!” message.
3. Create your Cloud Endpoint via the API
Create your Cloud Endpoint via the API by running the following in your terminal (make sure to replace <your-reserve-domain>
with your reserved domain):
Loading…
4. Test it out
Once you have created your Cloud Endpoint you can now open the URL in your web browser. You should see the "Hello, World!" message displayed in your browser.
What's next?
You've now successfully set up your first Cloud Endpoint with a custom Traffic Policy via the API.
To learn more about ngrok's Traffic Policy and its capabilities, check out the following resources:
- Learn about the core concepts like phases and rules.
- Check out the examples, use-cases and guides.
- The list of available actions, macros and variables you can use.