{"id":50580804,"url":"https://github.com/terraform-ncloud-modules/terraform-ncloud-server","last_synced_at":"2026-06-05T02:01:12.238Z","repository":{"id":62090101,"uuid":"528542649","full_name":"terraform-ncloud-modules/terraform-ncloud-server","owner":"terraform-ncloud-modules","description":"Terraform module which creates Server resources on Naver Cloud Platform","archived":false,"fork":false,"pushed_at":"2022-12-22T07:44:05.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-02T21:26:05.392Z","etag":null,"topics":["navercloudplatform","ncloud-server","ncp","server","terraform","terraform-module"],"latest_commit_sha":null,"homepage":"https://registry.terraform.io/modules/terraform-ncloud-modules/server/ncloud","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terraform-ncloud-modules.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-24T18:14:41.000Z","updated_at":"2026-01-02T05:16:49.000Z","dependencies_parsed_at":"2023-01-30T06:01:25.778Z","dependency_job_id":null,"html_url":"https://github.com/terraform-ncloud-modules/terraform-ncloud-server","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/terraform-ncloud-modules/terraform-ncloud-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-ncloud-modules%2Fterraform-ncloud-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-ncloud-modules%2Fterraform-ncloud-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-ncloud-modules%2Fterraform-ncloud-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-ncloud-modules%2Fterraform-ncloud-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terraform-ncloud-modules","download_url":"https://codeload.github.com/terraform-ncloud-modules/terraform-ncloud-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraform-ncloud-modules%2Fterraform-ncloud-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33927313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["navercloudplatform","ncloud-server","ncp","server","terraform","terraform-module"],"created_at":"2026-06-05T02:01:11.341Z","updated_at":"2026-06-05T02:01:12.216Z","avatar_url":"https://github.com/terraform-ncloud-modules.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiple Server Module\n\n## **This version of the module requires Terraform version 1.3.0 or later.**\n\nThis document describes the Terraform module that creates multiple Ncloud Servers.\n\nYou can check below scenarios.\n\n- [Variable Declaration](#variable-declaration)\n- [Module Declaration](#module-declaration)\n- [image \u0026 product reference scenario](#image--product-reference-scenario)\n- [count \u0026 start_index reference scenario](#count--start_index-reference-scenario)\n\n\n## Variable Declaration\n\n### Structure : `variable.tf`\n\nYou need to create `variable.tf` and copy \u0026 paste the variable declaration below.\n\n**You can change the variable name to whatever you want.**\n\n``` hcl\nvariable \"servers\" {\n  type = list(object({\n    create_multiple = optional(bool, false)          // If true, create multiple servers with postfixes \"-001\", \"-002\"\n    count           = optional(number, 1)            // Required when create_multiple = true\n    start_index     = optional(number, 1)            // Required when create_multiple = true\n\n    name_prefix          = string                    // Same as \"name\" if create_multiple = false\n    description          = optional(string, \"\")\n    vpc_name             = string\n    subnet_name          = string\n    login_key_name       = string\n    init_script_id       = optional(string, null)\n    fee_system_type_code = optional(string, \"MTRAT\") // MTRAT (default) | FXSUM\n\n    server_image_name  = string                      // \"Image Name\" on \"terraform-ncloud-docs\"\n    product_generation = string                      // \"Gen\" on \"Server product\" page on \"terraform-ncloud-docs\"\n    product_type       = string                      // \"Type\" on \"Server product\" page on \"terraform-ncloud-docs\"\n    product_name       = string                      // \"Product Name\" on \"Server product\" page on \"terraform-ncloud-docs\"\n\n    is_associate_public_ip                 = optional(bool, false) // Can only be true if the subnet is a public subnet.\n    is_protect_server_termination          = optional(bool, false)\n    is_encrypted_base_block_storage_volume = optional(bool, false)\n\n    default_network_interface = object({\n      name_prefix           = string                 // \"name\" will be \"${name_prefix}-${name_postfix}\" if create_multiple = false\n      name_postfix          = string\n      description           = optional(string, \"\")\n      private_ip            = optional(string, null)              // IP address (not CIDR)\n      access_control_groups = optional(list(string), [\"default\"]) // default value is [\"default\"], \"default\" is the \"default access control group\".\n    })\n\n    additional_block_storages = optional(list(object({\n      name_prefix  = string                          // \"name\" will be \"${name_prefix}-${name_postfix}\" if create_multiple = false\n      name_postfix = string\n      description  = optional(string, \"\")\n      size         = number                          // Unit = GB\n      disk_type    = optional(string, \"SSD\")         // SSD (default) | HDD\n    })), [])\n  }))\n  default = []\n}\n\n```\n\n### Example : `terraform.tfvars`\n\nYou can create a `terraform.tfvars` and refer to the sample below to write the variable specification you want.\nFile name can be `terraform.tfvars` or anything ending in `.auto.tfvars`\n\n**It must exactly match the variable name above.**\n\n``` hcl\nservers = [\n  {\n    create_multiple = true\n    count           = 2\n    start_index     = 1\n\n    name_prefix          = \"svr-foo\"\n    description          = \"foo server\"\n    vpc_name             = \"vpc-foo\"\n    subnet_name          = \"sbn-foo-public-1\"\n    login_key_name       = \"key-workshop\"\n    fee_system_type_code = \"MTRAT\"\n\n    server_image_name  = \"CentOS 7.8 (64-bit)\"\n    product_generation = \"G2\"\n    product_type       = \"High CPU\"\n    product_name       = \"vCPU 2EA, Memory 4GB, [SSD]Disk 50GB\"\n\n    is_associate_public_ip                 = true\n    is_protect_server_termination          = false\n    is_encrypted_base_block_storage_volume = false\n\n    default_network_interface = {\n      name_prefix           = \"nic-foo\"\n      name_postfix          = \"def\"\n      description           = \"default nic for svr-foo\"\n      private_ip            = \"\"\n      access_control_groups = [\"default\", \"acg-foo-public\"]\n    }\n\n    additional_block_storages = [\n      {\n        name_prefix  = \"vol-foo\"\n        name_postfix = \"extra\"\n        description  = \"extra volume for svr-foo\"\n        disk_type    = \"SSD\"\n        size         = 20\n      }\n    ]\n  },\n  {\n    name_prefix    = \"svr-bar\"\n    description    = \"bar server\"\n    vpc_name       = \"vpc-bar\"\n    subnet_name    = \"sbn-bar-public\"\n    login_key_name = \"key-workshop\"\n\n    server_image_name  = \"CentOS 7.8 (64-bit)\"\n    product_generation = \"G2\"\n    product_type       = \"High CPU\"\n    product_name       = \"vCPU 2EA, Memory 4GB, [SSD]Disk 50GB\"\n\n    default_network_interface = {\n      name_prefix  = \"nic-bar\"\n      name_postfix = \"def\"\n      description  = \"default nic for svr-bar\"\n    }\n  }\n]\n```\n\n## Module Declaration\n\n### `main.tf`\n\nMap your `Server variable name` to a `local Server variable`. `Server module` are created using `local Server variables`. This eliminates the need to change the variable name reference structure in the `Server module`.\n\n``` hcl\nlocals {\n  servers = var.servers\n}\n```\n\n`Server module` is using `count` \u0026 `start_index` for server numbering. In order to simplify the list of variables in the server to be finally created, flattening should be done as shown below.\n\n``` hcl\nlocals {\n  flatten_servers = flatten([for server in local.servers :\n    [\n      for index in range(server.count) : merge(\n        { name = join(\"\", [server.name_prefix, server.create_multiple ? format(\"-%03d\", index + server.start_index) : \"\"]) },\n        { for attr_key, attr_val in server : attr_key =\u003e attr_val if(attr_key != \"default_network_interface\" \u0026\u0026 attr_key != \"additional_block_storages\") },\n        { default_network_interface = merge(server.default_network_interface, { name = join(\"\", [\n          server.default_network_interface.name_prefix, server.create_multiple ? format(\"-%03d\", index + server.start_index) : \"\", \"-${server.default_network_interface.name_postfix}\"]) })\n        },\n        { additional_block_storages = [for vol in server.additional_block_storages : merge(vol, { name = join(\"\", [\n          vol.name_prefix, server.create_multiple ? format(\"-%03d\", index + server.start_index) : \"\", \"-${vol.name_postfix}\"]) })]\n        }\n      )\n    ]\n  ])\n}\n\n```\n\nThen just copy \u0026 paste the module declaration below.\n\n``` hcl\n\nmodule \"servers\" {\n  source = \"terraform-ncloud-modules/server/ncloud\"\n\n  for_each = { for server in local.flatten_servers : server.name =\u003e server }\n\n  name                 = each.value.name\n  description          = each.value.description\n\n  // you can use \"vpc_name\" \u0026 \"subnet_name\". Then module will find \"subnet_id\" from \"DataSource: ncloud_subnet\".\n  vpc_name             = each.value.vpc_name\n  subnet_name          = each.value.subnet_name\n  // or use only \"subnet_id\" instead for inter-module reference structure.\n  # subnet_id            = module.vpcs[each.value.vpc_name].subnets[each.value.subnet_name].id\n\n  login_key_name       = each.value.login_key_name\n  init_script_id       = each.value.init_script_id\n  fee_system_type_code = each.value.fee_system_type_code\n\n  server_image_name  = each.value.server_image_name\n  product_generation = each.value.product_generation\n  product_type       = each.value.product_type\n  product_name       = each.value.product_name\n\n  is_associate_public_ip                 = each.value.is_associate_public_ip\n  is_protect_server_termination          = each.value.is_protect_server_termination\n  is_encrypted_base_block_storage_volume = each.value.is_encrypted_base_block_storage_volume\n\n  // you can use just \"default_network_interface\" variable as is.\n  default_network_interface = each.value.default_network_interface\n  // or add \"access_control_group_ids\" attribute to the value of the \"default_network_interface\" variable for inter-module reference structure.\n  default_network_interface = merge(each.value.default_network_interface, {\n    access_control_group_ids = [for acg_name in each.value.default_network_interface.access_control_groups : module.vpcs[each.value.vpc_name].access_control_groups[acg_name].id]\n  })\n\n  additional_block_storages = each.value.additional_block_storages\n}\n\n```\n\n## image \u0026 product reference scenario\n\nYou can find out values for server image \u0026 product on [terraform-ncloud-docs](https://github.com/NaverCloudPlatform/terraform-ncloud-docs/blob/main/docs/server_image_product.md). You must `Copy \u0026 Paste` values exactly.\n\n``` hcl\n//variable\nserver_image_name  = \"CentOS 7.8(64-bit)\"                     // \"Image Name\" on \"terraform-ncloud-docs\"\nproduct_generation = \"G2\"                                     // \"Gen\" on \"Server product\" page on \"terraform-ncloud-docs\"\nproduct_type       = \"High CPU\"                               // \"Type\" on \"Server product\" page on \"terraform-ncloud-docs\"\nproduct_name       = \"vCPU 2EA, Memory 4GB, [SSD]Disk 50GB\"   // \"Product Name\" on \"Server product\" page on \"terraform-ncloud-docs\"\n```\n\n! Argument `member_server_image` is not supported with this module for now. It will be update soon.\n\n## count \u0026 start_index reference scenario\n\n#### create_multiple = true\n\nIf you set as below\n\n``` hcl\ncreate_multiple = true\ncount           = 3\nstart_index     = 1    // if set this 2, it starts with 002 \n```\n\nthen\n\n- `server`\n\n``` hcl\nname_prefix = \"svr-foo\"\n==\u003e \nnames = [svr-foo-001, svr-foo-002, svr-foo-003]\n```\n\n- `default_network_interface`\n\n``` hcl\nname_prefix  = \"nic-foo\"\nname_postfix = \"def\"\n==\u003e\nnames = [nic-foo-001-def, nic-foo-002-def, nic-foo-003-def]\n```\n\n- `additional_block_storages`\n\n``` hcl\nname_prefix  = \"vol-foo\"\nname_postfix = \"extra\"\n==\u003e\nnames = [vol-foo-001-extra, vol-foo-002-extra, vol-foo-003-extra]\n```\n\n#### create_multiple = false\n\n- `server`\n\n``` hcl\nname_prefix = \"svr-bar\"\n==\u003e \nname = svr-bar\n```\n\n- `default_network_interface`\n\n``` hcl\nname_prefix  = \"nic-bar\"\nname_postfix = \"def\"\n==\u003e\nname = nic-bar-def\n```\n\n- `additional_block_storages`\n\n``` hcl\nname_prefix  = \"vol-bar\"\nname_postfix = \"extra\"\n==\u003e\nname = vol-bar-extra\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraform-ncloud-modules%2Fterraform-ncloud-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterraform-ncloud-modules%2Fterraform-ncloud-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraform-ncloud-modules%2Fterraform-ncloud-server/lists"}