The Gcore Terraform provider v2 manages Gcore Managed DNS — zones, records, and geo-balancing — through declarative configuration files. The following resources are supported: DNS zones with SOA and DNSSEC configuration, A, AAAA, CNAME, MX, TXT, SRV, CAA records, and geo-balancing with geographic filtering. Provider v2 usesDocumentation Index
Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
api_key for authentication and gcore_dns_zone_rrset for DNS records; installation is in the Terraform overview, and existing v0 configurations can be updated with the migration guide.
Workflow
Add resource configuration tomain.tf, then run:
Create a DNS zone
Thegcore_dns_zone resource manages DNS zones in Gcore. The name field is required; all other fields are optional.
Basic zone
The minimum configuration requires only the zone name.Zone with SOA parameters
The following configuration enables zone resolution and sets the SOA timing and contact fields.| Field | Description | Default |
|---|---|---|
enabled | Whether records resolve on DNS servers | true |
contact | Administrator email address recorded in the SOA record | account default |
refresh | How often secondary servers check for zone changes (seconds) | 5400 |
retry | How long secondary servers wait before retrying a failed refresh (seconds) | 3600 |
expiry | How long secondary servers serve the zone without a successful refresh (seconds) | 1209600 |
nx_ttl | TTL for negative responses (NXDOMAIN) (seconds) | varies |
primary_server | Primary master name server for the zone | account default |
Add DNS records
Thegcore_dns_zone_rrset resource manages individual DNS record sets. Required fields are zone_name, rrset_name, rrset_type, and resource_records.
Each entry in resource_records has a required content field, which is a list of strings. The number and meaning of list elements depends on the record type.
A record
An A record maps a hostname to one or more IPv4 addresses. Each address is a separate entry inresource_records.
- Specify
zone_name— the DNS zone name. - Specify
rrset_name— the full record name (for the zone apex, use the zone name). - Specify
rrset_type = "A". - Add one entry per IP address in
resource_records. Each entry’scontentis a single-element list with the IPv4 address. - (optional) Specify
ttl.
AAAA record
An AAAA record maps a hostname to one or more IPv6 addresses. Each address is a separate entry inresource_records.
- Each entry’s
contentis a single-element list with the IPv6 address.
CNAME record
A CNAME record creates an alias that points one hostname to another.- Specify
rrset_name— the alias name. - Specify
content— the target domain with a trailing dot.
MX record
MXcontent must have exactly two elements: the priority and the mail server hostname (with trailing dot).
- Add one entry per mail server. Each
contentlist has two elements:["<priority>", "<hostname>."].
TXT record
A TXT record holds arbitrary text, commonly used for SPF, DKIM, and domain verification strings.CAA record
CAAcontent must have exactly three elements: flags, tag, and the CA value.
- Each
contentlist has three elements:["<flags>", "<tag>", "<value>"]. Tag acceptsissue,issuewild, oriodef.
SRV record
An SRV record specifies the location of a service, including its priority, weight, port, and target hostname.- Specify
rrset_name— the service name in the format_service._proto.example.com. - SRV
contentmust have exactly four elements: priority, weight, port, and target hostname (with trailing dot).
Configure geo-balancing
Geo-balancing routes DNS queries to the nearest or most appropriate server. Configure it with apickers block on the RRset and meta values on each record.
meta values are strings, so array-type values (latlong, continents, countries) must be JSON-encoded using the jsonencode() function.
- Add a
pickersblock. Specifytype— the filter algorithm. Available types:geodistance,geodns,country,continent,asn,ip,weighted_shuffle,first_n,default. - (optional) Specify
limit— maximum records returned per query. Set to0for no limit. - (optional) Add
strict = trueto return no records if none match, instead of falling back to all records. - Add
metainside eachresource_recordsentry to associate geographic data with that IP:latlong—jsonencode([latitude, longitude]), used by thegeodistancepicker.- (optional)
continents—jsonencode(["EU"])— two-letter continent code. - (optional)
countries—jsonencode(["NL"])— two-letter country code as defined in the geobalancing article.
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_name/rrset_name/rrset_type: