Updated on 2023-12-13 GMT+08:00

get_in_map

If a mapping table is defined in the template, you can use the get_in_map function to obtain the mapping table content from the node_templates and outputs sections.

Syntax

get_in_map: [map_name, top_level_key, second_level_key]

Parameter Description

Table 1 Parameter description

Parameter

Mandatory or Not

Parameter Description

map_name

Yes

Mapping name

top_level_key

Yes

Mapping object name

second_level_key

Yes

Mapping object property

Return Value

Value of the corresponding field in the mapping table.

Examples

Obtain the mapped content using the get_in_map function:

mappings:
  regionMap:
    cn-east-3:   # Defines the East China region.
      flavor: c2.medium    # Indicates the VM specifications of the East China region.
      image_id: f2003c7b-99c4-4616-be19-334beaca81b1   # Indicates the image ID of the East China region.
    cn-north-1:  # Defines the North China region.
      flavor: c1.medium    # Indicates the VM specifications of the North China region.
      image_id: 42f34d95-a538-4d17-be48-e690b48c1643   # Indicates the image ID of the North China region. 
    cn-south-1:   # Defines the South China region.
      flavor: c1.medium    # Indicates the VM specifications of the South China region.
      image_id: a3934478-bfeb-4a02-b257-9089779f0380   # Indicates the image ID of the South China region. 
node_templates:
  myecs:
    type: HuaweiCloud.ECS.CloudServer
    properties:
      availabilityZone: cn-south-1a
      flavor:
        get_in_map:
          - regionMap
          - get_input: HuaweiCloud.Region
          - flavor
      imageId:
        get_in_map:
          - regionMap
          - get_input: HuaweiCloud.Region
          - image_id
      ...