A Terraform provider that allows you to manage your Name.com DNS records and domain settings using infrastructure as code.
Special thanks to @mhumeSF for the original name.com provider that served as the foundation for this project.
- ✅ Create and manage DNS records (A, AAAA, CNAME, MX, NS, SRV, TXT)
- ✅ Configure nameservers for domains
- ✅ Set up DNSSEC for domains
- ✅ Built-in rate limiting (20 req/sec and 3000 req/hour by default)
This provider is available in the Terraform Registry. To use it, add the following to your Terraform configuration:
terraform {
required_providers {
namedotcom = {
source = "lexfrei/namedotcom"
version = "1.1.6"
}
}
}If you prefer to build from source:
- Clone this repository
- Run
go mod tidyto ensure dependencies - Run
go build -o terraform-provider-namedotcom - Move the binary to your Terraform plugins directory
The provider requires API credentials from Name.com:
- Log in to your Name.com account
- Go to API settings
- Generate a token if you don't already have one
Then configure the provider with your credentials:
provider "namedotcom" {
username = var.namedotcom_username
token = var.namedotcom_token
}Recommended: Store your credentials in environment variables or in a secure backend:
provider "namedotcom" {
# These can also be set with NAMEDOTCOM_USERNAME and NAMEDOTCOM_TOKEN environment variables
username = var.namedotcom_username
token = var.namedotcom_token
}# Create an A record
resource "namedotcom_record" "website" {
domain_name = "example.com"
host = "www"
record_type = "A"
answer = "192.0.2.1"
}
# Create a CNAME record
resource "namedotcom_record" "alias" {
domain_name = "example.com"
host = "blog"
record_type = "CNAME"
answer = "www.example.com"
}
# Create multiple records for the same domain
resource "namedotcom_record" "multi_records" {
domain_name = "example.com"
record_type = "A"
for_each = {
"" = "192.0.2.1" # Apex domain
"www" = "192.0.2.1"
"api" = "192.0.2.2"
"admin" = "192.0.2.3"
}
host = each.key
answer = each.value
}# Use custom nameservers (e.g., with AWS Route 53)
resource "aws_route53_zone" "example_zone" {
name = "example.com"
}
resource "namedotcom_domain_nameservers" "example_nameservers" {
domain_name = "example.com"
nameservers = [
aws_route53_zone.example_zone.name_servers[0],
aws_route53_zone.example_zone.name_servers[1],
aws_route53_zone.example_zone.name_servers[2],
aws_route53_zone.example_zone.name_servers[3],
]
}# Configure DNSSEC with AWS Route 53
resource "aws_route53_zone" "example_zone" {
name = "example.com"
}
resource "aws_route53_key_signing_key" "example_ksk" {
name = "example-key"
hosted_zone_id = aws_route53_zone.example_zone.id
key_management_service_arn = aws_kms_key.example_kms.arn
}
resource "aws_route53_hosted_zone_dnssec" "example" {
hosted_zone_id = aws_route53_zone.example_zone.id
}
resource "namedotcom_dnssec" "example_dnssec" {
domain_name = "example.com"
key_tag = aws_route53_key_signing_key.example_ksk.key_tag
algorithm = aws_route53_key_signing_key.example_ksk.signing_algorithm_type
digest_type = aws_route53_key_signing_key.example_ksk.digest_algorithm_type
digest = aws_route53_key_signing_key.example_ksk.digest_value
}The provider includes built-in rate limiting to prevent hitting Name.com's API limits. The defaults should work for most use cases, but you can adjust them if needed:
provider "namedotcom" {
username = var.namedotcom_username
token = var.namedotcom_token
# Optional rate limiting configuration
rate_limit_per_second = 20 # Default: 20
rate_limit_per_hour = 3000 # Default: 3000
}To import existing DNS records into your Terraform state:
# Format: terraform import namedotcom_record.[resource_name] [domain_name]:[record_id]
terraform import namedotcom_record.website example.com:12345
# For records in a for_each block
terraform import 'namedotcom_record.multi_records["www"]' example.com:12345To find the record ID, use the Name.com API:
curl -u 'username:token' 'https://api.name.com/v4/domains/example.com/records'To import existing DNSSEC settings:
# Format: terraform import namedotcom_dnssec.[resource_name] [domain_name]
terraform import namedotcom_dnssec.example_dnssec example.com
# For resources in a for_each block
terraform import 'namedotcom_dnssec.dnssec["example.com"]' example.comDetailed documentation for each resource type is available:
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -am 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.