-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudflare.tf
More file actions
44 lines (37 loc) · 1.16 KB
/
cloudflare.tf
File metadata and controls
44 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
terraform {
backend "s3" {
bucket = "my-terraform-state-bucket"
key = "prod/terraform.tfstate"
region = "auto"
endpoints = {
s3 = "https://72c051b1031882b8397bd766f01914f7.r2.cloudflarestorage.com"
}
skip_credentials_validation = true
skip_region_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
skip_s3_checksum = true
use_path_style = true
}
}
provider "cloudflare" {
api_token = var.cloudflare_api_token
}
# Fetches latest Cloudflare IPs automatically via API
data "cloudflare_ip_ranges" "cloudflare" {}
resource "cloudflare_dns_record" "vm_dns" {
zone_id = var.cloudflare_zone_id
name = "resources" # Root domain
content = azurerm_public_ip.vm_public_ip.ip_address
type = "A"
ttl = 1 # Auto TTL
proxied = true # Enables the Orange Cloud (SSL & IP Hiding)
}
resource "cloudflare_dns_record" "vm_ssh_dns" {
zone_id = var.cloudflare_zone_id
name = "ssh-access"
content = azurerm_public_ip.vm_public_ip.ip_address
type = "A"
ttl = 3600
proxied = false # This allows non-HTTP traffic like SSH to pass
}