From 57005fa747e3613f5313260baac474cb6fab68f0 Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Thu, 18 Jul 2024 15:12:33 +0700 Subject: [PATCH 1/7] feat: init wrapper --- wrapper/main.tf | 6 ++++++ wrapper/outputs.tf | 5 +++++ wrapper/variables.tf | 11 +++++++++++ wrapper/versions.tf | 11 +++++++++++ 4 files changed, 33 insertions(+) create mode 100644 wrapper/main.tf create mode 100644 wrapper/outputs.tf create mode 100644 wrapper/variables.tf create mode 100644 wrapper/versions.tf diff --git a/wrapper/main.tf b/wrapper/main.tf new file mode 100644 index 0000000..5f67a4b --- /dev/null +++ b/wrapper/main.tf @@ -0,0 +1,6 @@ +module "wrapper" { + source = "../" + + for_each = var.items + +} diff --git a/wrapper/outputs.tf b/wrapper/outputs.tf new file mode 100644 index 0000000..ec6da5f --- /dev/null +++ b/wrapper/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrapper/variables.tf b/wrapper/variables.tf new file mode 100644 index 0000000..a6ea096 --- /dev/null +++ b/wrapper/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrapper/versions.tf b/wrapper/versions.tf new file mode 100644 index 0000000..8e44575 --- /dev/null +++ b/wrapper/versions.tf @@ -0,0 +1,11 @@ +terraform { + required_providers { + yandex = { + source = "yandex-cloud/yandex" + } + tls = { + source = "hashicorp/tls" + } + } + required_version = ">= 1.3" +} From 92cf4a44167b1373e4f03b05cb0cbe57c75d7246 Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Thu, 18 Jul 2024 15:48:42 +0700 Subject: [PATCH 2/7] feat: add items from variables for wrapper --- wrapper/main.tf | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/wrapper/main.tf b/wrapper/main.tf index 5f67a4b..4ed1bb9 100644 --- a/wrapper/main.tf +++ b/wrapper/main.tf @@ -3,4 +3,41 @@ module "wrapper" { for_each = var.items + name = try(each.value.name, var.defaults.name, null) + folder_id = try(each.value.folder_id, var.defaults.folder_id, null) + description = try(each.value.description, var.defaults.description, null) + labels = try(each.value.labels, var.defaults.labels, {}) + zone = try(each.value.zone, var.defaults.zone, null) + subnet_id = try(each.value.subnet_id, var.defaults.subnet_id, "") + enable_nat = try(each.value.enable_nat, var.defaults.enable_nat, null) + create_pip = try(each.value.create_pip, var.defaults.create_pip, true) + enable_ipv4 = try(each.value.enable_ipv4, var.defaults.enable_ipv4, null) + private_ip_address = try(each.value.private_ip_address, var.defaults.private_ip_address, null) + enable_ipv6 = try(each.value.enable_ipv6, var.defaults.enable_ipv6, false) + private_ipv6_address = try(each.value.private_ipv6_address, var.defaults.private_ipv6_address, null) + security_group_ids = try(each.value.security_group_ids, var.defaults.security_group_ids, []) + network_acceleration_type = try(each.value.network_acceleration_type, var.defaults.network_acceleration_type, "standard") + serial_port_enable = try(each.value.serial_port_enable, var.defaults.serial_port_enable, false) + docker_compose = try(each.value.docker_compose, var.defaults.docker_compose, null) + platform_id = try(each.value.platform_id, var.defaults.platform_id, "standard-v3") + cores = try(each.value.cores, var.defaults.cores, 2) + memory = try(each.value.memory, var.defaults.memory, 2) + core_fraction = try(each.value.core_fraction, var.defaults.core_fraction, 100) + preemptible = try(each.value.preemptible, var.defaults.preemptible, false) + placement_group_id = try(each.value.placement_group_id, var.defaults.placement_group_id, null) + placement_affinity_rules = try(each.value.placement_affinity_rules, var.defaults.placement_affinity_rules, []) + image_snapshot_id = try(each.value.image_snapshot_id, var.defaults.image_snapshot_id, null) + image_id = try(each.value.image_id, var.defaults.image_id, null) + image_family = try(each.value.image_family, var.defaults.image_family, "ubuntu-2004-lts") + hostname = try(each.value.hostname, var.defaults.hostname, null) + service_account_id = try(each.value.service_account_id, var.defaults.service_account_id, null) + allow_stopping_for_update = try(each.value.allow_stopping_for_update, var.defaults.allow_stopping_for_update, true) + generate_ssh_key = try(each.value.generate_ssh_key, var.defaults.generate_ssh_key, true) + ssh_user = try(each.value.ssh_user, var.defaults, "ubuntu") + ssh_pubkey = try(each.value.ssh_pubkey, var.defaults.ssh_pubkey, null) + user_data = try(each.value.user_data, var.defaults.user_data, null) + boot_disk = try(each.value.boot_disk, var.defaults.boot_disk, {}) + boot_disk_initialize_params = try(each.value.boot_disk_initialize_params, var.defaults.boot_disk_initialize_params, {}) + secondary_disks = try(each.value.secondary_disks, var.defaults.secondary_disks, []) + } From e0721cf39224cf585a69be71d6500eb32cc5510e Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Thu, 18 Jul 2024 16:44:25 +0700 Subject: [PATCH 3/7] chore: rename --- {wrapper => wrappers}/main.tf | 0 {wrapper => wrappers}/outputs.tf | 0 {wrapper => wrappers}/variables.tf | 0 {wrapper => wrappers}/versions.tf | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {wrapper => wrappers}/main.tf (100%) rename {wrapper => wrappers}/outputs.tf (100%) rename {wrapper => wrappers}/variables.tf (100%) rename {wrapper => wrappers}/versions.tf (100%) diff --git a/wrapper/main.tf b/wrappers/main.tf similarity index 100% rename from wrapper/main.tf rename to wrappers/main.tf diff --git a/wrapper/outputs.tf b/wrappers/outputs.tf similarity index 100% rename from wrapper/outputs.tf rename to wrappers/outputs.tf diff --git a/wrapper/variables.tf b/wrappers/variables.tf similarity index 100% rename from wrapper/variables.tf rename to wrappers/variables.tf diff --git a/wrapper/versions.tf b/wrappers/versions.tf similarity index 100% rename from wrapper/versions.tf rename to wrappers/versions.tf From 40bf39d0fe012af1ef9948bd49d742b89046a8bc Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Thu, 18 Jul 2024 16:46:52 +0700 Subject: [PATCH 4/7] fix: default value for secondary_disks --- wrappers/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/main.tf b/wrappers/main.tf index 4ed1bb9..e6186f0 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -38,6 +38,6 @@ module "wrapper" { user_data = try(each.value.user_data, var.defaults.user_data, null) boot_disk = try(each.value.boot_disk, var.defaults.boot_disk, {}) boot_disk_initialize_params = try(each.value.boot_disk_initialize_params, var.defaults.boot_disk_initialize_params, {}) - secondary_disks = try(each.value.secondary_disks, var.defaults.secondary_disks, []) + secondary_disks = try(each.value.secondary_disks, var.defaults.secondary_disks, null) } From 0389874a83617dbf0e2ade52e646cac7e39eb7ec Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Thu, 18 Jul 2024 22:21:04 +0700 Subject: [PATCH 5/7] fix: default value for secondary_disks --- variables.tf | 2 +- wrappers/main.tf | 3 +-- wrappers/outputs.tf | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/variables.tf b/variables.tf index d8b03b3..394e184 100644 --- a/variables.tf +++ b/variables.tf @@ -103,7 +103,7 @@ variable "serial_port_enable" { variable "docker_compose" { description = "The key in the VM metadata that uses the docker-compose specification" - default = null + default = null } # diff --git a/wrappers/main.tf b/wrappers/main.tf index e6186f0..ab5e3c6 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -38,6 +38,5 @@ module "wrapper" { user_data = try(each.value.user_data, var.defaults.user_data, null) boot_disk = try(each.value.boot_disk, var.defaults.boot_disk, {}) boot_disk_initialize_params = try(each.value.boot_disk_initialize_params, var.defaults.boot_disk_initialize_params, {}) - secondary_disks = try(each.value.secondary_disks, var.defaults.secondary_disks, null) - + secondary_disks = try(each.value.secondary_disks, var.defaults.secondary_disks, {}) } diff --git a/wrappers/outputs.tf b/wrappers/outputs.tf index ec6da5f..68f7aa3 100644 --- a/wrappers/outputs.tf +++ b/wrappers/outputs.tf @@ -1,5 +1,5 @@ output "wrapper" { description = "Map of outputs of a wrapper." value = module.wrapper - # sensitive = false # No sensitive module output found + sensitive = true } From d27963ea13d61454b437a83111d832a7f3b87f93 Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Wed, 31 Jul 2024 13:52:03 +0700 Subject: [PATCH 6/7] fix: add public_ip_address to wrapper --- wrappers/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/wrappers/main.tf b/wrappers/main.tf index ab5e3c6..bebf4d6 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -26,6 +26,7 @@ module "wrapper" { preemptible = try(each.value.preemptible, var.defaults.preemptible, false) placement_group_id = try(each.value.placement_group_id, var.defaults.placement_group_id, null) placement_affinity_rules = try(each.value.placement_affinity_rules, var.defaults.placement_affinity_rules, []) + public_ip_address = try(each.value.public_ip_address, var.defaults.public_ip_address, null) image_snapshot_id = try(each.value.image_snapshot_id, var.defaults.image_snapshot_id, null) image_id = try(each.value.image_id, var.defaults.image_id, null) image_family = try(each.value.image_family, var.defaults.image_family, "ubuntu-2004-lts") From df1fde30a46690c19f96ee3a3f60639a0140cfef Mon Sep 17 00:00:00 2001 From: Eugene Selivanov Date: Fri, 2 Aug 2024 12:42:20 +0700 Subject: [PATCH 7/7] fix: add defaults for ssh_user in wrapper --- wrappers/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/main.tf b/wrappers/main.tf index bebf4d6..94a7e2b 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -34,7 +34,7 @@ module "wrapper" { service_account_id = try(each.value.service_account_id, var.defaults.service_account_id, null) allow_stopping_for_update = try(each.value.allow_stopping_for_update, var.defaults.allow_stopping_for_update, true) generate_ssh_key = try(each.value.generate_ssh_key, var.defaults.generate_ssh_key, true) - ssh_user = try(each.value.ssh_user, var.defaults, "ubuntu") + ssh_user = try(each.value.ssh_user, var.defaults.ssh_user, "ubuntu") ssh_pubkey = try(each.value.ssh_pubkey, var.defaults.ssh_pubkey, null) user_data = try(each.value.user_data, var.defaults.user_data, null) boot_disk = try(each.value.boot_disk, var.defaults.boot_disk, {})