Resource Orchestration Service (ROS) provides common sample templates to help you create stacks. This topic describes how to create a stack by using a sample template. In this topic, an Elastic Compute Service (ECS) instance is created.

Procedure

  1. Log on to the ROS console.
  2. In the left-side navigation pane, choose Templates > Sample Templates.
  3. Find the Specify ImageId to Create a Simple ECS Instance template.
  4. Optional:Click View Details.
    The following section demonstrates the template content in the JSON format:
    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Description": {
        "en": "Alibaba Cloud ROS Sample Template: One simple ECS instance with a security group and a vSwitch in a VPC. The user only needs to specify the image ID.",
    
      },
      "Parameters": {
        "ImageId": {
          "Type": "String",
          "Description": {
            "en": "Instance Image ID. see detail: <b><a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>",
          },
          "Label": {
            "en": "Image ID",
          },
          "Default": "centos_7"
        },
        "InstanceType": {
          "Type": "String",
          "Description": {
            "en": "Fill in the specifications that can be used under the VSwitch availability zone;</b></font><br>general specifications: <font color='red'><b>ecs.c5.large</b></font><br>note: some zones do not support general specifications<br>see detail: <a href='https://www.alibabacloud.com/help/en/doc-detail/25378.html' target='_blank'><b><font color='blue'>Instance Specification Family</font></a></b>"
          },
          "Label": {
            "en": "Instance Type",
          },
          "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType"
        },
        "Password": {
          "NoEcho": true,
          "Type": "String",
          "Description": {
            "en": "The 8-30 long login password of instance, consists of the uppercase, lowercase letter and number. <br> special characters include()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
          },
          "AllowedPattern": "[0-9A-Za-z\\_\\-&:;'<>,=%`~!@#\\(\\)\\$\\^\\*\\+\\|\\{\\}\\[\\]\\.\\?\\/]+$",
          "Label": {
            "en": "Login Password",
          },
          "ConstraintDescription": "[8, 30] characters, consists of uppercase letter, lowercase letter, number or special characters.",
          "MinLength": 8,
          "MaxLength": 30
        }
      },
      "Resources": {
        "VSwitch": {
          "Type": "ALIYUN::ECS::VSwitch",
          "Properties": {
            "VpcId": {
              "Ref": "VPC"
            },
            "ZoneId": {
              "Fn::Select": [
                "0",
                {
                  "Fn::GetAZs": {
                    "Ref": "ALIYUN::Region"
                  }
                }
              ]
            },
            "CidrBlock": "192.168.0.0/16"
          },
          "Metadata": {
            "ALIYUN::ROS::Designer": {
              "id": "90648756-148d-4692-a3c6-3834c2c80f80"
            }
          }
        },
        "WebServer": {
          "Type": "ALIYUN::ECS::Instance",
          "Properties": {
            "VpcId": {
              "Ref": "VPC"
            },
            "SecurityGroupId": {
              "Ref": "SecurityGroup"
            },
            "VSwitchId": {
              "Ref": "VSwitch"
            },
            "ImageId": {
              "Ref": "ImageId"
            },
            "InstanceType": {
              "Ref": "InstanceType"
            },
            "Password": {
              "Ref": "Password"
            }
          },
          "Metadata": {
            "ALIYUN::ROS::Designer": {
              "id": "2b080610-ddab-43ba-b9ab-8e3223668692"
            }
          }
        },
        "VPC": {
          "Type": "ALIYUN::ECS::VPC",
          "Properties": {
            "CidrBlock": "192.168.0.0/16",
            "VpcName": "simple_ecs_vpc"
          },
          "Metadata": {
            "ALIYUN::ROS::Designer": {
              "id": "1361cd4d-7ff5-4c6d-9c26-3d089a644b0b"
            }
          }
        },
        "SecurityGroup": {
          "Type": "ALIYUN::ECS::SecurityGroup",
          "Properties": {
            "VpcId": {
              "Ref": "VPC"
            }
          },
          "Metadata": {
            "ALIYUN::ROS::Designer": {
              "id": "468cb29b-5bba-452e-95f4-4b331727204d"
            }
          }
        }
      },
      "Outputs": {
        "InstanceId": {
          "Description": {
            "en": "The instance id of created ECS instance",
          },
          "Value": {
            "Fn::GetAtt": [
              "WebServer",
              "InstanceId"
            ]
          }
        },
        "PublicIp": {
          "Description": {
            "en": "Public IP address of created ECS instance.",
          },
          "Value": {
            "Fn::GetAtt": [
              "WebServer",
              "PublicIp"
            ]
          }
        },
        "SecurityGroupId": {
          "Description": {
            "en": "Generated security group id for security group.",
          },
          "Value": {
            "Fn::GetAtt": [
              "SecurityGroup",
              "SecurityGroupId"
            ]
          }
        }
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "90648756-148d-4692-a3c6-3834c2c80f80": {
            "size": {
              "width": 129,
              "height": 140
            },
            "position": {
              "x": 212,
              "y": 90
            },
            "z": 1,
            "embeds": [
              "2b080610-ddab-43ba-b9ab-8e3223668692"
            ]
          },
          "1361cd4d-7ff5-4c6d-9c26-3d089a644b0b": {
            "size": {
              "width": 309,
              "height": 194
            },
            "position": {
              "x": 193,
              "y": 63
            },
            "z": 0,
            "embeds": [
              "90648756-148d-4692-a3c6-3834c2c80f80",
              "468cb29b-5bba-452e-95f4-4b331727204d"
            ]
          },
          "2b080610-ddab-43ba-b9ab-8e3223668692": {
            "size": {
              "width": 60,
              "height": 60
            },
            "position": {
              "x": 250,
              "y": 130
            },
            "z": 2
          },
          "468cb29b-5bba-452e-95f4-4b331727204d": {
            "size": {
              "width": 60,
              "height": 60
            },
            "position": {
              "x": 406,
              "y": 130
            },
            "z": 1
          },
          "e776abde-ad3c-4a8d-a999-93fbd2fa37e6": {
            "source": {
              "id": "2b080610-ddab-43ba-b9ab-8e3223668692"
            },
            "target": {
              "id": "468cb29b-5bba-452e-95f4-4b331727204d"
            },
            "z": 1
          }
        }
      }
    }
    Template structure:
    • ROSTemplateFormatVersion: the version number of the template.
    • Description: the description of the template.
    • Parameters: the parameters of the template. In this example, parameters such as ImageId and InstanceType are defined.
    • Resources: the Alibaba Cloud resources included in the template. In this example, an ECS instance and a security group are created, and parameters defined in the Parameters section are referenced as resource properties.
    • Outputs: the information of created resources. In this example, the ECS instance ID, public IP address, and security group ID are defined as outputs.
  5. Click Create Stack.
  6. In the Configure Template Parameters step of the Use New Resources (Standard) wizard, set Stack Name and the following parameters.
    Parameter Description Example
    Image ID The image ID of the ECS instance. By default, centos_7 is used.

    For more information, see Image overview.

    centos_7
    Instance Type The instance type of the ECS instance.

    Select a valid instance type. For more information, see Instance families.

    ecs.r6e.large
    Login Password The password that is used to log on to the ECS instance. Test_12****
  7. Click Create.
    After the stack is created, you can view information such as events, resources, and outputs of the stack.