A Terraform Provider for Namecheap domain DNS configuration.
- Namecheap Provider Documentation
- Guide: Migration to v2.0.0 new major release
- Guide: Namecheap domain records
- Guide: Running in CI and automation environments
First you'll need to apply for API access to Namecheap. You can do that on this API admin page.
Next, find out your IP address and add that IP (or any other IPs accessing this API) to this whitelist admin page on Namecheap.
Once you've done that, make note of the API key, your IP address, and your username to fill into our provider block.
client_ip is optional: when it is left unset the provider auto-detects the caller's public IP over HTTPS. Set it explicitly (or via NAMECHEAP_CLIENT_IP) when running on hosts with restricted egress or split routing. For running from CI runners, containers, and other automation, see the Running in CI and automation environments guide.
Make sure your API details are correct in the provider block.
Terraform 0.13 and later:
terraform {
required_providers {
namecheap = {
source = "namecheap/namecheap"
version = ">= 2.0.0"
}
}
}
provider "namecheap" {
user_name = "your_username"
api_user = "your_username"
api_key = "your_api_key"
client_ip = "your.ip.address.here"
use_sandbox = false
# Optional client resilience tuning (defaults shown):
# requests_per_minute = 20 # client-side rate limit (1-20)
# max_retries = 4 # attempts per call (>= 0; 0 means SDK default of 4)
# retry_max_elapsed = "2m" # max total retry time (Go duration)
# request_timeout = "30s" # per-request HTTP timeout (Go duration)
}
resource "namecheap_domain_records" "domain-com" {
domain = "domain.com"
mode = "OVERWRITE"
record {
hostname = "dev"
type = "A"
address = "10.12.14.19"
}
}
resource "namecheap_domain_records" "domain2-com" {
domain = "domain2.com"
mode = "OVERWRITE"
nameservers = [
"ns1.random-domain.org",
"ns2.random-domain.org",
]
}Every pull request runs a fast, credential-free mock-backed acceptance suite
(make testacc-mock) on GitHub-hosted runners across a Terraform + OpenTofu
version matrix:
| Engine | Versions tested in CI |
|---|---|
| Terraform | 1.5.7 (minimum supported), 1.15.5 (latest series) |
| OpenTofu | 1.12.3 |
A live-API sandbox suite (make testacc-sandbox, aliased as make testacc)
additionally runs on pushes to this repository. See
CONTRIBUTING.md for how to run each locally.
To contribute, please read our contributing docs.
See SECURITY_COMPLIANCE.md for the full set of
controls (dependency pinning, vulnerability and license scanning, SBOM
publication, supply-chain pinning) and for how to report a vulnerability.