-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcloud_host.tf
54 lines (44 loc) · 1.47 KB
/
hcloud_host.tf
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
45
46
47
48
49
50
51
52
53
# This module creates a hcloud host, adds the DNS entries and sets the right rDNS entry in hcloud
locals {
dns_name = var.dns_name != "" ? var.dns_name : var.server_name
}
resource "hcloud_server" "hcloud_host" {
name = var.server_name
image = var.image
server_type = var.server_type
datacenter = var.datacenter
ssh_keys = var.ssh_keys
labels = {
Environment = var.environment
}
}
resource "hcloud_rdns" "hcloud_host_rDNS_v6" {
server_id = hcloud_server.hcloud_host.id
ip_address = hcloud_server.hcloud_host.ipv6_address
dns_ptr = "${local.dns_name}.${var.az_dns_zone.name}"
}
resource "hcloud_rdns" "hcloud_host_rDNS_v4" {
server_id = hcloud_server.hcloud_host.id
ip_address = hcloud_server.hcloud_host.ipv4_address
dns_ptr = "${local.dns_name}.${var.az_dns_zone.name}"
}
resource "azurerm_dns_a_record" "hcloud_host_dns_entry" {
name = local.dns_name
zone_name = var.az_dns_zone.name
resource_group_name = var.az_dns_zone.resource_group_name
ttl = 300
records = [hcloud_server.hcloud_host.ipv4_address]
tags = {
Environment = var.environment
}
}
resource "azurerm_dns_aaaa_record" "hcloud_host_dns_entry" {
name = local.dns_name
zone_name = var.az_dns_zone.name
resource_group_name = var.az_dns_zone.resource_group_name
ttl = 300
records = ["${hcloud_server.hcloud_host.ipv6_address}"]
tags = {
Environment = var.environment
}
}