Skip to content

Instantly share code, notes, and snippets.

@vyachin
Created July 2, 2019 06:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyachin/1677f7907fa8f3787275628ca5b01843 to your computer and use it in GitHub Desktop.
Save vyachin/1677f7907fa8f3787275628ca5b01843 to your computer and use it in GitHub Desktop.
provider "yandex" {
token = ""
cloud_id = ""
folder_id = ""
zone = ""
}
variable "instance_root_disk" {
default = "20"
}
variable "instance_additional_disk" {
default = "5"
}
resource "yandex_compute_instance" "vm-1" {
name = "vm-1"
description = "First test instance"
hostname = "vm-1"
resources {
cores = 1
memory = 1
}
boot_disk {
auto_delete = true
initialize_params {
image_id = "fd83i5r5g44fjkdpuuva" # ubuntu-1804-lts-1541165525
name = "disk-vm-1-root"
description = "Disk for the root"
size = "${var.instance_root_disk}"
}
}
secondary_disk {
disk_id = "${yandex_compute_disk.disk-vm-1.id}"
auto_delete = true
}
network_interface {
subnet_id = "${yandex_vpc_subnet.subnet-1.id}"
nat = true
}
metadata = {
ssh-keys = "ubuntu:${file("~/.ssh/id_rsa.pub")}"
}
}
resource "yandex_compute_disk" "disk-vm-1" {
name = "disk-vm-1"
type = "network-hdd"
size = "${var.instance_additional_disk}"
labels = {
environment = "test"
}
}
resource "yandex_vpc_network" "network-1" {
name = "network1"
description = "Test Network"
}
resource "yandex_vpc_subnet" "subnet-1" {
name = "subnet1"
zone = "ru-central1-a"
network_id = "${yandex_vpc_network.network-1.id}"
v4_cidr_blocks = ["192.168.10.0/24"]
description = "Test Subnet"
}
output "internal_ip_address_vm_1" {
value = "${yandex_compute_instance.vm-1.network_interface.0.ip_address}"
}
output "external_ip_address_vm_1" {
value = "${yandex_compute_instance.vm-1.network_interface.0.nat_ip_address}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment