• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Packer
  • Install
  • Tutorials
  • Documentation
  • Guides
  • Plugins
  • Try Cloud(opens in new tab)
  • Sign up
Packer Home

Plugins

Skip to main content
  • Plugins

      • Naver Cloud

  • Resources

  • Tutorial Library
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Packer
  3. Plugins
  4. Builders
  5. Naver Cloud
Community
v1.0.3

»NAVER CLOUD PLATFORM Builder

Type: ncloud Artifact BuilderId: ncloud.server.image

The ncloud builder allows you to create server images using the NAVER Cloud Platform.

Configuration Reference

Required:

  • access_key (string) - User's access key. Go to [Account Management > Authentication Key] to create and view your authentication key.

  • secret_key (string) - User's secret key paired with the access key. Go to [Account Management > Authentication Key] to create and view your authentication key.

  • server_image_product_code (string) - Product code of an image to create. (member_server_image_no is required if not specified)

Optional:

  • server_product_code (string) - Product (spec) code to create.

  • support_vpc (bool) - Whether to use VPC without specific vpc or subnet. Packer will try find public subnet in entire vpc if you set this value true. (You are required to least one three parameters if u want using VPC environment: support_vpc or vpc_no or subnet_no)

  • vpc_no (string) - The ID of the VPC where you want to place the Server Instance. If this field is left blank, Packer will try to get the VPC ID from the subnet_no or exists public subnet. (You are required to least one three parameters if u want using VPC environment: support_vpc or vpc_no or subnet_no)

  • subnet_no (string) - The ID of the Subnet where you want to place the Server Instance. This field is required if you are using an specific subnets. (You are required to least one three parameters if u want using VPC environment: support_vpc or vpc_no or subnet_no)

  • member_server_image_no (string) - Previous image code. If there is an image previously created, it can be used to create a new image. (server_image_product_code is required if not specified)

  • server_image_name (string) - Name of an image to create.

  • server_image_description (string) - Description of an image to create.

  • block_storage_size (number) - You can add block storage ranging from 10 GB to 2000 GB, in increments of 10 GB.

  • access_control_group_no (string) - This is used to allow winrm access when you create a Windows server. An ACG that specifies an access source (0.0.0.0/0) and allowed port (5985) must be created in advance if you use CLASSIC env. If this field is left blank, Packer will create temporary ACG for automatically in VPC environment.

  • user_data (string) - User data to apply when launching the instance. Note that you need to be careful about escaping characters due to the templates being JSON. It is often more convenient to use user_data_file, instead. Packer will not automatically wait for a user script to finish before shutting down the instance this must be handled in a provisioner.

  • user_data_file (string) - Path to a file that will be used for the user data when launching the instance.

  • region (string) - Name of the region where you want to create an image. (default: Korea)

    • values: Korea / US-West / HongKong / Singapore / Japan / Germany

Basic Example

Here is a basic example for windows server.

variable "access_key" {
  type    = string
  # default = "your_access_key"
}

variable "secret_key" {
  type    = string
  # default = "your_secret_key"
}

locals {
  timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}

source "ncloud" "example-windows" {
  access_key                            = "${var.access_key}"
  secret_key                            = "${var.secret_key}"
  server_image_product_code             = "SW.VSVR.OS.WND64.WND.SVR2016EN.B100" // for VPC environment.
  # server_image_product_code           = "SPSW0WINNTEN0016"  // for CLASSIC environment.
  server_image_name                     = "packer-${local.timestamp}"
  server_image_description              = "server image description"
  user_data                             = "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm quickconfig -q & sc config WinRM start= auto & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm get winrm/config/service\")"
  region                                = "Korea"
  support_vpc                           = true // Remove this if you use CLASSIC environment.
  # vpc_no                                = "{{YOUR_VPC_ID}}" // Remove this if you use CLASSIC environment.
  # subnet_no                             = "{{YOUR_SUBNET_ID}}" // Remove this if you use CLASSIC environment.
  communicator                          = "winrm"
  winrm_username                        = "Administrator"
  # access_control_group_no             = "{{YOUR_ACG_ID}}" // Specific ACG ID allowed port (5985) if you use CLASSIC environment.
}

build {
  sources = ["source.ncloud.example-windows"]

  provisioner "powershell" {
    inline = [
      "Write-Output 1,2,3 | Measure-Object"
    ]
  }
}
{
  "variables": {
    "ncloud_access_key": "{{env `NCLOUD_ACCESS_KEY`}}",
    "ncloud_secret_key": "{{env `NCLOUD_SECRET_KEY`}}"
  },
  "builders": [
    {
      "type": "ncloud",
      "access_key": "{{user `ncloud_access_key`}}",
      "secret_key": "{{user `ncloud_secret_key`}}",
      "server_image_product_code": "SPSW0WINNTEN0016",
      "server_image_name": "packer-test {{timestamp}}",
      "server_image_description": "server description",
      "user_data": "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm quickconfig -q & sc config WinRM start= auto & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm get winrm/config/service\")",
      "region": "Korea",
      "communicator": "winrm",
      "winrm_username": "Administrator"
    }
  ],
  "provisioners": [
    {
      "type": "powershell",
      "inline": ["Write-Output 1,2,3 | Measure-Object"]
    }
  ]
}

Warning: Please note that if you're setting up WinRM for provisioning, you'll probably want to turn it off or restrict its permissions as part of a shutdown script at the end of Packer's provisioning process. For more details on the why/how, check out this useful blog post and the associated code: https://cloudywindows.io/post/winrm-for-provisioning-close-the-door-on-the-way-out-eh/

Here is a basic example for linux server.

variable "access_key" {
  type    = string
  # default = "your_access_key"
}

variable "secret_key" {
  type    = string
  # default = "your_secret_key"
}

locals {
  timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}

source "ncloud" "example-linux" {
  access_key                = "${var.access_key}"
  secret_key                = "${var.secret_key}"
  server_image_product_code = "SW.VSVR.OS.LNX64.CNTOS.0708.B050" // for VPC environment.
  # server_image_product_code = "SPSW0LINUX000044" // for CLASSIC environment.
  server_image_name         = "packer-${local.timestamp}"
  server_image_description  = "server image description"
  region                    = "Korea"
  support_vpc               = true // Remove this if you use CLASSIC environment.
  # vpc_no                    = "{{YOUR_VPC_ID}}" // Remove this if you use CLASSIC environment.
  # subnet_no                 = "{{YOUR_SUBNET_ID}}" // Remove this if you use CLASSIC environment.
  communicator              = "ssh"
  ssh_username              = "root"
}

build {
  sources = ["source.ncloud.example-linux"]

  provisioner "shell" {
    inline = [
      "echo Connected via SSM at '${build.User}@${build.Host}:${build.Port}'"
    ]
  }
}
{
  "variables": {
    "ncloud_access_key": "{{env `NCLOUD_ACCESS_KEY`}}",
    "ncloud_secret_key": "{{env `NCLOUD_SECRET_KEY`}}"
  },
  "builders": [
    {
      "type": "ncloud",
      "access_key": "{{user `ncloud_access_key`}}",
      "secret_key": "{{user `ncloud_secret_key`}}",
      "server_image_product_code": "SPSW0LINUX000044",
      "server_image_name": "packer-test {{timestamp}}",
      "server_image_description": "server description",
      "region": "Korea",
      "communicator": "ssh",
      "ssh_username": "root"
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "echo Connected via SSM at '${build.User}@${build.Host}:${build.Port}'"
      ]
    }
  ]
}

Requirements for creating Windows images

You should include the following code in the Packer configuration file for provision when creating a Windows server.

  "builders": [
    {
      "type": "ncloud",
      ...
      "user_data":
        "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm quickconfig -q & sc config WinRM start= auto & winrm get winrm/config/service\")",
      "communicator": "winrm",
      "winrm_username": "Administrator"
    }
  ],
  "provisioners": [
    {
      "type": "powershell",
      "inline": [
        "$Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet /mode:vm \"/unattend:C:\\Program Files (x86)\\NBP\\nserver64.xml\" "
      ]
    }
  ]

Note

  • You can only create as many public IP addresses as the number of server instances you own. Before running Packer, please make sure that the number of public IP addresses previously created is not larger than the number of server instances (including those to be used to create server images).
  • When you forcibly terminate the Packer process or close the terminal (command) window where the process is running, the resources may not be cleaned up as the Packer process no longer runs. In this case, you should manually clean up the resources associated with the process.
Edit this page on GitHub

On this page

  1. NAVER CLOUD PLATFORM Builder
  2. Configuration Reference
  3. Basic Example
  4. Requirements for creating Windows images
  5. Note
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)