Skip to main content

Migration Guide

Import and migrate existing Namecheap domains to Pulumi management
3 min read

This guide explains how to import existing Namecheap domains and DNS records into Pulumi, allowing you to manage them as Infrastructure as Code.

Why Migrate to Pulumi?#

  • Version Control: Track all DNS changes in Git
  • Reproducibility: Recreate environments easily
  • Collaboration: Team members can review and approve changes
  • Automation: Integrate with CI/CD pipelines
  • Documentation: Code serves as living documentation

Pre-Migration Checklist#

Before migrating, ensure you have:

  • Namecheap API access enabled
  • API credentials (username, API key)
  • IP address whitelisted
  • Backup of current DNS settings
  • List of domains to migrate
  • Understanding of current DNS configuration

Backup Current Configuration#

Export your current DNS records manually or via API:

Import Strategy#

This approach imports existing DNS records into Pulumi state without changes.

Step 1: Create Pulumi code matching existing configuration

Step 2: Import the resource

Step 3: Verify the import

Option 2: Recreate Resources#

For simpler setups, you can define resources from scratch:

Step 1: Document existing configuration

Take screenshots or notes of your current Namecheap DNS settings.

Step 2: Create Pulumi program

Step 3: Apply with caution

Migration Patterns#

Single Domain Migration#

Simplest case - one domain with standard DNS:

Multiple Domains Migration#

Organize multiple domains efficiently:

Environment-Based Migration#

Migrate dev, staging, and production separately:

Migration Steps#

Phase 1: Preparation (Week 1)#

  1. Audit Current Configuration

    • Document all DNS records
    • Identify critical services
    • Note custom configurations
  2. Set Up Development Environment

  3. Test in Sandbox

Phase 2: Non-Critical Domains (Week 2)#

  1. Start with development domains
  2. Import or recreate resources
  3. Verify DNS resolution
  4. Monitor for 24-48 hours

Phase 3: Production Domains (Week 3-4)#

  1. Lower TTL values

  2. Migrate during low-traffic period

  3. Monitor closely

  4. Keep backup plan ready

  5. Restore normal TTL after 48 hours

Rollback Plan#

Always have a rollback strategy:

Post-Migration Tasks#

Verification#

Documentation#

Monitoring Setup#

Set up alerts for DNS changes:

Common Migration Issues#

Issue: Import Fails#

Problem: Cannot import existing resource

Solution: Use different resource name or remove from state first

Issue: Records Not Matching#

Problem: Pulumi shows changes after import

Solution: Ensure your code exactly matches existing configuration, including:

  • TTL values (use actual values, not defaults)
  • Record order (may need to reorder)
  • Trailing dots on CNAMEs

Issue: Downtime During Migration#

Problem: DNS resolution fails after migration

Solution:

  1. Check Namecheap API responded successfully
  2. Verify records in Namecheap dashboard
  3. Use low TTL values before migration
  4. Have rollback plan ready

Best Practices#

Incremental Migration#

Don't migrate everything at once:

Use Stack Tags#

Track migration status:

Document Everything#

Next Steps#