Mappings

The mapping tables. Mapping tables are nested tables.
  • The Mappings section is a Key-Value mapping table.
  • When mappings are used in Resources or Outputs definitions, use Fn::FindInMap to find their values by using corresponding keys.

Syntax

A mapping consists of Key-Value pairs.
  • Both the keys and values can be strings or numbers.
  • Multiple mappings are separated with commas ,.
  • Mapping names must be unique.

Example

The following example shows the Mappings syntax.
"Mappings" : {
	"Mapping01" : {
           "Key01" : {
               "Name" : "Value01"
           },
           "Key02" : {
               "Name" : "Value02"
           },
           "Key03" : {
               "Name" : "Value03"
           }
       }
}
The following example shows how to use Fn::FindInMap to find the return value.
{
	"ZStackTemplateFormatVersion": "2018-06-18",
       "Parameters": {
           "regionParam": {
               "Description": "Select the region for VM instance creation.",
               "Type": "String",
               "AllowedValues": ["cn-hangzhou", "cn-shanghai"]
           }
       },
       "Mappings" : {
           "ImageInRegions" : {
               "cn-hangzhou" : { "32" : "imageUuid-1", "64" : "imageUuid-2" },
               "cn-shanghai" : { "32" : "imageUuid-3", "64" : "imageUuid-4" }
           }
       },
       "Resources": {
           "WebServer": {
               "Type": "ZStack::Resource::VmInstance",
               "Properties": {
                   "name" : "test-vm",
                   "imageUuid" : {"Fn::FindInMap": ["ImageInRegions", {"Ref":"regionParam"}, "64"]},
                   "instanceOfferingUuid": {"Ref":"instanceOfferingUuid"},
                   "l3NetworkUuids": [{"Ref":"l3NetworkUuid"}]
               },
               "DeletionPolicy": "Retain"
          }
       }
}