Stack template is a UTF8-encoded file.
You can quickly create a resource stack based on a stack template. With a stack template, you can define what cloud resources you need, the dependency between the resources, and the resource configuration. CloudFormation analyzes the stack template and automatically creates and configures all resources.
{ "ZStackTemplateFormatVersion" : "YYYY-MM-DD", "Description" : "The description of the stack template, which is used to provide information such as application scenarios and the structure of the stack template.", "Parameters" : { // The parameters you can specify when creating a resource stack. }, "Mappings" : { // The mapping tables. Mapping tables are nested tables. }, "Resources" : { // The detailed information of resources, including configurations and dependencies. }, "Outputs" : { // The outputs that are used to provide useful information such as resource properties. You can use API to obtain this information. }
ZStackTemplateFormatVersion
(Required)YYYY-MM-DD
Description
(Optional)Parameters
(Optional)Mappings
(Optional)Fn::FindInMap
to select values through corresponding keys.Resources
(Optional)Outputs
(Optional)Label
field to define user-friendly parameter names.Parameters
are as follows.Property | Description | Required | Example |
---|---|---|---|
Type | The parameter type. Options:
| Yes | "Type": "String" |
Label | The alias of the parameter. When forms are previewed or generated using templates, labels can be mapped to parameter names. | No | "Label": "The password of the VM instance" |
Description | The string that describes the parameter. | No | "Description": "The login password of the VM instance" |
NoEcho | Specifies whether to mask a parameter value as asterisks (*****). If you set this property to true, CloudFormation returns the parameter value masked as asterisks (*****). | No | "NoEcho": true ![]() |
DefaultValue | The default value of the parameter. | No | "DefaultValue": "password" |
Parameters
. (You are actually not allowed to declare them.)Pseudo Parameter Name | Description |
---|---|
ZStack::StackName | The name of the current resource stack |
ZStack::StackUuid | The UUID of the current resource stack |
ZStack::AccountUuid | The AccountUuid of the current resource stack |
ZStack::AccountName | The AccountName of the current resource stack |
Parameters
syntax."Parameters" : { "username" : { "Label": "Login name", "Description" : "Login name", "DefaultValue": "root", "Type" : "String" }, "password" : { "Label": "Password", "NoEcho" : "true", "Description" : "Login password", "Type" : "String", } }
Parameters
.username
username
must also meet the length and valid values requirements.password
NoEcho
to true, CloudFormation returns the parameter value masked as asterisks (*****).NoEcho
property cannot be configured currently.Resources
can reference Parameters
, Mappings
, and Functions
.Resources
can be referenced by other Resources
and Outputs
.{ }
. ,
. Resources
are as follows.Key Field | Description | Required | Example |
---|---|---|---|
Type | The type of the resource that is being declared. Options:
| Yes |
|
Properties | The resource properties that specify parameters for resource creation. | Yes | For more information, see Properties |
DependsOn | Specifies that the creation of a specific resource follows another. | No |
|
DeletionPolicy |
| No |
|
Description | The string that describes the resource. | No |
|
Parameters
syntax."Resources" : { "UUID-1" : { "Description" : "The resource description", "Type" : "The resource type", "Properties" : { The resource properties } }, "UUID-2" : { "Description" : "The resource description" "Type" : "The resource type", "Properties" : { The resource properties }, "DependsOn":"The dependent resource. Take UUID-1 for example. Note that this dependent resource should be contained in the context.", "DeletionPolicy":"The deletion policy" } }
Resources
. The description of key fields are as follows:Resource UUID
UUID-1
and UUID-2
are the resource UUIDs. Both of them are variables.Type
Resource
type and Action
type."Type": "ZStack::Resource::VmInstance"
indicates that the resource is a VM instance. "Type": "ZStack::Action::AddIpRange"
indicates the IP range to be added.Properties
Properties
syntax."Resources" : { "InstanceOffering" : { "Type" : "ZStack::InstanceOffering", "Properties" : { "cpuNum" : "1", "cpuSpeed" : "1", "memorySize" : "1073741824", "name" : "instance-offering", "type" : "UserVm", "sortKey": 0, "allocatorStrategy": "LeastVmPreferredHostAllocatorStrategy" } } }
""
.[]
.{}
."Properties" : { "String" : "string", "LiteralList" : [ "value1", "value2" ], "Boolean" : "true" "ReferenceForOneValue" : { "Ref" : "ResourceID" } , "FunctionResultWithFunctionParams" : { "Fn::Join" : [ "%", [ "Key=", { "Ref" : "SomeParameter" } ] ] } }
DependsOn
DependsOn
attribute, you can specify that the creation of a specific resource follows another.DependsOn
attribute to a resource, the resource is created only after the creation of the resource specified in the DependsOn
attribute.DependsOn
syntax.{ "ZStackTemplateFormatVersion" : "2018-06-18", "Resources" : { "WebServer": { "Type": "ZStack::Resource::VmInstance", "DependsOn": "DatabseServer" }, "DatabseServer": { "Type": "ZStack::Resource::VmInstance", "Properties": { "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"},"VM"]]}, "instanceOfferingUuid": {"Ref":"InstanceOfferingUuid"}, "imageUuid":{"Ref":"ImageUuid"}, "l3NetworkUuids":[{"Ref":"PrivateNetworkUuid"}], "dataDiskOfferingUuids":[{"Ref":"DiskOfferingUuid"}], "hostUuid":{"Ref":"HostUuid"} } } } }
This example indicates that WebServer is created only after DatabaseServer is created.
DeletionPolicy
DeletionPolicy
specifies whether to retain a resource after its stack is deleted.DeletionPolicy
has two options: Retain
and Delete
.Delete
: The default value, which indicates that after a resource stack is deleted, all resources in the stack will be deleted.Retain
: If the DeletionPolicy
attribute is set to Retain
, the specific resource will be retained after its stack is deleted. Furthermore, the dependent resource of the resource will also be retained. (The system automatically retains the dependent resource.)"Resources" : { "VMInstance" : { "Type" : "ZStack::Resource::VmInstance", "Properties": { "name": {"Fn::Join":["-",[{"Ref":"ZStack::StackName"},"VM"]]}, "instanceOfferingUuid": {"Ref":"InstanceOfferingUuid"}, "imageUuid":{"Ref":"ImageUuid"}, "l3NetworkUuids":[{"Ref":"PrivateNetworkUuid"}], "dataDiskOfferingUuids":[{"Ref":"DiskOfferingUuid"}], "hostUuid":{"Ref":"HostUuid"} }, "DeletionPolicy" : "Retain" } }
Back to Top
Email Us
contact@zstack.ioEmail Us
contact@zstack.ioEmail Us
contact@zstack.ioThe download link is sent to your email address.
If you don't see it, check your spam folder, subscription folder, or AD folder. After receiving the email, click the URL to download the documentation.Thank you for using ZStack products and services.
Submit successfully.
We'll connect soon.Thank you for using ZStack products and services.