Create resource stacks with a template

Last Updated: Jan 25, 2018

Resource Orchestration Service (ROS) allows you to create a set of Alibaba Cloud resources based on templates. ROS defines, manages, and maintains the created set of Alibaba Cloud resources as a stack. In this document, we use a simple ROS template to create a set of Alibaba Cloud resources, and then manage and maintain them through the ROS console.

ROS templates are JSON text files. You can declare and define your Alibaba Cloud Resources in the text, such as security groups, ECS, VPC, and RDS.

The ROS console offers some common sample templates. This example uses an existing sample template to create Alibaba Cloud resources.

  1. Log on to the ROS console.
  2. Click Sample Template from the left-side navigation pane, to go to the page that shows the sample templates available in ROS. Find the sample template, which meet your requirement. We take simple_ecs_instance as an example, and use it to create an ECS instance and add the ECS instance to a security group.

    <alt>sample template

  3. Two buttons, Preview and Create Stack, are displayed under the sample template. Click Preview to see the template in JSON format. The details of the simple_ecs_instance template are as follows:
    1. {
    2. "ROSTemplateFormatVersion" : "2015-09-01",
    3. "Description": " A simple ECS instance includes a security group. You only need to designate an imageID.",
    4. "Parameters" : {
    5. "ImageId": {
    6. "Type" : "String",
    7. "Default": "centos7u2_64_40G_cloudinit_20160728.raw",
    8. "Description": " The image file ID indicates the image resources selected when the instance was started. <a href='#/product/cn-shenzhen/list/imageList' target='_blank'>View Image Resources</a>"
    9. },
    10. "InstanceType": {
    11. "Type": "String",
    12. "Description": " Resource type of the instance ",
    13. "Default": "ecs.s1.small",
    14. "AllowedValues": [
    15. "ecs.t1.small",
    16. "ecs.s1.small",
    17. "ecs.s1.medium",
    18. "ecs.s1.large",
    19. "ecs.s2.small",
    20. "ecs.s2.large",
    21. "ecs.s2.xlarge",
    22. "ecs.s2.2xlarge",
    23. "ecs.s3.medium",
    24. "ecs.s3.large",
    25. "ecs.m1.medium",
    26. "ecs.m2.medium",
    27. "ecs.m1.xlarge",
    28. "ecs.c1.small",
    29. "ecs.c1.large",
    30. "ecs.c2.medium",
    31. "ecs.c2.large",
    32. "ecs.c2.xlarge"
    33. ]
    34. }
    35. },
    36. "Resources" : {
    37. "WebServer": {
    38. "Type": "ALIYUN::ECS::Instance",
    39. "Properties": {
    40. "ImageId" : {"Ref": "ImageId"},
    41. "InstanceType": {"Ref": "InstanceType"},
    42. "SecurityGroupId": {"Ref": "SecurityGroup"}
    43. }
    44. },
    45. "SecurityGroup": {
    46. "Type": "ALIYUN::ECS::SecurityGroup",
    47. }
    48. },
    49. "Outputs": {
    50. "InstanceId": {
    51. "Value" : {"Fn::GetAtt": ["WebServer","InstanceId"]}
    52. },
    53. "PublicIp": {
    54. "Value" : {"Fn::GetAtt": ["WebServer","PublicIp"]}
    55. },
    56. "SecurityGroupId": {
    57. "Value" : {"Fn::GetAtt": ["SecurityGroup","SecurityGroupId"]}
    58. }
    59. }
    60. }
    The JSON text contains five top-level fields:

    "ROSTemplateFormatVersion" : "2015-09-01" defines the template version.

    "Description": " A simple ECS instance includes a security group. You only need to designate an imageID" defines the template description.

    "Parameters" : { } defines certain template parameters. In this example, the parameters of imageID and instance type are defined, with their default values specified.

    "Resources" : { } defines the Alibaba Cloud resources this template is to create. This example declares the creation of an ECS instance and a security group. The resource attributes declared here can reference the values defined in Parameters.

    "Outputs": { } defines the output resource information when the resources are created. This example declares to output the ECS instance ID, public IP address, and security group ID.

  4. Click Create Stack to create a stack based on the template. Select a region according to your business requirement, and click Next in the bottom right corner.

    create stack

  5. Specify a unique stack name for the set of resources to be created, while you can other default options unchanged, and click Create.

    It takes some time for the system to create the resources.

    Input Parameters

  6. Click Stack Management from the left-side navigation pane to check the stack status and detail information.

    When a stack is successfully created, click Manage, and you can see the detailed information of the stack.

    overview

    On the Overview page, the values under Output are the values defined to be output in the template.

    On the Resource page, you can view information of all the resources in the stack.

    On the Event page, you can see what actions have been performed to this resource stack. If any action related to the resource stack fails, and which specific resource caused the failure, the information is recorded.

    On the Template section, you can see the template text of the resource stack.

    You can delete, update, recreate, and perform health check for the stack on the ROS console.

    Manage stack
Thank you! We've received your feedback.