The QuickNode Terraform provider allows you to manage QuickNode blockchain infrastructure resources using Terraform.
terraform {
required_providers {
quicknode = {
source = "asyrafnorafandi/quicknode"
}
}
}
provider "quicknode" {
# Can also be set with the QUICKNODE_API_KEY environment variable
api_key = var.quicknode_api_key
}
resource "quicknode_endpoint" "example" {
chain = "optimism"
network = "optimism-sepolia"
label = "optimisim-sepolia-test-chain"
security_options = {
tokens = true
referrers = false
jwts = false
ips = true
domain_masks = true
hsts = false
cors = true
request_filters = true
}
tags = ["env:staging", "chain:optimism"]
}
# Whitelist specific IPs for the endpoint
locals {
whitelisted_ips = [
"10.20.10.0/24",
"10.20.11.0/24",
]
}
resource "quicknode_endpoint_whitelist_ip" "example" {
for_each = toset(local.whitelisted_ips)
ip = each.value
endpoint_id = quicknode_endpoint.example.id
}
# Whitelist specific domain masks for the endpoint
locals {
whitelisted_domains = [
"rpc.example.com",
"rpc.op-sepolia.example.com",
]
}
resource "quicknode_endpoint_whitelist_domain_mask" "example" {
for_each = toset(local.whitelisted_domains)
domain_mask = each.value
endpoint_id = quicknode_endpoint.example.id
}
# Whitelist specific RPC methods for the endpoint
resource "quicknode_endpoint_whitelist_methods" "example" {
method = ["eth_blockNumber", "eth_getBalance", "eth_chainId"]
endpoint_id = quicknode_endpoint.example.id
}
output "optimism_chain" {
value = quicknode_endpoint.example
}The provider requires a QuickNode API key. You can configure it in two ways:
-
Environment variables (recommended):
export QUICKNODE_API_KEY="your-api-key"
-
Provider configuration (not recommended for production):
provider "quicknode" { api_key = "your-api-key" }
You can optionally override the API base URL (defaults to https://api.quicknode.com):
export QUICKNODE_ENDPOINT="https://api.quicknode.com"quicknode_endpoint- Creates and manages a QuickNode RPC endpoint.quicknode_endpoint_whitelist_ip- Manages IP whitelist entries for an endpoint.quicknode_endpoint_whitelist_domain_mask- Manages domain mask whitelist entries for an endpoint.quicknode_endpoint_whitelist_methods- Manages RPC method whitelist (request filters) for an endpoint.
quicknode_chains- Fetches the list of supported blockchain chains and their networks.quicknode_endpoint- Returns info for a specific endpoint.quicknode_endpoints- Lists info for all available endpoints.
make buildUnit tests:
make testAcceptance tests (creates real resources):
export QUICKNODE_API_KEY="your-api-key"
make testaccThe API client is generated from the QuickNode OpenAPI spec using oapi-codegen. Generated code lives in internal/api/.
To regenerate after updating the spec:
cd internal/api
go generate ./...make generateDocumentation is generated from the provider schema and example configurations in examples/. Do not edit files in docs/ directly.
This project is licensed under the Mozilla Public License 2.0.