# Virtual Server

LLMS index: [llms.txt](https://docs.e.samsungsdscloud.com/en/userguide/management/llms.txt)

---

The Virtual Server sample template creates a Virtual Server. All samples create a VPC and Subnet together, and the Virtual Server uses a standard (public) image.

> **Reference**
>
> * Since the key pair for accessing the Virtual Server cannot be created with Infrastructure Builder, it must be created manually in advance. Enter the name of the key pair you created in the template's **KeypairName**.
> * You must enter the ID of the standard (public) image to use in **ImageId**. The image ID can be retrieved using the Virtual Server API's [ListImages](/apireference/compute/virtualserver/apis/listimages/1.6/).
> * The default values for **ServerTypeId** and **Zone** are example values. Update the values to match the region and image you are using.
> * Refer to the [Overview](/en/userguide/management/infrastructure_builder/overview/#constraints) for constraints.

# Virtual Server accessed via SSH (Security Group, key pair specified) {#server-keypair}

Create a Virtual Server by specifying a pre‑created key pair. VPC, Subnet, and Security Group are also created together, and the Virtual Server uses the created Subnet and Security Group.

* **ImageId** and **KeypairName** are required.
* An inbound rule for SSH (TCP 22) is added to the Security Group. Since the allowed range is `0.0.0.0/0` (all IPs), modify it to an IP range that should be permitted in the production environment.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Template for creating a Virtual Server (Compute) using a standard (shared) image'

Parameters:
  VpcName:
    Type: String
    Default: 'sample-vpc'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the VPC name. (3~20 characters, only English letters, numbers, and hyphens allowed)
  VpcCidr:
    Type: CommaDelimitedList
    Default: '10.0.0.0/16'
    Description: 'Enter the VPC's IP range (CIDR).' Separate multiple entries with commas. (prefix length /16 ~ /24)
  SubnetName:
    Type: String
    Default: 'sample-subnet'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the Subnet name.' (3~20 characters, only English letters, numbers, and hyphens allowed)
  SubnetCidr:
    Type: String
    Default: '10.0.1.0/24'
    Description: 'Enter the IP range (CIDR) of the Subnet.' (within the VPC CIDR range)
  SecurityGroupName:
    Type: String
    Default: 'sample-sg'
    MinLength: 1
    MaxLength: 255
    Description: 'Enter the Security Group name. (1~255 characters)
  ServerName:
    Type: String
    Default: 'sample-server'
    MinLength: 1
    MaxLength: 63
    AllowedPattern: '^[a-zA-Z0-9-_ ]*$'
    Description: 'Enter the Virtual Server name.' (1~63 characters, English letters/numbers/hyphen/underscore/space allowed)
  ImageId:
    Type: String
    MinLength: 1
    Description: 'Enter the standard (public) image ID to use with the Virtual Server.' (Check ID with ListImages API, required)
  KeypairName:
    Type: String
    MinLength: 1
    Description: 'Enter the key pair name to use for SSH connection. (required)
  ServerTypeId:
    Type: String
    Default: 's1v1m2'
    Description: 'Enter the Virtual Server type ID. (e.g.: s1v1m2. ※ Example value - modify to the type that matches the region/image)
  Zone:
    Type: String
    Default: 'kr-west1-a'
    Description: 'Enter the zone where the Virtual Server will be created. (e.g., kr-west1-a. ※ Example value - modify to the zone that matches the region)

Resources:
  MyVpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Ref VpcName
      Cidrs: !Ref VpcCidr

  MySubnet:
    Type: SCP::VPC::Subnet
    Properties:
      Name: !Ref SubnetName
      VpcId: !Ref MyVpc
      Cidr: !Ref SubnetCidr
      Type: PRIVATE
      Category: PRIMARY

  MySecurityGroup:
    Type: SCP::SecurityGroup::SecurityGroup
    Properties:
      Name: !Ref SecurityGroupName

  MySecurityGroupIngressSsh:
    Type: SCP::SecurityGroup::SecurityGroupRule
    Properties:
      SecurityGroupId: !Ref MySecurityGroup
      Direction: ingress
      Ethertype: IPv4
      Protocol: tcp
      PortRangeMin: 22
      PortRangeMax: 22
      RemoteIpPrefix: 0.0.0.0/0

  MyServer:
    Type: SCP::VirtualServer::VirtualServer
    Properties:
      Name: !Ref ServerName
      ImageId: !Ref ImageId
      KeypairName: !Ref KeypairName
      ServerTypeId: !Ref ServerTypeId
      Zone: !Ref Zone
      Networks:
        - SubnetId: !Ref MySubnet
      SecurityGroups:
        - !Ref MySecurityGroup
      BootVolume:
        Size: 40
        Type: SSD

Outputs:
  ServerId:
    Description: 'The ID of the generated Virtual Server.'
    Value: !Ref MyServer
```

_Code block. Virtual Server template for SSH access (Security Group, key pair specified)_

# Virtual Server connected to Public IP (Internet Gateway, Public IP) {#server-public-ip}

Create a Public IP and attach it to the Virtual Server's network. Creates a VPC, a public-type subnet, and an Internet Gateway together.

* **ImageId** and **KeypairName** are required.
* **PublicIpType** is selected from `IGW` (default), `GGW`, `SIGW`. `GGW` can be used only on Samsung Cloud Platform for Samsung, and `SIGW` can be used only on Samsung Cloud Platform for Enterprise.
* Public IP is configured with `DependsOn` to be created after the Internet Gateway is created.
* This sample does not assign a Security Group to the Virtual Server, so even if a Public IP is attached, it may not be accessible from outside. To access from outside, add a Security Group and inbound rules as in the [SSH로 접속하는 Virtual Server (Security Group, 키페어 지정)](#server-keypair) sample.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Template that creates a public IP (PublicIp) and connects it to a Virtual Server'

Parameters:
  VpcName:
    Type: String
    Default: 'sample-vpc'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the VPC name.' (3~20 characters, only English letters/numbers/hyphens allowed)
  VpcCidr:
    Type: CommaDelimitedList
    Default: '10.0.0.0/16'
    Description: 'Enter the VPC IP range (CIDR). Separate multiple entries with commas. (prefix length /16 ~ /24)
  SubnetName:
    Type: String
    Default: 'sample-subnet'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the Subnet name.' (3~20 characters, only English letters, numbers, and hyphens allowed)
  SubnetCidr:
    Type: String
    Default: '10.0.1.0/24'
    Description: 'Enter the IP range (CIDR) of the Subnet.' (within VPC CIDR range)
  ServerName:
    Type: String
    Default: 'sample-server'
    MinLength: 1
    MaxLength: 63
    AllowedPattern: '^[a-zA-Z0-9-_ ]*$'
    Description: 'Enter the Virtual Server name. (1~63 characters, English letters/numbers/hyphen/underscore/space allowed)
  ImageId:
    Type: String
    MinLength: 1
    Description: 'Enter the standard (public) image ID to use for the Virtual Server.' (Check ID with ListImages API, required)
  KeypairName:
    Type: String
    MinLength: 1
    Description: 'Enter the name of the key pair to use for SSH connection. (required)
  ServerTypeId:
    Type: String
    Default: 's1v1m2'
    Description: 'Enter the Virtual Server type ID. (e.g.: s1v1m2. ※ Example value - modify to the type that matches the region/image)
  Zone:
    Type: String
    Default: 'kr-west1-a'
    Description: 'Enter the zone where the Virtual Server and public IP will be created. (e.g., kr-west1-a. ※ Example value - modify to the zone that matches the region)
  PublicIpType:
    Type: String
    Default: 'IGW'
    AllowedValues:
      - IGW
      - GGW
      - SIGW
    Description: 'Select the public IP type.' (IGW/GGW/SIGW. GGW is for Samsung SCP, SIGW is exclusive to Enterprise SCP)

Resources:
  MyVpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Ref VpcName
      Cidrs: !Ref VpcCidr

  MySubnet:
    Type: SCP::VPC::Subnet
    Properties:
      Name: !Ref SubnetName
      VpcId: !Ref MyVpc
      Cidr: !Ref SubnetCidr
      Type: PUBLIC
      Category: PRIMARY

  MyPublicIp:
    Type: SCP::VPC::PublicIp
    DependsOn: MyInternetGateway
    Properties:
      Type: !Ref PublicIpType
      Zone: !Ref Zone

  MyInternetGateway:
    Type: SCP::VPC::InternetGateway
    Properties:
      Type: !Ref PublicIpType
      VpcId: !Ref MyVpc

  MyServer:
    Type: SCP::VirtualServer::VirtualServer
    Properties:
      Name: !Ref ServerName
      ImageId: !Ref ImageId
      KeypairName: !Ref KeypairName
      ServerTypeId: !Ref ServerTypeId
      Zone: !Ref Zone
      Networks:
        - SubnetId: !Ref MySubnet
          PublicIpId: !Ref MyPublicIp
      BootVolume:
        Size: 40
        Type: SSD

Outputs:
  ServerId:
    Description: 'The ID of the created Virtual Server.'
    Value: !Ref MyServer
  PublicIpId:
    Description: 'The ID of the generated public IP.'
    Value: !Ref MyPublicIp
```

_Code block. Virtual Server (Internet Gateway, Public IP) template with a Public IP attached._

# Virtual Server (UserData) that runs a script at boot {#userdata}

Pass the script to be executed when the server boots as UserData. VPC, Subnet, and Security Group are also created together.

* **ImageId**, **KeypairName**, **UserDataScript** must be provided.
* Enter the script to be executed as plain text in **UserDataScript**. In the template, encode with the `Fn::Base64` function and pass it; based on the encoded value, you can input up to 65,535 characters.
* An inbound rule for SSH (TCP 22) is added to the Security Group. Since the allowed target is `0.0.0.0/0` (all IPs), modify it to an IP range that should be permitted in the production environment.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Virtual Server creation template that uses a UserData bootstrap script'

Parameters:
  VpcName:
    Type: String
    Default: 'sample-vpc'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the VPC name.' (3~20 characters, only English letters/numbers/hyphens allowed)
  VpcCidr:
    Type: CommaDelimitedList
    Default: '10.0.0.0/16'
    Enter the VPC's IP range (CIDR). Separate multiple entries with commas. (prefix length /16 ~ /24)
  SubnetName:
    Type: String
    Default: 'sample-subnet'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the Subnet name.' (3~20 characters, only English letters, numbers, and hyphens allowed)
  SubnetCidr:
    Type: String
    Default: '10.0.1.0/24'
    Description: 'Enter the IP range (CIDR) of the Subnet.' (within the VPC CIDR range)
  SecurityGroupName:
    Type: String
    Default: 'sample-sg'
    MinLength: 1
    MaxLength: 255
    Description: 'Enter the Security Group name. (1~255 characters)
  ServerName:
    Type: String
    Default: 'sample-server'
    MinLength: 1
    MaxLength: 63
    AllowedPattern: '^[a-zA-Z0-9-_ ]*$'
    Description: 'Enter Virtual Server name. (1~63 characters, English letters/numbers/hyphen/underscore/space allowed)
  ImageId:
    Type: String
    MinLength: 1
    Description: 'Enter the standard (public) image ID to use for the Virtual Server.' (Check ID with ListImages API, required)
  KeypairName:
    Type: String
    MinLength: 1
    Description: 'Enter the name of the key pair to use for SSH connection.' (required)
  ServerTypeId:
    Type: String
    Default: 's1v1m2'
    Description: 'Enter the Virtual Server type ID.' (e.g. s1v1m2. ※ Example value - modify to the type that matches the region/image)
  Zone:
    Type: String
    Default: 'kr-west1-a'
    Description: 'Enter the zone where the Virtual Server will be created. (e.g., kr-west1-a. ※ Example value - modify to the zone that matches the region)
  UserDataScript:
    Type: String
    Description: 'Enter the bootstrap script (plain text) to be executed when the server boots.' (up to 65,535 characters based on base64 encoded value)

Resources:
  MyVpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Ref VpcName
      Cidrs: !Ref VpcCidr

  MySubnet:
    Type: SCP::VPC::Subnet
    Properties:
      Name: !Ref SubnetName
      VpcId: !Ref MyVpc
      Cidr: !Ref SubnetCidr
      Type: PRIVATE
      Category: PRIMARY

  MySecurityGroup:
    Type: SCP::SecurityGroup::SecurityGroup
    Properties:
      Name: !Ref SecurityGroupName

  MySecurityGroupIngressSsh:
    Type: SCP::SecurityGroup::SecurityGroupRule
    Properties:
      SecurityGroupId: !Ref MySecurityGroup
      Direction: ingress
      Ethertype: IPv4
      Protocol: tcp
      PortRangeMin: 22
      PortRangeMax: 22
      RemoteIpPrefix: 0.0.0.0/0

  MyServer:
    Type: SCP::VirtualServer::VirtualServer
    Properties:
      Name: !Ref ServerName
      ImageId: !Ref ImageId
      KeypairName: !Ref KeypairName
      ServerTypeId: !Ref ServerTypeId
      Zone: !Ref Zone
      UserData:
        Fn::Base64: !Ref UserDataScript
      Networks:
        - SubnetId: !Ref MySubnet
      SecurityGroups:
        - !Ref MySecurityGroup
      BootVolume:
        Size: 40
        Type: SSD

Outputs:
  ServerId:
    Description: 'The ID of the generated Virtual Server.'
    Value: !Ref MyServer
```

_Code block. Virtual Server (UserData) template that runs a script at boot._

# Create multiple Virtual Servers at once (nested stack) {#multi-instance}

Create multiple Virtual Servers with the same configuration using a root template and sub‑templates. The root template creates a VPC and Subnet, and calls the child template that creates one Virtual Server as a nested stack (`SCP::InfrastructureBuilder::Stack`) twice.

* First store the nested template in Object Storage, and then enter the nested template’s Object Storage URL in the root template’s **TemplateURL**.
* Templates that use nested stacks cannot be uploaded as local files. Save the root template to Object Storage, then enter its URL to create the stack.
* The root template's **ImageId** and **KeypairName** must be entered. The entered value is passed as a parameter to the child stack.
* The Virtual Server name is set to `sample-server-1`, `sample-server-2` in the root template. To create more Virtual Servers, add nested stack resources.
* The ID of each Virtual Server is returned as an output of the root template by referencing the child stack’s result output (ServerId) in the form `!GetAtt LogicalID.Outputs.ServerId`.
* This sample does not assign a Security Group to the Virtual Server. If needed, add a Security Group and inbound rules as shown in the [SSH로 접속하는 Virtual Server (Security Group, 키페어 지정)](#server-keypair) sample.

Please refer to [Configuring Nested Stack Templates](/en/userguide/management/infrastructure_builder/how_to_guides/template/#nested) for configuring nested stacks.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Template that deploys multiple identical Virtual Servers as nested stacks'

Parameters:
  VpcName:
    Type: String
    Default: 'sample-vpc'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the VPC name.' (3~20 characters, only English letters, numbers, and hyphens allowed)
  VpcCidr:
    Type: CommaDelimitedList
    Default: '10.0.0.0/16'
    Description: 'Enter the VPC IP range (CIDR).' Separate multiple entries with commas. (prefix length /16 ~ /24)
  SubnetName:
    Type: String
    Default: 'sample-subnet'
    MinLength: 3
    MaxLength: 20
    AllowedPattern: '^[a-zA-Z0-9-]*$'
    Description: 'Enter the Subnet name.' (3~20 characters, only English letters, numbers, and hyphens allowed)
  SubnetCidr:
    Type: String
    Default: '10.0.1.0/24'
    Description: 'Enter the IP range (CIDR) of the Subnet.' (within VPC CIDR range)
  ImageId:
    Type: String
    MinLength: 1
    Description: 'Enter the standard (public) image ID to use for the Virtual Server.' (Check ID with ListImages API, required)
  KeypairName:
    Type: String
    MinLength: 1
    Description: 'Enter the name of the key pair to use for SSH connection.' (required)
  ServerTypeId:
    Type: String
    Default: 's1v1m2'
    Description: 'Enter the Virtual Server type ID.' (e.g., s1v1m2. ※ Example value - modify to the type appropriate for the region/image)
  Zone:
    Type: String
    Default: 'kr-west1-a'
    Description: 'Enter the zone where the Virtual Server will be created.' (e.g., kr-west1-a. ※ Example value - modify to the zone that matches the region)

Resources:
  MyVpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Ref VpcName
      Cidrs: !Ref VpcCidr

  MySubnet:
    Type: SCP::VPC::Subnet
    Properties:
      Name: !Ref SubnetName
      VpcId: !Ref MyVpc
      Cidr: !Ref SubnetCidr
      Type: PRIVATE
      Category: PRIMARY

  Server1:
    Type: SCP::InfrastructureBuilder::Stack
    Properties:
      TemplateURL: '<하위 템플릿의 Object Storage URL>'
      Parameters:
        SubnetId: !Ref MySubnet
        ServerName: 'sample-server-1'
        ImageId: !Ref ImageId
        KeypairName: !Ref KeypairName
        ServerTypeId: !Ref ServerTypeId
        Zone: !Ref Zone

  Server2:
    Type: SCP::InfrastructureBuilder::Stack
    Properties:
      TemplateURL: '<하위 템플릿의 Object Storage URL>'
      Parameters:
        SubnetId: !Ref MySubnet
        ServerName: 'sample-server-2'
        ImageId: !Ref ImageId
        KeypairName: !Ref KeypairName
        ServerTypeId: !Ref ServerTypeId
        Zone: !Ref Zone

Outputs:
  VpcId:
    Description: 'The ID of the created VPC.'
    Value: !Ref MyVpc
  SubnetId:
    Description: 'The ID of the created Subnet.'
    Value: !Ref MySubnet
  Server1Id:
    Description: 'The ID of the first Virtual Server.'
    Value: !GetAtt Server1.Outputs.ServerId
  Server2Id:
    Description: 'The ID of the second Virtual Server.'
    Value: !GetAtt Server2.Outputs.ServerId
```

_Code block. Create multiple Virtual Servers at once (nested stack) - root template_


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'One Virtual Server deployed with a nested stack (subtemplate of a multi-instance creation sample)'

Parameters:
  SubnetId:
    Type: String
    Description: 'Enter the ID of the Subnet to create the Virtual Server.'
  ServerName:
    Type: String
    Default: 'sample-server'
    MinLength: 1
    MaxLength: 63
    Description: 'Enter the Virtual Server name.' (1~63 characters)
  ImageId:
    Type: String
    MinLength: 1
    Description: 'Enter the standard (public) image ID to use for the Virtual Server.' (Check ID with ListImages API, required)
  KeypairName:
    Type: String
    MinLength: 1
    Description: 'Enter the name of the key pair to use for SSH connection. (required)
  ServerTypeId:
    Type: String
    Default: 's1v1m2'
    Description: 'Enter the Virtual Server type ID.' (e.g.: s1v1m2)
  Zone:
    Type: String
    Default: 'kr-west1-a'
    Description: 'Enter the zone where the Virtual Server will be created. (e.g., kr-west1-a)

Resources:
  MyServer:
    Type: SCP::VirtualServer::VirtualServer
    Properties:
      Name: !Ref ServerName
      ImageId: !Ref ImageId
      KeypairName: !Ref KeypairName
      ServerTypeId: !Ref ServerTypeId
      Zone: !Ref Zone
      Networks:
        - SubnetId: !Ref SubnetId
      BootVolume:
        Size: 40
        Type: SSD

Outputs:
  ServerId:
    Description: 'The ID of the created Virtual Server.'
    Value: !Ref MyServer
```

_Code block. Create multiple Virtual Servers at once (nested stack) - child template_
