You can create a stack by using a sample template and manage Alibaba Cloud resources by group in the Resource Orchestration Service (ROS) console. 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. Enter simple_ecs_instance in the search box and find the Specify ImageId to Create a Simple ECS Instance template.
  4. Optional:Click View Details. The template appears as a JSON file.
    The Specify ImageId to Create a Simple ECS Instance template contains the following content:
    {
      "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 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: a few 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
          }
        }
      }
    }
    The following section describes the template parameters:
    • ROSTemplateFormatVersion: the version 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, and the default values of these parameters are specified.
    • Resources: the Alibaba Cloud resources that can be created by using sample templates. 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 that is generated by ROS. 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, 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, click the Outputs tab to view the ECS instance ID, public IP address, and security group ID.