initial
This commit is contained in:
commit
14cbc8c367
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
ENV
|
||||
terraform.tfstate
|
||||
terraform.tfstate.backup
|
||||
tf-key
|
||||
tf-key.pub
|
||||
.terraform.lock.hcl
|
||||
.terraform/
|
||||
|
96
main.tf
Normal file
96
main.tf
Normal file
@ -0,0 +1,96 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
hcloud = {
|
||||
source = "hetznercloud/hcloud"
|
||||
version = "1.36.2"
|
||||
}
|
||||
}
|
||||
|
||||
backend "http" {
|
||||
}
|
||||
}
|
||||
|
||||
provider "hcloud" {
|
||||
token = var.hcloud_token
|
||||
}
|
||||
|
||||
resource "hcloud_ssh_key" "default" {
|
||||
name = "DefaultSSHKey"
|
||||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDgWpTiwD2v1PIfgEMB6/BjPhevD2pV6I7l6U08ESXcgqiEG9fR8RxpvVP+5K/gvFw36qcVINCbiyYxH6TMRwqYPpYRhBwyydDJMMzGg0FFTucQAhVnxREZk5soDyhlwQUumsvmk0/+NZ0DxTA2Z4JJSwvD9Q2Gm5ca6D/nUodlb7qs4/26NsffMmTYng3NQLKYg6Rg0TyV6WRiHrxeonaWOeCqYuB4sG5himvUJ0cbg6Yvs82Qy4djipa3nmIi6GbpPLqisC1Fy8RH1j32kqY7w2+i7X9xD+U2Yf9PYGLiPZ5yzCqhnH1Z9U2/MQUc1jzHnWKPdzV/YMxOpcCRHpLY67XmJ3B7dXVPjlADVA1T+SIvhy77UZV9rhVyCCNifb6qSEWGwN8CBbbeU3z4hSkNnxNv2RnUm7UQyRPlL+cWC3U34omqGZMZb5HUXhZ31trz61PiXly/mgOKKwGB0C0f1U4StHc4/HR8gY7XQj854R2oznAbZgy/xiCZO0kZJ9hCQ3rtt1NqHkHd9+n2QPyVIgCYMoEaxs9umJKkArbYVsWXIdHOJcnEH2Uk/p8//Je2K8YW+PAQ/GXKwER0+pXj4G/cOCnjQcEIWlUDAuYYOfqRG7hkC6H+ZLyO6cmOKB5gRQTaf1JanbFL4lAMUHI/4LB9/E0HhIIgxnsmsyid3Q== openpgp:0x49DE4884"
|
||||
}
|
||||
resource "hcloud_ssh_key" "tf" {
|
||||
name = "TerraformSSHKey"
|
||||
public_key = file("./tf-key.pub")
|
||||
}
|
||||
|
||||
resource "hcloud_firewall" "default" {
|
||||
name = "DefaultFirewall"
|
||||
rule {
|
||||
description = "grafana"
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
source_ips = [
|
||||
"0.0.0.0/0"
|
||||
]
|
||||
port = "3000"
|
||||
}
|
||||
rule {
|
||||
description = "http"
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
source_ips = [
|
||||
"0.0.0.0/0"
|
||||
]
|
||||
port = "80"
|
||||
}
|
||||
rule {
|
||||
description = "https"
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
source_ips = [
|
||||
"0.0.0.0/0"
|
||||
]
|
||||
port = "443"
|
||||
}
|
||||
rule {
|
||||
description = "mqtt/tls"
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
source_ips = [
|
||||
"0.0.0.0/0"
|
||||
]
|
||||
port = "8883"
|
||||
}
|
||||
rule {
|
||||
description = "ssh"
|
||||
direction = "in"
|
||||
protocol = "tcp"
|
||||
source_ips = [
|
||||
"0.0.0.0/0"
|
||||
]
|
||||
port = "22"
|
||||
}
|
||||
}
|
||||
|
||||
resource "hcloud_server" "saerbeck01" {
|
||||
name = "saerbeck01"
|
||||
image = "docker-ce"
|
||||
server_type = "cpx21"
|
||||
location = "nbg1"
|
||||
ssh_keys = [
|
||||
hcloud_ssh_key.default.id,
|
||||
hcloud_ssh_key.tf.id
|
||||
]
|
||||
public_net {
|
||||
ipv4_enabled = true
|
||||
ipv6_enabled = false
|
||||
}
|
||||
firewall_ids = [
|
||||
hcloud_firewall.default.id
|
||||
]
|
||||
}
|
||||
|
||||
output "IPAddress" {
|
||||
value = hcloud_server.saerbeck01.ipv4_address
|
||||
description = "Main Address"
|
||||
}
|
4
variables.tf
Normal file
4
variables.tf
Normal file
@ -0,0 +1,4 @@
|
||||
variable "hcloud_token" {
|
||||
sensitive = true
|
||||
type = string
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user