资源编排服务ROS(Resource Orchestration Service)提供了常用的模板示例,方便您快速地创建资源栈。本文将以通过模板示例创建一个ECS实例为例,为您介绍具体的操作方法。

操作步骤

  1. 登录资源编排控制台
  2. 在左侧导航栏,选择模板 > 模板示例
  3. 查找模板指定ImageId创建一个简单配置的ECS
  4. 可选:单击查看详情
    模板内容如下,默认为JSON格式。
    {
      "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.",
        "zh-cn": "阿里云资源编排模板示例:一个简单的ECS实例,在VPC中具有一个安全组和一个vSwitch。用户只需要指定镜像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>",
            "zh-cn": "实例镜像ID。详见:<b><a href='https://help.aliyun.com/document_detail/112977.html' target='_blank'><font color='blue'>查找镜像</font></a></b>"
          },
          "Label": {
            "en": "Image ID",
            "zh-cn": "镜像ID"
          },
          "Default": "centos_7"
        },
        "InstanceType": {
          "Type": "String",
          "Description": {
            "zh-cn": "填写vSwitch可用区下可使用的规格;<br>通用规格:<font color='red'><b>ecs.c5.large</b></font><br>注:部分可用区可能不支持通用规格<br>规格详见:<a href='https://help.aliyun.com/document_detail/25378.html' target='_blank'><b><font color='blue'>实例规格族</font></a></b>",
            "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",
            "zh-cn": "实例类型"
          },
          "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType"
        },
        "Password": {
          "NoEcho": true,
          "Type": "String",
          "Description": {
            "zh-cn": "长度8~30,必须包含大写字母、小写字母、数字、特殊符号三个;<br>特殊字符包括:()`~!@#$%^&*_-+=|{}[]:;'<>,.?/",
            "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",
            "zh-cn": "登录密码"
          },
          "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",
            "zh-cn": "已创建的ECS实例的实例ID"
          },
          "Value": {
            "Fn::GetAtt": [
              "WebServer",
              "InstanceId"
            ]
          }
        },
        "PublicIp": {
          "Description": {
            "en": "Public IP address of created ecs instance.",
            "zh-cn": "已创建的ECS实例的公网IP地址。"
          },
          "Value": {
            "Fn::GetAtt": [
              "WebServer",
              "PublicIp"
            ]
          }
        },
        "SecurityGroupId": {
          "Description": {
            "en": "Generated security group id for security group.",
            "zh-cn": "为安全组生成的安全组ID。"
          },
          "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
          }
        }
      }
    }
    模板结构说明:
    • ROSTemplateFormatVersion:模板的版本号。
    • Description:模板的描述信息。
    • Parameters:模板的参数。示例中定义了镜像ID和实例类型等参数。
    • Resources:模板所包含的阿里云资源。示例将创建一个ECS实例和一个安全组,资源属性将引用Parameters中定义的参数。
    • Outputs:资源创建完成后,输出的资源信息。示例将输出ECS实例的ID、公网IP和安全组ID。
  5. 单击创建资源栈
  6. 配置模板参数页面,输入资源栈名称,并设置以下参数。
    参数 说明 示例
    镜像ID ECS镜像ID,默认使用centos_7。

    更多信息,请参见镜像概述

    centos_7
    实例类型 ECS实例规格。

    请选用有效的实例规格。更多信息,请参见实例规格族

    ecs.r6e.large
    实例密码 ECS实例密码。 Test_12****
  7. 单击创建
    资源栈创建成功后,您可以查看资源栈的事件、资源和输出等信息。