backend.tf 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. resource "yandex_compute_instance_group" "ig-backend" {
  2. name = "ig-backend"
  3. service_account_id = yandex_iam_service_account.ig_sa.id
  4. folder_id = var.folder_id
  5. instance_template {
  6. platform_id = "standard-v2"
  7. resources {
  8. cores = 4
  9. memory = 8
  10. }
  11. service_account_id = yandex_iam_service_account.ig_sa.id
  12. boot_disk {
  13. mode = "READ_WRITE"
  14. initialize_params {
  15. image_id = data.yandex_compute_image.container-optimized-image.id
  16. size = 13
  17. }
  18. }
  19. secondary_disk {
  20. mode = "READ_WRITE"
  21. device_name = "coi-data"
  22. initialize_params {
  23. size = 13
  24. type = "network-ssd"
  25. }
  26. }
  27. network_interface {
  28. subnet_ids = [yandex_vpc_subnet.backend-subnet-a.id, yandex_vpc_subnet.backend-subnet-b.id, yandex_vpc_subnet.backend-subnet-c.id]
  29. nat=true
  30. security_group_ids = [yandex_vpc_security_group.sg-backend.id]
  31. }
  32. metadata = {
  33. docker-compose = file("docker-compose.yaml")
  34. user-data = "${data.template_file.cloud_init.rendered}"
  35. serial-port-enable = 1
  36. }
  37. }
  38. scale_policy {
  39. fixed_scale {
  40. size = 3
  41. }
  42. }
  43. allocation_policy {
  44. zones = ["ru-central1-a", "ru-central1-b", "ru-central1-c"]
  45. }
  46. deploy_policy {
  47. max_unavailable = 3
  48. max_creating = 3
  49. max_expansion = 3
  50. max_deleting = 3
  51. }
  52. depends_on = [
  53. yandex_resourcemanager_folder_iam_binding.sabind,
  54. ]
  55. }