Skip to content

Commit

Permalink
Merge pull request #49 from terraform-yacloud-modules/wrapper
Browse files Browse the repository at this point in the history
Wrapper for terragrunt
  • Loading branch information
glavk authored Nov 2, 2024
2 parents 5ec8781 + e5dc2ad commit ee9e9bb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
43 changes: 43 additions & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
@@ -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, {})
}
5 changes: 5 additions & 0 deletions wrappers/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
output "wrapper" {
description = "Map of outputs of a wrapper."
value = module.wrapper
sensitive = true
}
11 changes: 11 additions & 0 deletions wrappers/variables.tf
Original file line number Diff line number Diff line change
@@ -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 = {}
}
11 changes: 11 additions & 0 deletions wrappers/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
tls = {
source = "hashicorp/tls"
}
}
required_version = ">= 1.3"
}

0 comments on commit ee9e9bb

Please sign in to comment.