CLI to read Gandi.net live DNS records and generate corresponding TF gandi_livedns_record resources
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Generate Terraform file from Gandi DNS records
[!IMPORTANT] This repository has been archived as I moved all my domains out of Gandi.net and will not use their services anymore. Therefore I will not be able to keep updating the code if their API changes.
[!WARNING] This project is archived on pypi.org too and will not receive any further update. The final version is
1.3.3.
This tool aims to simplify managing DNS recods using Terrafom by making the initial import through a single operation.
It fetches DNS records from one or multiple domains you own with Gandi.net and generates TF files with the corresponding records' resources using gandi_livedns_record and defining each record in a set (see the example output). It will output all the terraform import command to execute for the records.
Install
$ pip install gandi-2-terraform
$ gandi2tf --help
Usage
You need to provide the Gandi API key as an environment variable GANDI_KEY (same as for the TF provider).
$ export GANDI_KEY=A1b2C3d4E5f6
When no argument is given, it will fetch all available domains for the given API key:
$ gandi-2tf
Or it can generate the tf configuration file for a single domain:
$ gandi-2tf example.com
Fetching the domains only owned by a single organization:
$ gandi-2tf --organization-id 04303337-a1b0-4b96-8bd7-992005a072e9
Options
--organization-id: in case your API key has access to multiple organization, you can filter the list of domains fetched by a single organization ID (uuid).--subdir: flag to create a sub directory per domain and generate themain.tfinside it with a second file containing all theimportcommands.
Configuration
In order to access the DNS records through the API, you have to provide your API key. It uses the same variable name than the Gandi Terraform provider GANDI_KEY. See Gandi authentication documentation of their API on how to generate one.
Example
$ export GANDI_KEY=A1b2C3d4E5f6
$ gandi-2tf example.com
will generate a file example.com.tf containing:
locals {
example_com_records = {
apex_a = {
name = "@"
type = "A"
ttl = 10800
values = [
"192.30.252.153",
"192.30.252.154",
]
}
apex_mx = {
name = "@"
type = "MX"
ttl = 10800
values = [
"10 spool.mail.gandi.net.",
"50 fb.mail.gandi.net.",
]
}
apex_txt = {
name = "@"
type = "TXT"
ttl = 10800
values = [
"\"v=spf1 include:_mailcust.gandi.net -all\"",
]
}
imap_cname = {
name = "imap"
type = "CNAME"
ttl = 10800
values = [
"access.mail.gandi.net.",
]
}
smtp_cname = {
name = "smtp"
type = "CNAME"
ttl = 10800
values = [
"relay.mail.gandi.net.",
]
}
webmail_cname = {
name = "webmail"
type = "CNAME"
ttl = 10800
values = [
"webmail.gandi.net.",
]
}
}
}
resource "gandi_livedns_record" "example_com" {
for_each = local.example_com_records
zone = "example.com"
name = each.value.name
ttl = each.value.ttl
type = each.value.type
values = each.value.values
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gandi_2_terraform-1.3.3.tar.gz.
File metadata
- Download URL: gandi_2_terraform-1.3.3.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8e8bfcebb862d312709e3fba60c2a71c3a215eaea55457d2f2c551be58cb03d
|
|
| MD5 |
8531e4e2e29ba9ae6e1f091f457efd5c
|
|
| BLAKE2b-256 |
b47d11b24367956c654724f9a377b8c6464695e6871ca95e569a61f4f1d66fc9
|
File details
Details for the file gandi_2_terraform-1.3.3-py3-none-any.whl.
File metadata
- Download URL: gandi_2_terraform-1.3.3-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.13.1 Linux/6.8.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9020ecc733c1cc2dd77d0e39928d131a287bc96914d3154cb4888bff20fac6fb
|
|
| MD5 |
262b9fd12cb24ecd90bc6055c8ac81cd
|
|
| BLAKE2b-256 |
cad2ca4f389d607e160b7a7fc2bfacfffa8161c56216e4d2687c95b41944646f
|