Last active
June 20, 2020 20:11
-
-
Save webchi/8e214383db22eac23851c2d19c1c4603 to your computer and use it in GitHub Desktop.
Yandex instance group
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 "yandex_iam_service_account" "swarm-group" { | |
name = "swarm-group" | |
description = "service account to manage Instance Group" | |
} | |
resource "yandex_resourcemanager_folder_iam_binding" "editor" { | |
folder_id = var.yandex_folder_id | |
role = "editor" | |
members = [ | |
"serviceAccount:${yandex_iam_service_account.swarm-group.id}", | |
] | |
} |
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 "yandex_compute_instance_group" "swarm-workers" { | |
name = "swarm-workers" | |
folder_id = var.yandex_folder_id | |
service_account_id = yandex_iam_service_account.swarm-group.id | |
instance_template { | |
platform_id = "standard-v1" | |
resources { | |
cores = 1 | |
memory = 2 | |
} | |
boot_disk { | |
mode = "READ_WRITE" | |
initialize_params { | |
image_id = data.yandex_compute_image.container-optimized-image.id | |
} | |
} | |
network_interface { | |
network_id = yandex_vpc_network.default.id | |
subnet_ids = [yandex_vpc_subnet.subnet-a.id] | |
} | |
metadata = { | |
user-data = data.template_cloudinit_config.cloudinit.rendered | |
} | |
service_account_id = "The ID of the service account authorized for this instance" | |
} | |
scale_policy { | |
auto_scale { | |
initial_size = 1 | |
measurement_duration = 60 | |
cpu_utilization_target = 75 | |
min_zone_size = 1 | |
max_size = 2 | |
warmup_duration = 60 | |
stabilization_duration = 120 | |
} | |
} | |
allocation_policy { | |
zones = ["ru-central1-a"] | |
} | |
deploy_policy { | |
max_unavailable = 1 | |
max_expansion = 0 | |
} | |
} | |
data "yandex_compute_image" "container-optimized-image" { | |
family = "container-optimized-image" | |
} | |
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
variable "instance_ssh_pubkey_path" { | |
default = "~/.ssh/id_rsa.pub" | |
} | |
variable "yandex_folder_id" {} | |
variable "yandex_oauth" {} |
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 "yandex_vpc_network" "default" { | |
name = "main" | |
} | |
resource "yandex_vpc_subnet" "subnet-a" { | |
v4_cidr_blocks = ["10.0.0.0/28"] | |
name = "sn-ru-central1-a" | |
zone = "ru-central1-a" | |
network_id = yandex_vpc_network.default.id | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment