Add Terraform Stage 1
This commit is contained in:
14
tf-stage-1/modules/dns/dns.tf
Normal file
14
tf-stage-1/modules/dns/dns.tf
Normal file
@ -0,0 +1,14 @@
|
||||
resource "cloudflare_zone" "zone" {
|
||||
account_id = var.account_id
|
||||
zone = var.zone
|
||||
}
|
||||
|
||||
resource "cloudflare_record" "records" {
|
||||
zone_id = cloudflare_zone.zone.id
|
||||
for_each = { for record in var.records : uuidv5("dns", "${record.type}/${record.name}/${record.value}") => record } # Hackery.
|
||||
name = each.value.name
|
||||
value = each.value.value
|
||||
type = each.value.type
|
||||
ttl = 1
|
||||
priority = each.value.type == "MX" ? each.value.priority : null
|
||||
}
|
9
tf-stage-1/modules/dns/main.tf
Normal file
9
tf-stage-1/modules/dns/main.tf
Normal file
@ -0,0 +1,9 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
cloudflare = {
|
||||
source = "cloudflare/cloudflare"
|
||||
version = "~> 4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
tf-stage-1/modules/dns/variables.tf
Normal file
10
tf-stage-1/modules/dns/variables.tf
Normal file
@ -0,0 +1,10 @@
|
||||
variable "account_id" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
variable "zone" {
|
||||
type = string
|
||||
}
|
||||
variable "records" {
|
||||
type = set(object({ type = string, name = string, value = string, priority = optional(number) }))
|
||||
}
|
Reference in New Issue
Block a user