The Namecheap provider allows you to manage DNS records and domain configurations on Namecheap through Pulumi's infrastructure as code approach.
Overview#
The Namecheap provider bridges the Terraform Namecheap provider to Pulumi, enabling you to:
- Manage DNS records for your domains
- Configure email forwarding and MX records
- Use custom nameservers
- Automate domain configuration
Installation#
Install the Namecheap provider package using your preferred package manager:
Configuration#
The provider requires authentication with Namecheap's API. You need:
- API Key: Your Namecheap API key
- API User: Your API username (often same as your account username)
- Username: Your Namecheap account username
- Client IP (optional): Your whitelisted IP address for API access
Getting API Credentials#
- Log in to your Namecheap account
- Navigate to Profile → Tools → API Access
- Enable API access and whitelist your IP address
- Generate an API key
Configuration Options#
Configure the provider using one of these methods:
Method 1: Configuration Block#
Method 2: Environment Variables#
Method 3: Pulumi Configuration#
Quick Start#
Here's a simple example to create DNS records for a domain:
Sandbox Mode#
For testing and development, enable sandbox mode to use Namecheap's sandbox environment:
Resources#
The Namecheap provider includes the following resources:
- DomainRecords - Manage DNS records for a domain
Best Practices#
Security#
- Never commit API keys to source control
- Use Pulumi secrets for sensitive configuration
- Whitelist only necessary IP addresses for API access
- Use separate API keys for different environments
DNS Management#
- Use TTL wisely: Lower TTL (300-600 seconds) for frequently changing records, higher TTL (3600+ seconds) for stable records
- OVERWRITE vs MERGE mode: Use OVERWRITE for full control, MERGE to preserve existing records
- Test in sandbox: Always test configuration changes in sandbox mode first
Example Project Structure#
Troubleshooting#
API Access Issues#
Error: Invalid API credentials
- Verify API key, API user, and username are correct
- Ensure your IP address is whitelisted in Namecheap settings
Error: Domain not found
- Confirm the domain is purchased and active in your Namecheap account
- Check for typos in the domain name
DNS Propagation#
DNS changes may take time to propagate:
- TTL determines cache time: If previous TTL was 3600 seconds, changes may take up to 1 hour to fully propagate
- Use DNS tools: Check propagation with tools like
digor online DNS checkers - Lower TTL before changes: If planning major DNS changes, lower TTL 24-48 hours in advance