This topic describes how to define a template to use different parameter values based on a region.
When you create a stack group by using a template, you may want to use different parameter values based on a region. For example, you may want to install a different image in each region. In this case, you can use the Mappings section, and define the Fn::FindInMap built-in function in the Resources and Outputs sections of the template. This way, you can obtain a desired value from a mapping based on a specified key. For example, you can define a mapping that uses regions as keys and images as values in the Mappings section, and use the Fn::FindInMap built-in function together with the ALIYUN::Region pseudo parameter in resource properties. Then, you can obtain a desired image from the mapping based on a specified region.
ROSTemplateFormatVersion: '2015-09-01'
Mappings:
RegionMap:
cn-shenzhen:
ImageId: m-2vca5gczbrozn1vwp****
cn-beijing:
ImageId: m-hp38urk0l2aioidn****
us-west-1:
ImageId: m-rj9b5x7xtspmbage****
cn-shanghai:
ImageId: m-2ze1bpkyqvylc2ag****
cn-hangzhou:
ImageId: m-bp1h1cr4n27d3owq****
Outputs:
ImageId:
Value:
Fn::FindInMap:
- RegionMap
- Ref: ALIYUN::Region
- ImageId
Sample UI
When you create a stack group and specify China (Hangzhou) as the region to deploy stacks, the ImageId value that corresponds to cn-hangzhou in the RegionMap mapping is automatically used.