add cloudflare DNS module

This commit is contained in:
alessandrovitali committed 2026-09-02 20:17:04 +02:00
commit af00f58f92
3 files changed
+58

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# macOS
.DS_Store
+21
View File
@@ -0,0 +1,21 @@
terraform {
required_version = ">= 1.0.0"
required_providers {
cloudflare = { source = "cloudflare/cloudflare", version = "~> 5.23.0" }
}
}
data "cloudflare_zone" "this" {
filter = {
name = var.zone_name
}
}
resource "cloudflare_dns_record" "this" {
zone_id = data.cloudflare_zone.this.id
name = var.record_name
type = var.record_type
content = var.record_value
proxied = var.proxied
ttl = var.proxied ? 1 : var.ttl
}
+35
View File
@@ -0,0 +1,35 @@
variable "zone_name" {
type = string
description = "Apex domain of the Cloudflare zone (e.g. domain.tld)"
}
variable "record_name" {
type = string
description = "Subdomain label to create the record for (e.g. sub → sub.domain.tld)"
}
variable "record_type" {
type = string
description = "DNS record type: A, AAAA, CNAME, MX, TXT"
}
variable "record_value" {
type = string
description = "Record content (IP address, target hostname, text)"
}
variable "proxied" {
type = bool
description = "Route through the Cloudflare proxy (orange cloud)"
default = true
}
variable "ttl" {
type = number
description = "TTL in seconds (ignored when proxied)"
default = 3600
validation {
condition = var.ttl >= 60 && var.ttl <= 86400
error_message = "ttl must be between 60 and 86400 seconds"
}
}