# Manage Templates

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

---

Users can create and save a template that defines the infrastructure for use in stack creation. Refer to the concept and storage location of templates in [템플릿](/en/userguide/management/infrastructure_builder/overview/template/).

# Create a template {#write}

Templates are written in JSON or YAML format, defining the resources to be created, input values, and output values by section.

## Template format {#format}

Templates are written in JSON or YAML format. Since both formats represent the same structure, you can choose the format that is more convenient to write.


| Category | JSON | YAML |
|---------|--------|--------|
| Structure representation | Represent structure with curly braces (`{}`) and square brackets (`[]`). | Represent structure with indentation<ul><li>Use spaces for indentation; tab characters cannot be used</li></ul> |
| Comment | Not supported | Comments can be written after `#` |
| Built-in function notation | Write in full format<ul><li>Example: `{ "Ref": "VpcName" }`</li></ul> | Both full syntax and short syntax can be used<ul><li>Full syntax example: `Ref: VpcName`</li></ul><ul><li>Short syntax example: `!Ref VpcName`</li></ul> |

_Table. Template format comparison_


> **Reference**: In the Console's **Template Creation** page, clicking the code type button allows you to convert the written code to YAML or JSON format. For more details, refer to [템플릿 생성하기](#template-create).

## Template structure {#anatomy}

The template consists of multiple sections. Only the Resources section is mandatory, and the other sections can be optionally included as needed.


| section | Required or not | Explanation |
|---------|--------|--------|
| [SCPTemplateFormatVersion](#format-version) | Select | Version of the format that the template follows |
| [Description](#description) | Select | Description of the template |
| [Metadata](#metadata) | Select | Additional information about the template |
| [Parameters](#parameters) | Select | Input values when creating or updating a stack |
| [Rules](#rules) | Select | Rules for validating parameter values entered when creating or updating a stack |
| [Mappings](#mappings) | Select | Table of values that can be retrieved by key |
| [Conditions](#conditions) | Select | Conditions that determine whether a resource is created or its attribute values |
| [Resources](#resources) | Required | Resources to be created and their attributes |
| [Outputs](#outputs) | Select | Value to verify after creating the stack or to pass to another stack |

_Table. Template section_


> **Reference**: Transform section is not supported.

The following is the basic structure of the template that includes all sections. It is recommended to write the section in the order below.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: Description of the template
Metadata:
  Metadata definition
Parameters:
  Parameter definition
Rules:
  Rule definition
Mappings:
  Mapping definition
Conditions:
  Condition definition
Resources:
  Resource definition
Outputs:
  Result output definition
```

```json
{
  "SCPTemplateFormatVersion": "2026-01-01",
  "Description": "Description of the template",
  "Metadata": {
    Metadata definition
  },
  "Parameters": {
    Parameter definition
  },
  "Rules": {
    Rule definition
  },
  "Mappings": {
    Mapping definition
  },
  "Conditions": {
    Condition definition
  },
  "Resources": {
    Resource definition
  },
  "Outputs": {
    Result output definition
  }
}
```

_Code block. Template basic structure_

### Format version (SCPTemplateFormatVersion) {#format-version}

Specifies the version of the format that the template follows. The only supported value is `'2026-01-01'`, and it can be omitted.

* In YAML, wrap values in single quotes (`'`) to prevent date-formatted values from being interpreted as dates.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
```

_Code block. Example of format version creation_

### Description(Description) {#description}

Write a string that describes the purpose or composition of the template. The description can be up to 1,024 bytes.


```yaml
Description: 'Template that creates VPC and Subnet'
```

_Code block. Example of writing a description._

### Metadata(Metadata) {#metadata}

Defines additional information about the template. You can record information needed to manage the template, such as the template’s owner or purpose.


```yaml
Metadata:
  Owner: 'network-team'
  Purpose: 'Development environment network configuration'
```

_Code block. Metadata creation example_

#### Define Parameter Group {#parameter-group}

If you define the `SCP::InfrastructureBuilder::Interface` key in the metadata, the Console’s stack creation screen will group parameters together and let you specify a label to display instead of the parameter name.


| Category | Explanation |
|---------|--------|
| ParameterGroups | List of parameter groups<ul><li>`Label.default`: group name</li></ul><ul><li>`Parameters`: list of parameter names to include in the group</li></ul> |
| ParameterLabels | Label to display for each parameter<ul><li>`parameter name.default` specified in the format</li></ul> |

_Table. Parameter group components_



```yaml
Metadata:
  SCP::InfrastructureBuilder::Interface:
    ParameterGroups:
      - Label:
          default: 'Network Settings'
        Parameters:
          - VpcCidr
          - SubnetCidr
      - Label:
          default: 'Server Settings'
        Parameters:
          - ServerTypeId
          - KeypairName
    ParameterLabels:
      VpcCidr:
        default: 'VPC IP range'
      SubnetCidr:
        default: 'Subnet IP range'
```

_Code block. Example of creating a parameter group_

> **Reference**
>
> * Parameter groups are applied only on the stack creation screen in the Console and do not affect the creation or operation of the stack.
> * Parameters that are not included in any group are displayed separately outside the group.
> * If a parameter not defined in the template is assigned to a group, that parameter is ignored, and groups with no included parameters are not displayed.

### Parameter(Parameters) {#parameters}

Defines the values to be received as input when creating or updating a stack. By using parameters, you can input different values for each environment in a single template and reuse it.

Each parameter specifies the following attributes under its parameter name.


| attribute | Required or not | Explanation |
|---------|--------|--------|
| Type | Required | Parameter data type<ul><li>`String`: string</li></ul><ul><li>`Number`: number</li></ul><ul><li>`List<Number>`: list of numbers separated by commas</li></ul><ul><li>`CommaDelimitedList`: list of strings separated by commas</li></ul> |
| Default | Select | Default value to use when no value is entered<ul><li>If not specified, a value must be provided when creating or updating the stack</li></ul> |
| Description | Selection | Description of the parameter<ul><li>Displayed on the stack creation screen</li></ul> |
| AllowedValues | Select | List of values that can be entered<ul><li>applies to the `String`, `Number`, `CommaDelimitedList` types</li></ul><ul><li>If specified, you can select one of the items from the list in the Console and enter it</li></ul> |
| AllowedPattern | Select | Regular expression pattern that the input value must match<ul><li>`String`, `CommaDelimitedList` applied to the types</li></ul> |
| MinLength, MaxLength | Select | minimum and maximum length of the input value<ul><li>`String` type only applies</li></ul> |
| MinValue, MaxValue | Select | Minimum and maximum values of the input<ul><li>applies only to the `Number` type</li></ul> |
| NoEcho | Select | If set to `true`, the input value and the retrieved result are masked and displayed<ul><li>used for sensitive information such as passwords</li></ul> |
| ConstraintDescription | Select | Description to display instead of the default error message when the input violates a constraint<ul><li>In the Console's stack creation screen, replace all constraint violation messages (AllowedValues, AllowedPattern, length, value range) except required value errors with this description</li></ul> |

_Table. Parameter attributes_



```yaml
Parameters:
  EnvName:
    Type: String
    Default: dev
    AllowedValues:
      - dev
      - prod
    Description: 'Select the deployment environment.'
  VpcCidr:
    Type: String
    Default: '10.0.0.0/16'
    AllowedPattern: '^(\d{1,3}\.){3}\d{1,3}/\d{1,2}$'
    Description: 'Enter the VPC's IP range (CIDR).'
    ConstraintDescription: 'Must be entered in CIDR format (e.g., 10.0.0.0/16).'
  BootVolumeSize:
    Type: Number
    Default: 40
    MinValue: 40
    MaxValue: 200
    Description: 'Enter the boot volume size (GB).'
  UserPassword:
    Type: String
    NoEcho: true
    MinLength: 8
    Description: 'Enter the user password.'
  AllowedCidrs:
    Type: CommaDelimitedList
    Default: '10.0.0.0/16,192.168.0.0/24'
    Description: 'Enter the IP ranges to allow access, separated by commas.'
```

_Code block. Parameter creation example_

The defined parameters are referenced in the Resources and Outputs sections using `!Ref parameter name`. Parameters of list types (`List<Number>`, `CommaDelimitedList`) can be used by extracting a value at a specific position with `!Select` or concatenating them into a single string with `!Join`.

> **Reference**
>
> * A template can define up to 200 parameters, and each parameter value can be up to 4,096 bytes.
> * Do not write sensitive information such as passwords directly in the template; instead, receive it as a parameter with `NoEcho` specified.
> * Refer to [Create a stack](/en/userguide/management/infrastructure_builder/how_to_guides/#create) for how parameters are displayed in the Console when creating a stack.

### Rules(Rules) {#rules}

Validates whether the parameter values entered when creating or updating a stack meet the conditions. The value of a single parameter is validated using parameter attributes (AllowedValues, AllowedPattern, etc.), and combinations of multiple parameter values are validated by rules.

Each rule consists of the following elements.


| Category | Required or not | Explanation |
|---------|--------|--------|
| RuleCondition | Select | the condition to apply the rule<ul><li>if not specified, always apply the rule</li></ul> |
| Assertions | Required | List of validation items that the parameter value must satisfy |
| Assert | Required | The condition that must be true for each item of Assertions<ul><li>written as a function that returns true or false</li></ul> |
| AssertDescription | Select | The message displayed when validation fails for each item of Assertions |

_Table. Rule components_


The rules allow the use of the following function.


| Category | function |
|---------|--------|
| Condition function | `Fn::Equals`, `Fn::Not`, `Fn::And`, `Fn::Or` |
| Reference function | `Ref` |
| Rule-specific function | `Fn::Contains`, `Fn::EachMemberEquals`, `Fn::EachMemberIn` |

_Table. Functions that can be used in rules_


The rule-specific function is as follows.


| function | format | Explanation |
|---------|--------|--------|
| Fn::Contains | `Fn::Contains: [list of strings, string]` | Returns true if the specified string is contained in the list of strings. |
| Fn::EachMemberEquals | `Fn::EachMemberEquals: [list of strings, string]` | Returns true if all values in the string list are equal to the specified string. |
| Fn::EachMemberIn | `Fn::EachMemberIn: [list of strings, list of allowed values]` | Returns true if all values in the string list are included in the allowed values list. |

_Table. Rule-specific function_



```yaml
Rules:
  ProdServerType:
    RuleCondition: !Equals [!Ref EnvName, prod]
    Assertions:
      - Assert: !Not [!Equals [!Ref ServerTypeId, s1v1m2]]
        AssertDescription: 'The s1v1m2 server type cannot be used in a production environment.'
```

_Code block. Example of rule creation_

The above example validates that when the value of the EnvName parameter is `prod`, the ServerTypeId parameter cannot be set to `s1v1m2`. Rules are evaluated when creating or updating a stack, and if validation fails, the stack cannot be created or updated.

### Mapping(Mappings) {#mappings}

Define a table that can look up values by key. When you need to use different values depending on the environment or region, define the values as a mapping and retrieve them using a key.

A mapping consists of three steps: the mapping name, the top-level key, and the second key and value.


```yaml
Mappings:
  EnvironmentMap:
    dev:
      ServerTypeId: s1v1m2
    prod:
      ServerTypeId: s1v2m4
```

_code block. mapping creation example_

The value of a mapping is retrieved in the `!FindInMap [mapping name, top-level key, second key]` format. For example, `!FindInMap [EnvironmentMap, !Ref EnvName, ServerTypeId]` returns the server type ID based on the value of the EnvName parameter.

> **Reference**: A template can define up to 200 mappings, and each mapping can specify up to 200 mapping properties.

### Conditions(Conditions) {#conditions}

Defines a condition that evaluates to true or false based on parameter values, etc. Using conditions, you can specify whether resources are created or assign different property values in a single template based on the environment.

Conditions are defined using the `!Equals`, `!Not`, `!And`, `!Or` functions, and within a function you can use value reference functions such as `!Ref`. The defined condition is used as follows.

* If you specify a condition name in the resource's `Condition` property, the resource is created only when the condition is true.
* If you use the `!If` function, you can assign property values differently based on conditions.


```yaml
Conditions:
  IsProd: !Equals [!Ref EnvName, prod]

Resources:
  Vpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !If [IsProd, 'prod-vpc', 'dev-vpc']
      Cidrs: ['10.0.0.0/16']

  ProdPublicIp:
    Type: SCP::VPC::PublicIp
    Condition: IsProd
    Properties:
      Type: IGW
      Zone: 'kr-west1-a'
```

_Code block. Example of writing a condition._

In the above example, the Vpc resource’s name is set to `prod-vpc` if the EnvName parameter value is `prod`; otherwise, it is set to `dev-vpc`. The ProdPublicIp resource is created only when the value of the EnvName parameter is `prod`.

### Resources(Resources) {#resources}

Define the resources to be created and their properties. It is the only required section in the template, and you must define at least one resource.

Each resource consists of the following elements.


| Category | Required or not | Explanation |
|---------|--------|--------|
| Logical ID | Required | Name that identifies a resource within the template<ul><li>Can be up to 255 characters, using only letters and numbers</li></ul><ul><li>Must be unique within the template</li></ul><ul><li>Reference the resource by this name in other resources or output results</li></ul> |
| Type | Required | The type of resource to create<ul><li>`SCP::Service::Resource` specify in the format (e.g., `SCP::VPC::Vpc`)</li></ul><ul><li>Only resource types supported by Infrastructure Builder can be used</li></ul> |
| Properties | Required | Resource attributes<ul><li>The assignable attributes and required attributes differ for each resource type</li></ul><ul><li>Built-in functions can be used in attribute values</li></ul><ul><li>Nested stack resources (`SCP::InfrastructureBuilder::Stack`) can be omitted</li></ul> |

_Table. Resource components_



```yaml
Resources:
  Vpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Ref VpcName
      Cidrs: [!Ref VpcCidr]

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

_Code block. Example of resource creation_

In the above example, the Subnet resource references the Vpc resource’s ID with `!Ref Vpc`.

In addition to Type and Properties, you can specify the following attributes for a resource to control its creation conditions, order, and behavior upon deletion.


| attribute | Explanation |
|---------|--------|
| DependsOn | Create this resource after the specified resource has been created<ul><li>When specifying multiple resources, list them</li></ul> |
| Condition | Create the resource only when the specified condition is true<ul><li>Specify the condition name defined in the Conditions section</li></ul> |
| DeletionPolicy | Specify how the actual resource is handled when a resource is deleted from the stack<ul><li>`Delete`(default): delete the actual resource</li></ul><ul><li>`Retain`: the stack removes the resource but preserves the actual resource without deleting it</li></ul> |
| UpdateReplacePolicy | Specify how to handle existing resources when a resource is replaced during a stack update<ul><li>`Delete`(default): delete the existing resource</li></ul><ul><li>`Retain`: the stack removes the existing resource, but the actual resource is not deleted and is retained</li></ul> |

_Table. Resource attributes_



```yaml
Resources:
  InternetGateway:
    Type: SCP::VPC::InternetGateway
    Properties:
      Type: IGW
      VpcId: !Ref Vpc

  PublicIp:
    Type: SCP::VPC::PublicIp
    DependsOn: InternetGateway
    DeletionPolicy: Retain
    Properties:
      Type: IGW
      Zone: 'kr-west1-a'
```

_Code block. Example of writing resource properties._

In the above example, the PublicIp resource does not reference the InternetGateway resource, but because `DependsOn` is specified, it is created after the InternetGateway resource is created. Also, since the `DeletionPolicy` is set to `Retain`, the actual Public IP is not deleted and is retained even if the stack is deleted.

> **Reference**
>
> * Refer to the [Template Reference](/en/templatereference/) for available resource types and their attributes.
> * A template can define up to 500 resources.
> * Keypairs cannot be created from a template. Provide the name of the pre‑created Keypair as a parameter and reference it.
> * To create a stack with a template that includes IAM resources, you must approve the creation of IAM resources. In the Console, select the **Approve to allow Infrastructure Builder to create IAM resources.** option, and specify `CAPABILITY_IAM` in OpenAPI or CLI.
> * Resources retained with `Retain` are no longer managed by the stack. Delete unused resources directly in the respective service.

> **Caution**: If you change the logical ID of a resource in an already deployed stack, the existing resource may be deleted and a new resource may be created. Check the change type with the change set before modifying the logical ID.

### Result Output (Outputs) {#outputs}

Define the values to verify after creating the stack or to pass to another stack. The defined value can be viewed in the **Result Information** tab of the stack details.

Each result output specifies the following attributes under the output name.


| attribute | Required or not | Explanation |
|---------|--------|--------|
| Value | Required | value to be returned as output<ul><li>built-in functions that reference resources or parameters can be used</li></ul> |
| Description | Select | Explanation of the result output |
| Export | Select | When exporting a value so that it can be referenced from another stack, specify<ul><li>the export name in `Name`</li></ul><ul><li>The export name can use `!Sub` and `!Ref`, and only parameters and pseudo‑parameters can be referenced</li></ul> |

_Table. Result output attribute_



```yaml
Outputs:
  VpcId:
    Description: 'The ID of the created VPC.'
    Value: !Ref Vpc
    Export:
      Name: !Sub '${EnvName}-VpcId'
```

_Code block. Example of writing result output_

The exported value is referenced in another stack using `!ImportValue ExportName`.


```yaml
Resources:
  Subnet:
    Type: SCP::VPC::Subnet
    Properties:
      Name: 'app-subnet'
      VpcId: !ImportValue dev-VpcId
      Cidr: '10.0.2.0/24'
      Type: PRIVATE
      Category: PRIMARY
```

_Code block. Example of referencing exported values._

> **Reference**
>
> * A template can define up to 200 result outputs.
> * Export names can be up to 255 characters using letters, numbers, colons (:), and hyphens (-), and must be unique within the same Account and region.
> * The exported value can be up to 1,024 characters.
> * Exports can only be referenced from other stacks in the same account and region. For more details, refer to [내보내기](/en/userguide/management/infrastructure_builder/overview/template/#export).
> * Exports referenced in another stack cannot be deleted or modified.

## built-in function {#intrinsic-function}

Built-in functions are used within templates to reference the values of parameters or other resources, combine values, and evaluate conditions. In YAML, you can write using the short form with `!` instead of `Fn::`.

Built-in functions are classified as follows based on where they are used.


| Category | Usage location |
|---------|--------|
| value function | Location where you specify values such as resource attributes and result output |
| Condition function | Conditions section |
| Rule-specific function | Rules section<ul><li>For more details, see [규칙(Rules)](#rules)</li></ul> |

_Table. Built-in function classification_


### value function {#value-function}

The following are functions used when referencing or combining values.


| function | YAML shorthand syntax | Explanation |
|---------|--------|--------|
| Ref | `!Ref name` | Reference a parameter, resource, or pseudo‑parameter<ul><li>When referencing a parameter, it returns the input value</li></ul><ul><li>When referencing a resource, it returns the resource's identifier (ID or name, depending on the resource type)</li></ul><ul><li>When referencing a pseudo‑parameter, it returns its value (e.g., `!Ref SCP::Region`)</li></ul> |
| Fn::GetAtt | `!GetAtt LogicalID.Attribute` | Returns the attribute value of a resource<ul><li>Since a resource's identifier cannot be retrieved with `!GetAtt`, use `!Ref`</li></ul><ul><li>Example: `!GetAtt NetworkStack.Outputs.VpcId` (retrieve output from a nested stack)</li></ul> |
| Fn::Sub | `!Sub 'string'`<br>`!Sub ['string', {variable: value}]` | Replace `${name}` in the string with the value of a parameter, resource, or pseudo‑parameter<ul><li>Example: `!Sub '${EnvName}-vpc'`</li></ul><ul><li>If you also specify a variable map, you can use variables within the string</li></ul><ul><li>If you prefix with `!` as in `${!Literal}`, it is not substituted and `${Literal}` is used as‑is</li></ul> |
| Fn::Join | `!Join [delimiter, [value1, value2, ...]]` | Returns a string that joins a list of values with a delimiter<ul><li>Example: `!Join ['-', [!Ref EnvName, 'vpc']]`</li></ul> |
| Fn::Split | `!Split [delimiter, string]` | Returns a list split by the delimiter<ul><li>Example: `!Split [',', '10.0.1.0/24,10.0.2.0/24']`</li></ul> |
| Fn::Select | `!Select [index, list]` | Returns the value at the index position in the list<ul><li>Index starts at 0</li></ul><ul><li>Example: `!Select [0, !Ref AllowedCidrs]`</li></ul> |
| Fn::If | `!If [condition name, value when true, value when false]` | Returns one of two values based on the condition result<ul><li>Specify the condition name defined in the Conditions section</li></ul> |
| Fn::FindInMap | `!FindInMap [mapping name, top-level key, second key]` | Retrieve values from the mapping defined in the Mappings section |
| Fn::Base64 | `!Base64 string` | Returns the value of the string encoded in Base64<ul><li>Used for properties that require input of a Base64-encoded value, such as the UserData of a Virtual Server</li></ul> |
| Fn::ImportValue | `!ImportValue export name` | Return the value exported from another stack<ul><li>Can reference only exports from the same Account and Region</li></ul> |
| Fn::Cidr | `!Cidr [IP range, count, host bit size]` | Returns a list of CIDR blocks that split the specified IP range into the given number<ul><li>Supports IPv4 only</li></ul><ul><li>Example: `!Cidr ['10.0.0.0/16', 2, 8]` returns `10.0.0.0/24`, `10.0.1.0/24`</li></ul> |
| Fn::Length | `!Length list` | Return the number of items in the list |
| Fn::ToJsonString | `!ToJsonString object` | Convert an object or list to a JSON string and return it. |

_Table. Value function_


> **Reference**: For each resource type, see the [Template Reference](/en/templatereference/) for the identifiers returned by `!Ref` and the attributes you can retrieve with `!GetAtt`.

### Conditional function {#condition-function}

The following is a function used to define conditions in the Conditions section. Within condition functions, you can use value functions such as `!Ref`.


| function | YAML short form | Explanation |
|---------|--------|--------|
| Fn::Equals | `!Equals [value1, value2]` | Returns true if the two values are equal |
| Fn::Not | `!Not [condition]` | Returns false when the condition is true, and true when it is false. |
| Fn::And | `!And [condition1, condition2, ...]` | Returns true if all conditions are true |
| Fn::Or | `!Or [condition1, condition2, ...]` | Returns true if at least one condition is true. |

_Table. Condition function_


## Doctor parameter {#pseudo-parameter}

A pseudo-parameter is a parameter predefined by Infrastructure Builder that can be used without being separately defined in the template. Reference using `!Ref` or `!Sub`.


| Doctor parameter | return value |
|---------|--------|
| SCP::Region | Region where the stack is created |
| SCP::AccountId | Account ID where the stack is created |
| SCP::StackId | Stack ID |
| SCP::StackName | Stack name |
| SCP::Partition | partition<ul><li>`scp`</li></ul> |
| SCP::URLSuffix | URL suffix<ul><li>`samsungsdscloud.com`</li></ul> |
| SCP::NoValue | No value<ul><li>When used with `!If`, it is treated as not specifying the attribute depending on the condition</li></ul> |

_Table. Doctor parameter_



```yaml
Conditions:
  IsProd: !Equals [!Ref EnvName, prod]

Resources:
  Vpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Sub '${SCP::StackName}-vpc'
      Cidrs: ['10.0.0.0/16']

  PublicIp:
    Type: SCP::VPC::PublicIp
    Properties:
      Type: IGW
      Zone: 'kr-west1-a'
      Description: !If [IsProd, 'Production environment Public IP', !Ref SCP::NoValue]
```

_Code block. Example of writing a dummy parameter_

In the above example, the Vpc resource name is specified by appending `-vpc` to the stack name. The Description of the PublicIp resource is set only when the IsProd condition is true.

## Template creation example {#example}

The following is an example template that includes parameters, resources, and result output. Accepts an environment name, creates a VPC and subnet, and exports the ID of the created VPC.


```yaml
SCPTemplateFormatVersion: '2026-01-01'
Description: 'Template that creates VPC and Subnet'

Parameters:
  EnvName:
    Type: String
    Default: dev
    AllowedValues:
      - dev
      - prod
    Description: 'Select the deployment environment.'
  VpcCidr:
    Type: String
    Default: '10.0.0.0/16'
    Description: 'Enter the VPC IP range (CIDR).'
  SubnetCidr:
    Type: String
    Default: '10.0.1.0/24'
    Description: 'Enter the IP range (CIDR) of the Subnet.' (within VPC CIDR range)

Resources:
  Vpc:
    Type: SCP::VPC::Vpc
    Properties:
      Name: !Sub '${EnvName}-vpc'
      Cidrs: [!Ref VpcCidr]

  Subnet:
    Type: SCP::VPC::Subnet
    Properties:
      Name: !Sub '${EnvName}-subnet'
      VpcId: !Ref Vpc
      Cidr: !Ref SubnetCidr
      Type: PRIVATE
      Category: PRIMARY

Outputs:
  VpcId:
    Description: 'The ID of the created VPC.'
    Value: !Ref Vpc
    Export:
      Name: !Sub '${EnvName}-VpcId'
  SubnetId:
    Description: 'The ID of the created Subnet.'
    Value: !Ref Subnet
```

```json
{
  "SCPTemplateFormatVersion": "2026-01-01",
  "Description": "Template for creating VPC and Subnet",
  "Parameters": {
    "EnvName": {
      "Type": "String",
      "Default": "dev"
      "AllowedValues": ["dev", "prod"],
      "Description": "Select the deployment environment."
    },
    "VpcCidr": {
      "Type": "String",
      "Default": "10.0.0.0/16",
      "Description": "Enter the VPC's IP range (CIDR)."
    },
    "SubnetCidr": {
      "Type": "String",
      "Default": "10.0.1.0/24",
      "Description": "Enter the IP range (CIDR) of the Subnet." (within the VPC CIDR range)
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "SCP::VPC::Vpc"
      "Properties": {
        "Name": { "Fn::Sub": "${EnvName}-vpc" },
        "Cidrs": [{ "Ref": "VpcCidr" }]
      }
    },
    "Subnet": {
      "Type": "SCP::VPC::Subnet",
      "Properties": {
        "Name": { "Fn::Sub": "${EnvName}-subnet" },
        "VpcId": { "Ref": "Vpc" },
        "Cidr": { "Ref": "SubnetCidr" },
        "Type": "PRIVATE"
        "Category": "PRIMARY"
      }
    }
  },
  "Outputs": {
    "VpcId": {
      "Description": "The ID of the created VPC.",
      "Value": { "Ref": "Vpc" },
      "Export": {
        "Name": { "Fn::Sub": "${EnvName}-VpcId" }
      }
    },
    "SubnetId": {
      "Description": "The ID of the created Subnet."
      "Value": { "Ref": "Subnet" }
    }
  }
}
```

_code block. Template creation example_

> **Reference**: For service-specific usage examples, refer to the [Sample Template](/en/userguide/management/infrastructure_builder/sample_template/).

## Template limit {#limits}

Check the following limits when creating a template.


| Category | Limit |
|---------|--------|
| Description(Description) size | 1,024 bytes or less |
| Number of resources | Up to 500 per template |
| Logical ID length | Maximum 255 characters |
| Number of parameters | Up to 200 per template |
| Parameter value size | 4,096 bytes or less |
| Result count | Up to 200 per template |
| Export | Export name up to 255 characters, value up to 1,024 characters |
| Number of mappings | Up to 200 per template<ul><li>Each mapping can have up to 200 mapping properties</li></ul> |
| Template size | 51,200 bytes or less<ul><li>Object Storage URL, file upload, creation in the Console, etc., apply uniformly regardless of the template specification method</li></ul> |
| Nested stack depth | Maximum 5 steps |

_Table. Template limit_


Please refer to the [Constraints](/en/userguide/management/infrastructure_builder/overview/#constraints) for all constraints.

# Create Template {#template-create}

You can create it after directly writing and reviewing the template in the console. The created template is stored in the Object Storage bucket `ib-templates-{random 12-character string}-{region}`. For more details, please refer to [템플릿 저장 위치](/en/userguide/management/infrastructure_builder/overview/template/#location).
To create a template, follow these steps.

1. **All Services > Management > Infrastructure Builder** Click the menu. Navigate to the **Service Home** page.
2. **Service Home** page, click the **Stack > Stack List** menu. Navigate to the **Stack List** page.
3. Click the **Create Template** button on the **Stack List** page. Go to the **Create Template** page.
4. **Template Creation** page, select the code type and then write the template code.
    * You can choose **YAML** (default) or **JSON**.
    * Click the code type button to check for errors in the written code. If there are no errors, convert the existing code to the selected type; if there are errors, display the error message.
5. Click the **Review** button to verify the template's syntax and structure.
    * The **Review** button is enabled only when code has been entered.
    * If there is an error, check the error message and modify the template.
    * If there are no errors, a message indicating that the template is valid is displayed and the **Create** button is enabled.
6. Click the **Create** button. A confirmation popup is displayed.
7. In the popup, click the **Confirm** button. The template is created, and the template’s Object Storage URL is displayed in the top flash bar.
    * If creation fails, the current screen remains and an error message is displayed.

> **Reference**
>
> * If you do not click the **Create** button, the template will not be saved.
> * The template size can be up to 51,200 bytes.
> * If you do not have permission to create the Object Storage bucket to store the template, template creation will fail. For more details, please refer to [템플릿 저장 위치](/en/userguide/management/infrastructure_builder/overview/template/#location).
> * Refer to [Template Writing](#write) for guidance and examples on writing each section of the template. Refer to the [Template Reference](/en/templatereference/) for available resource types and properties.

# Configure a Nested Stack Template {#nested}

If the template becomes large and difficult to manage, you can separate it by functional units and configure it as a nested stack.

> **information**: The nested stack's template must be stored in Object Storage because it is referenced by URL. Nested stacks cannot be used with local file uploads.

To configure a nested stack, follow these steps.

1. Create sub-templates separated by functional units.
    * Define the value to be passed to the upper stack as the result output.
    * Define the value received from the upper stack as a parameter.
2. Save each created sub-template to Object Storage.
3. Create a root template that calls a subtemplate.
    * Define the substack as a `SCP::InfrastructureBuilder::Stack` resource.
    * Specify the URL of the subtemplate and pass the required values as parameters.
    * Referencing the output of a child stack automatically determines the creation order between stacks.
4. After storing the root template in Object Storage, create a stack using that template.

The `SCP::InfrastructureBuilder::Stack` resource can specify the following properties.


| attribute | Explanation |
|---------|--------|
| TemplateURL | Object Storage URL where the sub‑template is stored |
| Parameters | Value to pass to the subtemplate's parameter |
| TimeoutInMinutes | Substack task timeout (minutes) |

_Table. Nested stack resource properties_



```yaml
Resources:
  NetworkStack:
    Type: SCP::InfrastructureBuilder::Stack
    Properties:
      TemplateURL: '<네트워크 템플릿의 Object Storage URL>'
      Parameters:
        VpcCidr: '10.0.0.0/16'
      TimeoutInMinutes: 30

  AppStack:
    Type: SCP::InfrastructureBuilder::Stack
    Properties:
      TemplateURL: '<애플리케이션 템플릿의 Object Storage URL>'
      Parameters:
        VpcId: !GetAtt NetworkStack.Outputs.VpcId
```

_Code block. Root template creation example_

The result outputs of a nested stack are referenced in the `!GetAtt LogicalID.Outputs.OutputName` format. You can also write it in list format, like `!GetAtt [LogicalID, 'Outputs.OutputName']`.

In the above example, AppStack receives NetworkStack’s output (VpcId) as a parameter, so it is created after NetworkStack is created. The result outputs of a child stack can also be referenced in the root template’s result outputs (Outputs).

> **Reference**
>
> * The name of a child stack is automatically generated in the `{parent stack name}-{logical ID}-{8-character random identifier}` format.
> * Subtemplates are also validated in the same way as the parent template when creating a stack.
> * You can define up to 2,500 resources across the entire nested stack hierarchy, and up to 500 per template.

For detailed information about nested stack configuration, please refer to [Nested Stack](/en/userguide/management/infrastructure_builder/overview/template/#nested-stack). For an example of creating multiple Virtual Servers with a nested stack, refer to the [Create Multiple Virtual Servers at Once (Nested Stack)](/en/userguide/management/infrastructure_builder/sample_template/compute/#multi-instance) sample.
