With the Gcore Terraform provider v0, teams define DNS zones and records in configuration files, then apply them consistently across environments without managing DNS through the Portal. The following resources are supported: DNS zones with SOA and DNSSEC configuration, A, AAAA, CNAME, MX, TXT, SRV, CAA records, geo-balancing with geographic filtering, and DNS failover with health checks. Provider installation is in the Terraform overview; to upgrade, use the Terraform provider v2 article and the migration guide.Documentation Index
Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Workflow
Add resource configuration tomain.tf, then run:
Create a DNS zone
Thegcore_dns_zone resource manages DNS zones in Gcore.
Add a basic zone
The minimum configuration requires only the zone name.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
Configure optional zone settings
The following configuration enables DNSSEC and sets the SOA timing, contact, and primary server fields.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the zone.
- Specify
name. - (optional) Add
enabled = trueto allow records to resolve on DNS servers. - (optional) Add
dnssec = trueto enable DNSSEC signing for the zone. - (optional) Specify
contact— the administrator email recorded in the SOA record. - (optional) Specify
refresh— how often secondary servers check for zone changes (seconds). - (optional) Specify
retry— how long secondary servers wait before retrying a failed refresh (seconds). - (optional) Specify
expiry— how long secondary servers serve the zone without a successful refresh (seconds). - (optional) Specify
nx_ttl— TTL for negative responses (seconds). - (optional) Specify
primary_server— the primary master name server for the zone.
Add DNS records
Thegcore_dns_zone_record resource manages individual DNS records within a zone. Required fields are zone, domain, type, and at least one resource_record block. The ttl field is optional.
A record
An A record maps a hostname to one or more IPv4 addresses.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
zone— the DNS zone name. - Specify
domain— the full record name (for the zone apex, use the zone name). - Specify
type = "A". - Add one
resource_recordblock per IP address. Specifycontent— the IPv4 address. - (optional) Specify
ttl.
AAAA record
An AAAA record maps a hostname to one or more IPv6 addresses.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
zone— the DNS zone name. - Specify
domain— the full record name. - Specify
type = "AAAA". - Add one
resource_recordblock per IPv6 address. Specifycontent— the IPv6 address. - (optional) Specify
ttl.
CNAME record
A CNAME record creates an alias that points one hostname to another.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
zone. - Specify
domain— the alias name. - Specify
type = "CNAME". - Specify
content— the target domain with a trailing dot. - (optional) Specify
ttl.
MX record
An MX record specifies mail servers for the domain, each with a priority value.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
zoneanddomain. - Specify
type = "MX". - Add one
resource_recordblock per mail server. Specifycontentas"<priority> <hostname>."— priority and hostname separated by a space, hostname with a trailing dot. - (optional) Specify
ttl.
TXT record
A TXT record holds arbitrary text, commonly used for SPF, DKIM, and domain verification.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
zoneanddomain. - Specify
type = "TXT". - Specify
content— the text value, such as an SPF, DKIM, or domain verification string. - (optional) Specify
ttl.
CAA record
A CAA record specifies which certificate authorities are allowed to issue certificates for the domain.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
zoneanddomain. - Specify
type = "CAA". - Specify
contentas"<flags> <tag> \"<value>\""— flags, tag (issue,issuewild, oriodef), and the CA value in quotes. - (optional) Specify
ttl.
SRV record
An SRV record specifies the location of a service, including its priority, weight, port, and target hostname.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the record.
- Specify
domain— the service name in the format_service._proto.example.com. - Specify
type = "SRV". - Specify
contentas"<priority> <weight> <port> <target>."— four values separated by spaces, target with a trailing dot. - (optional) Specify
ttl.
Configure geo-balancing
Geo-balancing returns different IP addresses based on the client’s geographic location, usingfilter and meta blocks within a record.
- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure geo-balancing.
- Add a
filterblock. Specifytype— the filter algorithm (geodistance,geodns,country,continent,asn,ip,weighted_shuffle,first_n, ordefault). - (optional) Specify
limit— the maximum number of records returned per query. Set to0for no limit. - (optional) Add
strict = trueto return no records if none match the filter, instead of falling back to all records. - Add
metainside eachresource_recordto associate geographic data with that IP.- Specify
latlong—[latitude, longitude]coordinates used by thegeodistancefilter. - (optional) Specify
continents— list of continent codes (europe,north_america,south_america,asia,africa,oceania). - (optional) Specify
countries— list of two-letter country codes as defined in the geobalancing article.
- Specify
Set up failover with health checks
Health checks automatically remove unhealthy records from DNS responses, directing traffic only to reachable endpoints.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the values:
- Configure the health check.
- Add
filter { type = "is_healthy" }to exclude unhealthy records from DNS responses. - Add
enabled = trueinside eachresource_recordto include it in health check rotation. - Add a
meta { failover { } }block to the record and configure the health check:- Specify
protocol—HTTP,TCP,UDP, orICMP. - Specify
port. - Specify
frequency— check interval from 10 to 3600 seconds. - Specify
timeout— response timeout from 1 to 10 seconds. - (optional, HTTP only) Specify
host,method,url,http_status_code, andtls.
- Specify
Import existing DNS resources
To import existing DNS zones and records from the Gcore Customer Portal into Terraform state, add the corresponding resource blocks tomain.tf and run the import commands below.
To import an existing DNS zone:
zone:domain:type: