Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper for terragrunt #49

Merged
merged 8 commits into from
Nov 2, 2024
Merged

Wrapper for terragrunt #49

merged 8 commits into from
Nov 2, 2024

Conversation

glavk
Copy link
Contributor

@glavk glavk commented Jul 19, 2024

Wrapper for terragrunt.
Example usage:

include {
  path = find_in_parent_folders()
}

locals {
  # Load the relevant env.hcl file based on where terragrunt was invoked. This works because find_in_parent_folders
  # always works at the context of the child configuration.
  folder_vars = read_terragrunt_config(find_in_parent_folders("folder.hcl"))

  environment = local.folder_vars.locals.environment

  folder_id = local.folder_vars.locals.folder_id

  labels = {
    managed-by  = "terraform"
    environment = local.environment
  }
}

dependency "vpc" {
  config_path = "${find_in_parent_folders("vpc")}/vpcs"
}

dependency "ip" {
  config_path = "${find_in_parent_folders("vpc")}/ip"
}

terraform {
  source = "git::https://github.com/terraform-yacloud-modules/terraform-yandex-instance.git//wrappers?ref=main"
}

inputs = {
  defaults = {
    labels             = local.labels
    serial_port_enable = true
    generate_ssh_key   = false

    zone     = "ru-central1-a"
    image_id = "fd870suu28d40fqp8srr" # ubuntu-2404-lts

    enable_nat = false
    create_pip = false

    core_fraction = 100

    ssh_user   = "ubuntu"
    ssh_pubkey = "${find_in_parent_folders("ssh_keys")}/ubuntu.pub"

    boot_disk = {
      auto_delete = true
      device_name = "boot-disk"
      mode        = "READ_WRITE"
    }

    folder_id = local.folder_id
  }

  items = {
    nfs-server-a = {
      name        = "nfs"
      description = "NFS server"

      hostname = "nfs"

      subnet_id = dependency.vpc.outputs.private_subnets["10.1.0.0/16"].subnet_id
      zone      = "ru-central1-a"

      cores  = local.nfs.cores
      memory = local.nfs.memory

      boot_disk_initialize_params = {
        size = local.nfs.disk_size
        type = local.nfs.disk_type
      }

      secondary_disks = local.nfs.secondary_disks

      labels = merge(local.labels, {
        service = "nfs"
      })
    },

    clickhouse1 = {
      name        = "clickhouse"
      description = "ClickHouse with keeper"

      hostname = "clickhouse"

      subnet_id = dependency.vpc.outputs.public_subnets["10.2.0.0/16"].subnet_id

      cores  = 12
      memory = 24

      boot_disk_initialize_params = {
        name = "clickhouse"
        size = 365
        type = "network-ssd"
      }

      secondary_disks = {
        backup = {
          type = "network-ssd-nonreplicated"
          size = 651

          labels = {
            managed-by = "terraform"
            component  = "clickhouse"
          }
        }
      }

      enable_nat = true

      labels = merge(local.labels, {
        service = "clickhouse"
      })
    }
  }
}

@glavk glavk self-assigned this Jul 19, 2024
@glavk glavk added the enhancement New feature or request label Jul 19, 2024
@glavk glavk marked this pull request as ready for review November 1, 2024 15:09
@glavk glavk merged commit ee9e9bb into main Nov 2, 2024
2 checks passed
@glavk glavk deleted the wrapper branch November 10, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants