Consul Integration
Table of Contents
- Before starting
- Add the task to your CTS configuration
- Set the module variables
- Describe the records in service metadata
- Have more questions?
DNSimple’s Consul-Terraform-Sync module, dnsimple/cts/dnsimple, keeps DNS records in DNSimple in step with the services in your Consul catalog. When a service changes, Consul-Terraform-Sync (CTS) runs the module, which creates or updates the records you describe in the service’s metadata. It uses DNSimple’s Terraform provider to make the changes.
Before starting
You need:
- A Consul cluster and Consul-Terraform-Sync installed
- An API access token for your DNSimple account, and the account ID shown on the page, as in Getting to the API & Access page
- The zone for your records in DNSimple
Add the task to your CTS configuration
Define a task that uses the module:
task {
name = "dnsimple-task"
description = "Manage DNSimple records from Consul service metadata"
module = "dnsimple/cts/dnsimple"
variable_files = ["/etc/consul-tf-sync/dnsimple.tfvars"]
condition "services" {
regexp = ".+"
filter = "Service.Kind != \"connect-proxy\" and Service.Tags contains \"dnsimple\""
}
}
-
condition "services"chooses which services trigger the task. This example picks every service taggeddnsimpleand leaves out Consul Connect proxies, which would otherwise create duplicate records. -
variable_filespoints to the file with the module variables below.
Set the module variables
The module needs three variables. Set all three, including dnsimple_sandbox, which has no default:
dnsimple_token = "your-api-access-token"
dnsimple_account = "1010"
dnsimple_sandbox = false
Set dnsimple_sandbox = true to test against the DNSimple Sandbox with a Sandbox token and account ID.
Describe the records in service metadata
Add dnsimple_ keys to the meta section of each service you want in DNS:
"Meta": {
"dnsimple_zone_name": "example.com",
"dnsimple_record_name": "api",
"dnsimple_record_content": "$address",
"dnsimple_record_ttl": "600"
}
This creates an A record for api.example.com that points to the service’s address, with a TTL of 600 seconds.
| Key | Required | What it sets |
|---|---|---|
dnsimple_zone_name |
Yes, unless dnsimple_default_zone is set |
The zone to add the record to |
dnsimple_record_name |
Yes | The record name, such as api
|
dnsimple_record_content |
Yes | The record value, such as $address or 192.0.2.1
|
dnsimple_record_type |
No | The record type. Defaults to A
|
dnsimple_record_ttl |
No | The TTL in seconds. Defaults to 3600
|
dnsimple_record_priority |
No | The priority, for MX and SRV records |
dnsimple_default_zone, dnsimple_default_record_type, dnsimple_default_record_ttl
|
No | Defaults for this service’s records |
dnsimple_record_name and dnsimple_record_content can include service attributes, such as $address, $port, $name, and $node_address. To create more than one record for a service, add a numbered set of keys, such as dnsimple_record_name-1 and dnsimple_record_content-1. A numbered set without its dnsimple_record_content key is skipped. The module README lists every attribute.
Have more questions?
If you have additional questions or need any assistance with the Consul integration, contact support, and we will be happy to help. You can also read more about DNSimple integrations.