Document navigation

CloudFormation

Overview

ZStack Cloud CloudFormation is a service that helps you simplify the cloud computing resource management and automate the deployment and O&M. With a resource stack template, you can define what cloud resources you need, the dependency between the resources, and the resource configuration. With the CloudFormation engine, CloudFormation can provide automatic batch deployment and resource configuration, as well as easy lifecycle management of cloud resources. You can also use API and SDK to integrate the automatic O&M capabilities.

As shown in Figure 1.
Figure 1. CloudFormation


The advantages of CloudFormation are as follows:
  1. You only need to create a stack template or modify an existing one to define what cloud resources you need, the dependency between the resources, and the resource configuration. With the CloudFormation engine, CloudFormation will automatically complete the creation and configuration of all resources.
  2. The Cloud provides sample templates and a designer to create stack templates quickly.
  3. You can dynamically update a stack template based on your business needs, and then you can update the related resource stack to flexibly meet the needs of business development.
  4. If you no longer need a resource stack, you can simply one-click delete it, which also deletes all of the resources in the stack.
  5. You can reuse an existing stack template to quickly duplicate all stack resources without repeated configuration.
  6. You can flexibly combine cloud services based on different scenarios to meet the needs of automatic maintenance.

Inventory

Resource Stack Inventory

Name Description Optional Valid Value Starting Version
uuid The UUID. For more information, see Resource Property. 2.5.0
name The name. For more information, see Resource Property. 2.5.0
description The description. For more information, see Resource Property. Yes 2.5.0
version The stack version. 2.5.0
type The stack type. Default type: zstack.
  • zstack
2.5.0
templateContent The stack content, which is a JSON string. Yes 2.5.0
paramContent The parameters in the stack. The parameters are JSON strings. 2.5.0
status The stack status. 2.5.0
reason The reason for stack creation failure. Yes 2.5.0
enableRollback Whether to roll back if stack creation fails. 2.5.0
groupBy Groups rows into subgroups based on values of columns or expressions. This field is equivalent to the Group By clause in MySQL, such as groupBy=type. Yes 2.5.0
createDate The creation date. For more information, see Resource Property. 2.5.0
lastOpDate The last operation date. For more information, see Resource Property. 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0

Sample

{
    "inventories": [
        {
            "createDate": "Jun 28, 2018 1:44:13 PM",
            "enableRollback": true,
            "lastOpDate": "Jun 28, 2018 1:44:22 PM",
            "name": "EIP",
            "paramContent": "{"InstanceOfferingUuid":"87dd7bae500f4273a9241751d0542a65","ImageUuid":"4f04a5e91d075a9cb72131da51eeb62b","PrivateNetworkUuid":"f88ccf4ece2a46e793b2d55b9c07b905","PublicNetworkUuid":"4373fceca7334974aeaac17007e17ec3","RootDiskOfferingUuid":"aee7c2ce77754134809caa8dbea49ecf"}",
            "status": "Created",
\n}", } } "Ref": "VmInstance"etAtt":[{"Fn::Select":[0,{"Fn::GetAtt":["VmInstance","vmNics"]}]},"uuid"]}
            "type": "zstack",
            "uuid": "36ed397d1ce847fcb3faa95decce7898",
            "version": "2018-06-18"
        }
    ],
    "success": true
}

Stack Template Inventory

Name Description Optional Valid Value Starting Version
uuid The UUID. For more information, see Resource Property. 2.5.0
name The name. For more information, see Resource Property. 2.5.0
description The description. For more information, see Resource Property. Yes 2.5.0
type The template type. Default type: zstack.
  • zstack
2.5.0
version The template version. 2.5.0
state Whether to enable the template. 2.5.0
content The template content, which is a JSON string. 2.5.0
groupBy Groups rows into subgroups based on values of columns or expressions. This field is equivalent to the Group By clause in MySQL, such as groupBy=type. Yes 2.5.0
createDate The creation date. For more information, see Resource Property. 2.5.0
lastOpDate The last operation date. For more information, see Resource Property. 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0

Sample

{
    "inventories": [
        {
            "content": "{  "ZStackTemplateFormatVersion" : "2018-06-18",  "Description": "Example for create a group vm instance in zstack.",  "Parameters" : {    "imageUuid": {      "Type" : "String",      "Description": "Image Uuid, represents the image resource to startup one vm instance\ntest enter"    },    "instanceOfferingUuid": {      "Type": "String",      "Description": "The instance offering uuid"    },    "l3NetworkUuid": {      "Type": "String",      "Description": "The l3 network uuid"    }  },  "Resources" : {    "WebServer1": {      "Type": "ZStack::Resource::VmInstance",      "Properties": {        "name" : "vm",        "description": "test\nenter",        "imageUuid" : {"Ref": "imageUuid"},        "instanceOfferingUuid":  {"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wL2xubXAxLjQudGFyLmd6IC1vIGxubXAxLjQudGFyLmd6ICYmIHRhciB6eGYgbG5tcDEuNC50YXIuZ3ogJiYgY2QgbG5tcDEuNCAmJiBlY2hvICIifC4vaW5zdGFsbC5zaCBsbm1w"]      }    }  },  "Outputs": {    "VmInstance": {      "Description" : "print vm instance",      "Value" : {"Ref": "WebServer1"}    }  }}",
            "createDate": "Jun 27, 2018 7:59:07 PM",
            "lastOpDate": "Jun 27, 2018 7:59:07 PM",
            "name": "userdata",
            "state": true,
            "type": "zstack",
            "uuid": "94cd225aa6c348edbfd2fb1ca7ec50f7",
            "version": "2018-06-18"
        },
        {
\n}", } } "Ref": "VmInstance"etAtt":[{"Fn::Select":[0,{"Fn::GetAtt":["VmInstance","vmNics"]}]},"uuid"]}
            "createDate": "Jun 27, 2018 5:21:19 PM",
            "lastOpDate": "Jun 27, 2018 7:15:48 PM",
            "name": "ć»șEIP",
            "state": true,
            "type": "zstack",
            "uuid": "a427e49177a7426eadeef2e10b89efaf",
            "version": "2018-06-18"
        }
    ],
    "success": true
}

Resource Stack Event Inventory

Name Description Optional Valid Value Starting Version
id The event ID. 2.5.0
description The detailed description of the resource. Yes 2.5.0
action The event name. 2.5.0
content The event parameters. 2.5.0
resourceName The resource name. 2.5.0
actionStatus The action status. 2.5.0
stackUuid The stack UUID. 2.5.0
duration The event duration. Yes 2.5.0
groupBy Groups rows into subgroups based on values of columns or expressions. This field is equivalent to the Group By clause in MySQL, such as groupBy=type. Yes 2.5.0
createDate The creation date. For more information, see Resource Property. 2.5.0
lastOpDate The last operation date. For more information, see Resource Property. 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0

Sample

{
    "inventories": [
        {
            "action": "CreateVmInstanceAction",
            "actionStatus": "Start",
            "content": "{\n  "l3NetworkUuids": [\n    "f88ccf4ece2a46e793b2d55b9c07b905"\n  ],\n  "name": "EIP-VM",\n  "instanceOfferingUuid": "87dd7bae500f4273a9241751d0542a65",\n  "imageUuid": "4f04a5e91d075a9cb72131da51eeb62b",\n  "rootDiskOfferingUuid": "aee7c2ce77754134809caa8dbea49ecf"\n}",
            "createDate": "Jun 28, 2018 1:44:13 PM",
            "id": 11,
            "lastOpDate": "Jun 28, 2018 1:44:13 PM",
            "resourceName": "VmInstance",
            "stackUuid": "36ed397d1ce847fcb3faa95decce7898"
        },
    ],
    "success": true
}

Operations

AddStackTemplate

Adds a stack template. For example,
AddStackTemplate name=userdata
templateContent="{  \"ZStackTemplateFormatVersion\" : \"2018-06-18\",  \"Description\": \"Example for create a group vm instance in zstack.\",
  \"Parameters\" : {    \"imageUuid\": {      \"Type\" : \"String\",      \"Description\": \"Image Uuid,
 represents the image resource to startup one vm instance\ntest enter\"    },    \"instanceOfferingUuid\":
 {      \"Type\": \"String\",      \"Description\": \"The instance offering uuid\"    },    \"l3NetworkUuid\": {      \"Type\": \"String\",
\"Description\": \"The l3 network uuid\"    }  },  \"Resources\" : {    \"WebServer1\": {      \"Type\": \"ZStack::Resource::VmInstance\",
\"Properties\": {        \"name\" : \"vm\",        \"description\": \"test\\nenter\",        \"imageUuid\" : {\"Ref\": \"imageUuid\"},
\"instanceOfferingUuid\":  {\"Ref\": \"instanceOfferingUuid\"},        \"l3NetworkUuids\": [{\"Ref\": \"l3NetworkUuid\"}],
\"systemTags\": [\"userdata::I2Nsb3VkLWNvbmZpZwp1c2VyczoKIC0gbmFtZTogcm9vdAogICBzaGVsbDogL2Jpbi9iYXNoCiAgIGdyb3Vwczogcm9vdAogICBzdWRvOiBbJ0FMTD0oQUxMKSBOT1BBU1NXRDpBTEwnXQogICBzc2gtYXV0aG9yaXplZC1rZXlzOgogICAgICAgLSBzc2gtcnNhIEFBQUFCM056YUMxeWMyRUFBQUFEQVFBQkFBQUJBUURmZ2dMQVRrM0prVW5uazczT1F6b1dOdzN4UFdtb1FNVjV6bUZWekEwYVFyWHZoT00xakk3bXJiLzdKVTJTK0t3Nm1xUFp5QVUvTWg3WEc5Smw4REh3NzJEZWlzOEVWYm8yanA5dkU1dHRmdXY0K3Rvb1o2Sm9STVNDOEdvcGlkd2RZYWw3Y3o2Vk9TYzgyWkFyR3VlVUxzMzFqWEUzclIxNk96V0tTRzFVL1RsbXA5V0Rlamxyd1dZMCtPZzA4WHBORWVjMnFkUnpvV3lHMHJ5WEpDbUQrdmxCSXErWnVMQVRMZWZQUk1uNGZOVlROM1JmZ0Q0aVEvR2Jaa3RJK1BwZ1ppRkdMVW0zVnJwMjNJckVzSTdjUkszV01lZ2RNSlVrQmFzR05STjB1d082OXNvM3lBbi9NZTZ0b1hmd2JOaC9MWEpPRkh2RFo5bmtscWwydnA0MyByb290QDEwLjAuMTIxLjE3NQp3cml0ZV9maWxlczoKIC0gcGF0aDogL3RtcC9aU3RhY2tfY29uZmlnCiAgIGNvbnRlbnQ6IHwKICAgICAgIEhlbGxvLHdvcmxkIQpob3N0bmFtZToga292ZW4tdGVzdApkaXNhYmxlX3Jvb3Q6IGZhbHNlCmNocGFzc3dkOgogIGxpc3Q6IHwKICAgICAgcm9vdDpwYXNzd29yZAogIGV4cGlyZTogRmFsc2UKcnVuY21kOgogLSBjdXJsIGh0dHA6Ly9zb2Z0LnZwc2VyLm5ldC9sbm1wL2xubXAxLjQudGFyLmd6IC1vIGxubXAxLjQudGFyLmd6ICYmIHRhciB6eGYgbG5tcDEuNC50YXIuZ3ogJiYgY2QgbG5tcDEuNCAmJiBlY2hvICIifC4vaW5zdGFsbC5zaCBsbm1w\"]      }    }  },
\"Outputs\": {    \"VmInstance\": {      \"Description\" : \"print vm instance\",      \"Value\" : {\"Ref\": \"WebServer1\"}    }  }}"

Parameters

Name Description Optional Valid Value Starting Version
name The resource name. 2.5.0
description The detailed description of the resource. Yes 2.5.0
type The template type. Default type: zstack. Yes
  • zstack
2.5.0
templateContent The template content, which is a JSON string. 2.5.0
resourceUuid The resource UUID. Yes 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

DeleteStackTemplate

Deletes a stack template. For example,
DeleteStackTemplate uuid=a427e49177a7426eadeef2e10b89efaf

Parameters

Name Description Optional Valid Value Starting Version
uuid The resource UUID.
deleteMode Yes
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

QueryStackTemplate

Queries a stack template. For example,
QueryStackTemplate uuid=a427e49177a7426eadeef2e10b89efaf

Primitive Fields of Query

See Stack Template Inventory.

UpdateStackTemplate

Updates a stack template. For example,
UpdateStackTemplate uuid=a427e49177a7426eadeef2e10b89efaf name=StackTemplate

Parameters

Name Description Optional Valid Value Starting Version
uuid The template UUID. 2.5.0
name The resource name. Yes 2.5.0
description The detailed description of the resource. Yes 2.5.0
state Whether the template is available. Yes 2.5.0
templateContent The template content, which is a JSON string. Yes 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

GetSupportedCloudFormationResources

Obtains resources that are supported by a stack template. For example,
GetSupportedCloudFormationResources

Parameters

Name Description Optional Valid Value Starting Version
version The template version No. For example, v1. Yes
  • v1
2.6.0
type The template type. Default type: zstack. Yes
  • zstack
2.6.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.6.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.6.0
timeout Yes

CreateResourceStack

Creates a resource stack. For example,
CreateResourceStack name=stack \
parameters="{  \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\",  \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\",  \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\"}" \
templateUuid=3a1106e2ff91411d989025c138a16b74

Parameters

Name Description Optional Valid Value Starting Version
name The resource name. 2.5.0
description The detailed description of the resource. Yes 2.5.0
type The stack type. Default type: zstack. Yes
  • zstack
2.5.0
rollback Whether to roll back if stack creation fails. Yes 2.5.0
templateContent The stack content, which is a JSON string.
Note: Make sure that at least one of templateContent and templateUuid is not null.
Yes 2.5.0
templateUuid The template UUID.
Note: Make sure that at least one of templateContent and templateUuid is not null.
Yes 2.5.0
parameters The parameters in the stack. The parameters are JSON strings. 2.5.0
resourceUuid The resource UUID. Yes 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

PreviewResourceStack

Previews a resource stack. For example,
PreviewResourceStack uuid=a427e49177a7426eadeef2e10b89efaf

Parameters

Name Description Optional Valid Value Starting Version
type Yes
  • zstack
2.5.0
templateContent The template content. Yes 2.5.0
uuid The template UUID. Yes 2.5.0
parameters The parameters in the template. The parameters are JSON strings. Yes 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

DeleteResourceStack

Deletes a resource stack. For example,
DeleteResourceStack uuid=36ed397d1ce847fcb3faa95decce7898

Parameters

Name Description Optional Valid Value Starting Version
uuid The resource UUID. 2.5.0
deleteMode Yes 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

UpdateResourceStack

Updates a resource stack. For example,
UpdateResourceStack uuid=f4e877381bc349a798e23b74084cd546 name=EIP

Parameters

Name Description Optional Valid Value Starting Version
uuid The stack UUID. 2.5.0
name The resource name. Yes 2.5.0
description The detailed description of the resource. Yes 2.5.0
rollback Whether to roll back if stack creation fails. Yes 2.5.0
templateContent The stack content, which is a JSON string. Yes 2.5.0
parameters The parameters in the stack. The parameters are JSON strings. Yes 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

QueryResourceStack

Queries a resource stack. For example,
QueryResourceStack uuid=f4e877381bc349a798e23b74084cd546

Primitive Fields of Query

See Resource Stack Inventory.

GetResourceFromResourceStack

Obtains resources from a resource stack. For example,
GetResourceFromResourceStack uuid=36ed397d1ce847fcb3faa95decce7898

Parameters

Name Description Optional Valid Value Starting Version
uuid The stack UUID. 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

QueryEventFromResourceStack

Queries events from a resource stack. For example,
QueryEventFromResourceStack uuid=36ed397d1ce847fcb3faa95decce7898

Primitive Fields of Query

See Resource Stack Event Inventory.

RestartResourceStack

Restarts a stack template. For example,
RestartResourceStack uuid=36ed397d1ce847fcb3faa95decce7898

Parameters

Name Description Optional Valid Value Starting Version
uuid The resource UUID. 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

CheckStackTemplateParameters

Checks stack template parameters. For example,
CheckStackTemplateParameters uuid=a427e49177a7426eadeef2e10b89efaf

Parameters

Name Description Optional Valid Value Starting Version
type The template type. Default type: zstack. Yes
  • zstack
2.5.0
templateContent The template content, which is a JSON string. Yes 2.5.0
uuid The template UUID. 2.5.0
userTags The user tags. For more information, see CreateUserTag. Yes 2.5.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 2.5.0
timeout Yes

DecodeStackTemplate

Parses a stack template into a resource structure graph. For example,
DecodeStackTemplate uuid=59a98484f6fe43b9af1d782f725f40ac

Parameters

Name Description Optional Valid Value Starting Version
type The template type. Default type: zstack. Yes
  • zstack
3.0.0
templateContent The template content.
Note: You must specify the uuid or templateContent parameter.
Yes 3.0.0
uuid The template UUID.
Note: You must specify the uuid or templateContent parameter.
Yes 3.0.0
parameters The request parameters in JSON format. Yes 3.0.0
preparameters The pre-rendered request parameters in JSON format. Yes 3.9.0
userTags The user tags. For more information, see CreateUserTag. Yes 3.0.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 3.0.0
timeout Yes

GetResourceStackFromResource

Obtains the corresponding stack of a resource. For example,
GetResourceStackFromResource resourceUuid=fad8b8f55961311a82b82a61d8b67fc5

Parameters

Name Description Optional Valid Value Starting Version
resourceUuid The resource UUID. 3.9.0
userTags The user tags. For more information, see CreateUserTag. Yes 3.9.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 3.9.0
timeout Yes

GetResourceStackVmStatus

Obtains the VM port monitoring status in a stack. For example,
GetResourceStackVmStatus uuid=8f0e4af072913507a434a2c7a8bd1d0a

Parameters

Name Description Optional Valid Value Starting Version
uuid The resource UUID. 3.9.0
userTags The user tags. For more information, see CreateUserTag. Yes 3.9.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 3.9.0
timeout Yes

AddResourceStackVmPortMonitor

Adds VM port monitoring to a stack. For example,
AddResourceStackVmPortMonitor vmInstanceUuid=29ddc109dd983b7fb74a7988ebbed12d port=22.0

Parameters

Name Description Optional Valid Value Starting Version
stackUuid The stack UUID. Yes 3.9.0
vmInstanceUuid The VM instance UUID. 3.9.0
port The port No. 3.9.0
userTags The user tags. For more information, see CreateUserTag. Yes 3.9.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 3.9.0
timeout Yes

DeleteResourceStackVmPortMonitor

Deletes VM port monitoring from a stack. For example,
DeleteResourceStackVmPortMonitor vmInstanceUuid=ffa8ab9746de3edcb1bc1245eef8868d

Parameters

Name Description Optional Valid Value Starting Version
stackUuid The stack UUID. Yes 3.9.0
vmInstanceUuid The VM instance UUID. 3.9.0
port The port No. Yes 3.9.0
deleteMode The delete mode. Yes 3.9.0
userTags The user tags. For more information, see CreateUserTag. Yes 3.9.0
systemTags The system tags. For more information, see CreateSystemTag. Yes 3.9.0
timeout Yes

Tags

You can create a user tag on a resource stack by using resourceType=ResourceStackVO. For example,
CreateUserTag resourceType=ResourceStackVO tag=golden-ResourceStack \
resourceUuid=36ed397d1ce847fcb3faa95decce7898
CLI Command Manual | 5.5.30 | ZStack Cloud · ZCF | ZStack Resource Center