add cloudflare DNS module
This commit is contained in:
commit
af00f58f92
3 files changed
+58
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
@@ -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
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user