diff --git a/wrappers/main.tf b/wrappers/main.tf new file mode 100644 index 0000000..94a7e2b --- /dev/null +++ b/wrappers/main.tf @@ -0,0 +1,43 @@ +module "wrapper" { + source = "../" + + 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, []) + 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") + 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.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, {}) + 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, {}) +} diff --git a/wrappers/outputs.tf b/wrappers/outputs.tf new file mode 100644 index 0000000..68f7aa3 --- /dev/null +++ b/wrappers/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + sensitive = true +} diff --git a/wrappers/variables.tf b/wrappers/variables.tf new file mode 100644 index 0000000..a6ea096 --- /dev/null +++ b/wrappers/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/wrappers/versions.tf b/wrappers/versions.tf new file mode 100644 index 0000000..8e44575 --- /dev/null +++ b/wrappers/versions.tf @@ -0,0 +1,11 @@ +terraform { + required_providers { + yandex = { + source = "yandex-cloud/yandex" + } + tls = { + source = "hashicorp/tls" + } + } + required_version = ">= 1.3" +}