Created
March 12, 2019 10:51
-
-
Save Dartblack4/2a18a3faf823159ad791dc1cebb9d4a3 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}" # Имя сервера | |
image = "${var.image}" # Базовый образ | |
server_type = "${var.server_type}" # Тип инстанса | |
location = "${var.location}" # Регион | |
backups = "false" # Включать ли бекапы | |
ssh_keys = ["${hcloud_ssh_key.user.id}"] # SSH ключ | |
user_data = "${data.template_file.instance.rendered}" # Скрипт, который отработает при старте | |
provisioner "file" { # Копирование файлов на инстанс | |
source = "user-data/file" # Путь до файла на локальной машине | |
destination = "/root/file" # Путь куда копировать | |
} | |
} | |
# Определение файла юзердаты | |
data "template_file" "instance" { | |
template = "${file("${path.module}/user-data/instance.tpl")}" | |
} | |
# Определение ssh ключа из переменной | |
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