Terraform module to manage the following Hetzner Cloud resources:
- hcloud_server
Copy and paste the following code snippet to your Terraform configuration,
specify the required variables and run the command terraform init.
module "hcloud_firewall" {
source = "gitlab.com/terraform-child-modules-48151/terraform-hcloud-firewall/local"
version = "1.0.0"
name = "example-firewall"
rule = [
{
direction = "in"
protocol = "icmp"
source_ips = [
"0.0.0.0/0",
"::/0"
]
},
{
direction = "in"
protocol = "tcp"
port = "22"
source_ips = [
"0.0.0.0/0",
"::/0"
]
},
{
direction = "out"
protocol = "icmp"
destination_ips = [
"0.0.0.0/0",
"::/0"
]
},
{
direction = "out"
protocol = "tcp"
port = "53"
destination_ips = [
"0.0.0.0/0",
"::/0"
]
},
{
direction = "out"
protocol = "udp"
port = "53"
destination_ips = [
"0.0.0.0/0",
"::/0"
]
},
{
direction = "out"
protocol = "tcp"
port = "80"
destination_ips = [
"0.0.0.0/0",
"::/0"
]
},
{
direction = "out"
protocol = "tcp"
port = "443"
destination_ips = [
"0.0.0.0/0",
"::/0"
]
}
]
}
module "hcloud_network" {
source = "gitlab.com/terraform-child-modules-48151/terraform-hcloud-network/local"
version = "1.0.0"
name = "example-network"
ip_range_network = "10.0.0.0/8"
type = "cloud"
network_zone = "eu-central"
ip_range_subnet = "10.0.1.0/24"
}
module "hcloud_ssh_key" {
source = "gitlab.com/terraform-child-modules-48151/terraform-hcloud-ssh-key/local"
version = "1.0.0"
name = "example-ssh-key"
public_key = "./dhoppeit.pub"
}
module "hcloud_server" {
source = "gitlab.com/terraform-child-modules-48151/terraform-hcloud-server/local"
version = "1.0.0"
name = "example-server"
image = "debian-13"
server_type = "cx22"
location = "nbg1"
firewall_ids = [
module.hcloud_firewall.id
]
network = {
network_id = module.hcloud_network.id_network
ip = cidrhost(module.hcloud_network.ip_range_subnet, 2)
}
ssh_keys = [
module.hcloud_ssh_key.id
]
}
| Name | Version |
|---|---|
| terraform | >= 1.0 |
| hcloud | ~> 1.0 |
| Name | Version |
|---|---|
| hcloud | ~> 1.0 |
No modules.
| Name | Type |
|---|---|
| hcloud_server.this | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| allow_deprecated_images | Enable the use of deprecated images | bool |
false |
no |
| backups | Enable or disable backups | bool |
false |
no |
| datacenter | The datacenter name to create the server in | string |
null |
no |
| delete_protection | Enable or disable delete protection | bool |
false |
no |
| firewall_ids | Firewall IDs the server should be attached to on creation | list(string) |
[] |
no |
| ignore_remote_firewall_ids | Ignores any updates to the firewall_ids argument which were received from the server | bool |
false |
no |
| image | Name or ID of the image the server is created from | string |
n/a | yes |
| iso | ID or Name of an ISO image to mount | string |
null |
no |
| keep_disk | If true, do not upgrade the disk | bool |
false |
no |
| labels | User-defined labels (key-value pairs) should be created with | map(string) |
{} |
no |
| location | The location name to create the server in | string |
null |
no |
| name | Name of the server to create | string |
n/a | yes |
| network | Private Network the server shall be attached to | object( { network_id = string ip = optional(string) alias_ips = optional(list(string)) } ) |
null |
no |
| placement_group_id | Placement Group ID the server added to on creation | string |
null |
no |
| public_net | In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs | object( { ipv4_enabled = optional(bool) ipv4 = optional(string) ipv6_enabled = optional(bool) ipv6 = optional(string) } ) |
{} |
no |
| rebuild_protection | Enable or disable rebuild protection | bool |
false |
no |
| rescue | Enable and boot in to the specified rescue system | string |
null |
no |
| server_type | Name of the server type this server should be created with | string |
n/a | yes |
| shutdown_before_deletion | Whether to try shutting the server down gracefully before deleting it | bool |
false |
no |
| ssh_keys | SSH key IDs or names which should be injected into the server at creation time | list(string) |
[] |
no |
| user_data | Cloud-Init user data to use during server creation | string |
null |
no |
| Name | Description |
|---|---|
| backups | Whether backups are enabled |
| datacenter | The datacenter name |
| delete_protection | Whether delete protection is enabled |
| firewall_ids | Firewall IDs the server is attached to |
| id | Unique ID of the server |
| image | Name or ID of the image the server was created from |
| ipv4_address | The IPv4 address |
| ipv6_address | The first IPv6 address of the assigned network |
| ipv6_network | The IPv6 network |
| iso | ID or Name of the mounted ISO image |
| labels | User-defined labels (key-value pairs) |
| location | The location name |
| name | Name of the server |
| network | Private Network the server shall be attached to |
| placement_group_id | Placement Group ID the server is assigned to |
| primary_disk_size | The size of the primary disk in GB |
| rebuild_protection | Whether rebuild protection is enabled |
| server_type | Name of the server type |
| shutdown_before_deletion | Whether the server will try to shut down gracefully before being deleted |
| status | The status of the server |
Created and maintained by Dennis Hoppe.
Apache 2 licensed. See LICENSE for full details.