Skip to content
Snippets Groups Projects
Commit c65e160a authored by Goik Martin's avatar Goik Martin
Browse files

API secret and steps renamings

parent 99c1e501
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 14 deletions
# Barebone server creation by single `main.tf` file
\ No newline at end of file
# Supporting non-versioned secrets
......@@ -8,31 +8,12 @@ terraform {
}
provider "hcloud" {
token = "your_api_token_goes_here"
token = var.hcloud_token # See secrets.auto.tfvars
}
resource "hcloud_firewall" "sshFw" {
name = "ssh-firewall"
rule {
direction = "in"
protocol = "tcp"
port = "22"
source_ips = [
"0.0.0.0/0",
"::/0"
]
}
}
resource "hcloud_ssh_key" "goik" {
name = "goik@hdm-stuttgart.de"
public_key = file("~/.ssh/id_ed25519.pub")
}
# Create server
resource "hcloud_server" "helloServer" {
name = "hello"
image = "debian-12"
server_type = "cx11"
location = "nbg1"
ssh_keys = [hcloud_ssh_key.goik.id]
firewall_ids = [hcloud_firewall.sshFw.id]
}
# Firewall setup and ssh key installation
- Add ssh public key from local file system providing admin (`root`) login
- Add firewall restricting inbound traffic to ssh connections
\ No newline at end of file
......@@ -24,7 +24,7 @@ resource "hcloud_firewall" "sshFw" {
}
}
resource "hcloud_ssh_key" "goik" {
resource "hcloud_ssh_key" "loginUser" {
name = "goik@hdm-stuttgart.de"
public_key = file("~/.ssh/id_ed25519.pub")
}
......@@ -34,6 +34,6 @@ resource "hcloud_server" "helloServer" {
image = "debian-12"
server_type = "cx11"
location = "nbg1"
ssh_keys = [hcloud_ssh_key.goik.id]
ssh_keys = [hcloud_ssh_key.loginUser.id]
firewall_ids = [hcloud_firewall.sshFw.id]
}
hcloud_token="your_api_token_goes_here"
variable "hcloud_token" { # See secret.auto.tfvars
nullable = false
sensitive = true
}
\ No newline at end of file
output "hello_ip_addr" {
value = hcloud_server.helloServer.ipv4_address
description = "The server's IPv4 address"
}
output "hello_datacenter" {
value = hcloud_server.helloServer.datacenter
description = "The server's datacenter"
}
\ No newline at end of file
# Show server's provider ID and IP on `terraform apply` execution
......@@ -8,7 +8,7 @@ terraform {
}
provider "hcloud" {
token = "your_api_token_goes_here"
token = var.hcloud_token
}
resource "hcloud_firewall" "sshFw" {
......@@ -23,7 +23,7 @@ resource "hcloud_firewall" "sshFw" {
]
}
}
resource "hcloud_ssh_key" "goik" {
resource "hcloud_ssh_key" "loginUser" {
name = "goik@hdm-stuttgart.de"
public_key = file("~/.ssh/id_ed25519.pub")
}
......@@ -33,7 +33,7 @@ resource "hcloud_server" "helloServer" {
image = "debian-12"
server_type = "cx11"
location = "nbg1"
ssh_keys = [hcloud_ssh_key.goik.id]
ssh_keys = [hcloud_ssh_key.loginUser.id]
firewall_ids = [hcloud_firewall.sshFw.id]
}
......
hcloud_token="your_api_token_goes_here"
variable "hcloud_token" { # See secret.auto.tfvars
nullable = false
sensitive = true
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment