Last active
May 6, 2019 13:05
-
-
Save Dartblack4/f82ca9f785aa154200f693ac53aaa111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "hcloud_server" "server" { # Create a server | |
name = "server-${local.name}" # Name server | |
image = "${var.image}" # Basic image | |
server_type = "${var.server_type}" # Instance type | |
location = "${var.location}" # Region | |
backups = "false" # Enable backups | |
ssh_keys = ["${hcloud_ssh_key.user.id}"] # SSH key | |
user_data = "${data.template_file.instance.rendered}" # The script that works when you start | |
provisioner "file" { # Copying files to instances | |
source = "user-data/file" # Path to file on local machine | |
destination = "/root/file" # Path to copy | |
} | |
} | |
# File definition user-data | |
data "template_file" "instance" { | |
template = "${file("${path.module}/user-data/instance.tpl")}" | |
} | |
# Definition ssh key from variable | |
resource "hcloud_ssh_key" "user" { | |
name = "user" | |
public_key = "${var.public_key}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment