Download & Install
The fastest way to put anything on the internet.
TerraformInfrastructure
Add the ngrok provider to your Terraform configuration.
1terraform {2 required_providers {3 ngrok = {4 source = "ngrok/ngrok"5 version = ">= 0.8.1"6 }7 }8}9 10provider "ngrok" {}The provider authenticates with an ngrok API key. Sign up for a free account, then create a key in the dashboard.
export NGROK_API_KEY="<YOUR_NGROK_API_KEY>"Download the provider into your working directory.
terraform initReserve a domain and put a cloud endpoint online in front of it, with Traffic Policy attached.
1resource "ngrok_domain" "app" {2 domain = "app.example.com"3}4 5resource "ngrok_cloud_endpoint" "app" {6 url = "https://${ngrok_domain.app.domain}"7 8 traffic_policy = jsonencode({9 on_http_request = [{10 actions = [{11 type = "custom-response"12 config = { status_code = 200, content = "Hello from ngrok!" }13 }]14 }]15 })16}Create both resources. Your endpoint answers requests as soon as the apply finishes.
terraform applyThe provider manages domains, endpoints, IP policies, vaults, secrets, and IAM. Browse every resource and data source in the Terraform Registry.
You’re all set. What’s next?

