tout est fonctionnel
All checks were successful
terraform validation / Terraform (push) Successful in 11s

This commit is contained in:
Hubert Cornet 2025-01-15 07:57:31 +01:00
parent 33ff1d1604
commit 4bfecd99cc
10 changed files with 138 additions and 103 deletions

View File

@ -1,7 +1,7 @@
# ${REPO_NAME}
# terraform-cloudflare-dns-zone
${REPO_DESCRIPTION}
Gestion DNS pour CloudFlare
# A propos de
@ -14,8 +14,8 @@ https://developer.hashicorp.com/terraform/install?product_intent=terraform
# Démarrage manuel
~~~bash
git clone https://gitea.tips-of-mine.com${REPO_LINK}.git
cd ${TEMPLATE_NAME}
git clone https://gitea.tips-of-mine.com/tips-of-mine/terraform-cloudflare-dns-zone.git
cd terraform-cloudflare-dns-zone
~~~
# Utilisation du repository
@ -35,5 +35,10 @@ plan
terraform plan
~~~
apply
~~~bash
terraform plan
~~~
# Buy me a coffe
<a href='https://ko-fi.com/R5R2KNI3N' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi4.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

10
main.tf
View File

@ -1,10 +0,0 @@
#resource "cloudflare_zone_settings_override" "this" {
# name = "${var.cloudflare_zone}"
# settings {
# always_use_https = "on"
# tls_1_3 = "on"
# ssl = "strict"
# min_tls_version = "1.2"
# }
#}

View File

@ -1,8 +0,0 @@
#output "record" {
# value = cloudflare_record.foobar.hostname
#}
#output "metadata" {
# value = cloudflare_record.foobar.metadata
# sensitive = true
#}

View File

@ -2,14 +2,13 @@ terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.46"
version = "~> 4.50"
}
}
required_version = ">= 1.7.5"
}
provider "cloudflare" {
# email = var.cloudflare_email
api_token = var.cloudflare_api_token
# zone = var.cloudflare_zone
}

View File

@ -1,17 +1,21 @@
resource "cloudflare_record" "terraform" {
zone_id = var.cloudflare_zone
name = "terraform"
value = "82.66.77.254"
type = "A"
resource "cloudflare_record" "a-root" {
zone_id = var.cloudflare_zone_id
comment = "Domain verification record A"
content = var.main_server
name = "a-root.tips-of-mine.com"
proxied = false
tags = []
ttl = 1
proxied = true
type = "A"
}
resource "cloudflare_record" "a-root" {
zone_id = var.cloudflare_zone
resource "cloudflare_record" "b-root" {
zone_id = var.cloudflare_zone_id
comment = "Domain verification record B"
content = var.main_server
name = "@"
value = var.main_server
type = "A"
ttl = 3600
proxied = false
tags = []
ttl = 3600
type = "A"
}

View File

@ -1,17 +1,21 @@
resource "cloudflare_record" "cname-www" {
zone_id = var.cloudflare_zone
name = "www"
value = "${cloudflare_record.a-root.hostname}"
type = "CNAME"
ttl = 3600
zone_id = var.cloudflare_zone_id
comment = "Domain verification record C"
content = cloudflare_record.a-root.name
name = "site"
proxied = false
tags = []
ttl = 3600
type = "CNAME"
}
resource "cloudflare_record" "cname-mail" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record D"
content = cloudflare_record.b-root.name
name = "mail"
value = "ghs.googlehosted.com"
type = "CNAME"
ttl = 3600
proxied = false
tags = []
ttl = 3600
type = "CNAME"
}

View File

@ -1,39 +1,62 @@
resource "cloudflare_record" "mx-aspmx" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record H"
content = "aspmx.l.tips-of-mine.com"
name = "@"
value = "aspmx.l.google.com"
proxied = false
tags = []
ttl = 300
type = "MX"
priority = 10
}
resource "cloudflare_record" "mx-alt1" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record I"
content = "alt1.aspmx.l.tips-of-mine.com"
name = "@"
value = "alt1.aspmx.l.google.com"
proxied = false
tags = []
ttl = 300
type = "MX"
priority = 20
}
resource "cloudflare_record" "mx-alt2" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record J"
content = "alt2.aspmx.l.tips-of-mine.com"
name = "@"
value = "alt2.aspmx.l.google.com"
proxied = false
tags = []
ttl = 300
type = "MX"
priority = 20
priority = 30
}
resource "cloudflare_record" "mx-alt3" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record K"
content = "alt3.aspmx.l.tips-of-mine.com"
name = "@"
value = "alt3.aspmx.l.google.com"
proxied = false
tags = []
ttl = 300
type = "MX"
priority = 30
priority = 40
}
resource "cloudflare_record" "mx-alt4" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record L"
content = "alt4.aspmx.l.tips-of-mine.com"
name = "@"
value = "alt4.aspmx.l.google.com"
proxied = false
tags = []
ttl = 300
type = "MX"
priority = 30
priority = 40
}

View File

@ -1,14 +1,19 @@
#resource "cloudflare_record" "sip-tls-terraform-srv" {
# zone_id = "$var.cloudflare_zone}"
# name = "_sip._tls"
# type = "SRV"
# data = {
# service = "_sip"
# proto = "_tls"
# name = "terraform-srv"
# priority = 0
# weight = 0
# port = 443
# target = "tips-of-mine.com"
# }
#}
resource "cloudflare_record" "sip-tls-terraform-srv" {
zone_id = var.cloudflare_zone_id
comment = "Domain verification record M"
data {
service = "_sip"
proto = "_tls"
name = "terraform-srv"
priority = 0
weight = 0
port = 443
target = "tips-of-mine.com"
}
name = "_sip._tls"
proxied = false
tags = []
ttl = 300
type = "SRV"
priority = 0
}

View File

@ -1,23 +1,32 @@
resource "cloudflare_record" "txt-amazonses" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record E"
content = "xxxxxxxx"
name = "_amazonses"
value = "xxxxxxxx"
type = "TXT"
proxied = false
tags = []
ttl = 300
type = "TXT"
}
resource "cloudflare_record" "txt-dmarc" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record F"
content = "v=DMARC1; p=none; pct=100; rua=mailto:dmarc@tips-of-mine.com; sp=none; aspf=r;"
name = "_dmarc"
value = "v=DMARC1; p=none; pct=100; rua=mailto:dmarc@tips-of-mine.com; sp=none; aspf=r;"
type = "TXT"
proxied = false
tags = []
ttl = 300
type = "TXT"
}
resource "cloudflare_record" "txt-mandrill-domainkey" {
zone_id = var.cloudflare_zone
zone_id = var.cloudflare_zone_id
comment = "Domain verification record G"
content = "v=DKIM1; k=rsa; p=xxxxxxxx;"
name = "mandrill._domainkey"
value = "v=DKIM1; k=rsa; p=xxxxxxxx;"
type = "TXT"
proxied = false
tags = []
ttl = 300
type = "TXT"
}

View File

@ -1,23 +1,27 @@
variable "cloudflare_email" {
description = "L'adresse électronique associée au compte."
type = string
sensitive = true
default = "thedjinhn@gmail.com"
}
variable "cloudflare_api_token" {
description = "Le jeton de l'API Cloudflare."
type = string
default = "EMVLdieKXA6X-ifx0tW0ELNQGde5XrJ3D8T-qcEY"
sensitive = true
default = "EiFZGvTTRwOgFB8-OiiNyuLGEPEZvqjM8ckpA-lA"
}
variable "cloudflare_zone" {
variable "cloudflare_zone_id" {
description = "La zone DNS à laquelle ajouter l'enregistrement."
type = string
default = "tips-of-mine.com"
sensitive = true
default = "82345d1f868f476b080d5ad04d39bd0c"
}
variable "main_server" {
description = "Le serveur principal"
type = string
default = "82.66.77.254"
sensitive = true
default = "10.0.4.50"
}