配置參數(shù)映射
在全托管服務(wù)中,如果您的模板參數(shù)之間存在依賴關(guān)系,并且在特定條件下希望將參數(shù)設(shè)置為固定的值,則可以在服務(wù)中配置參數(shù)映射。計(jì)算巢在部署服務(wù)實(shí)例時(shí),在滿足條件的場(chǎng)景下,會(huì)自動(dòng)將您配置的參數(shù)值用作實(shí)例部署。本文介紹如何配置參數(shù)映射關(guān)系。
背景信息
全托管服務(wù)支持直接添加和使用資源棧組添加兩種映射方式添加映射關(guān)系。設(shè)置后,對(duì)應(yīng)參數(shù)自動(dòng)變?yōu)殡[藏參數(shù)。在用戶創(chuàng)建服務(wù)實(shí)例時(shí),只體現(xiàn)依賴參數(shù),且選擇依賴參數(shù)的值后,隱藏的參數(shù)自動(dòng)填寫映射關(guān)系中對(duì)應(yīng)參數(shù)設(shè)置的值。
直接添加:用于少數(shù)地域配置參數(shù)映射關(guān)系。服務(wù)商對(duì)模板中的參數(shù)進(jìn)行映射關(guān)系和子依賴映射設(shè)置。選擇依賴參數(shù)和對(duì)應(yīng)參數(shù),并設(shè)置依賴參數(shù)和對(duì)應(yīng)參數(shù)的值。
試用資源棧組添加:用于服務(wù)部署在多個(gè)地域的多個(gè)可用區(qū)且需要在每個(gè)地域都配置一個(gè)參數(shù)映射關(guān)系的情況。服務(wù)商可以使用資源棧組添加參數(shù)映射關(guān)系,簡(jiǎn)化配置參數(shù)映射的操作。
直接添加參數(shù)映射關(guān)系
操作步驟
在左側(cè)導(dǎo)航欄中,選擇我的服務(wù),在我的服務(wù)頁面中,選擇我發(fā)布的服務(wù),然后單擊創(chuàng)建新服務(wù)。
在創(chuàng)建新服務(wù)頁面,設(shè)置服務(wù)信息。
此處只列舉參數(shù)映射需要特別配置的參數(shù),其他參數(shù),請(qǐng)參見創(chuàng)建全托管服務(wù)。
在模板內(nèi)容框中,輸入模板內(nèi)容。模板內(nèi)容的詳細(xì)信息,請(qǐng)參見模板示例。
單擊添加參數(shù)映射關(guān)系,在彈出的添加參數(shù)映射關(guān)系彈窗中選擇直接添加并配置相關(guān)參數(shù)。
在映射配置和子依賴項(xiàng)映射配置區(qū)域,分別選擇依賴參數(shù)和對(duì)應(yīng)參數(shù)。
單擊添加自動(dòng)參數(shù)映射,設(shè)置選擇依賴參數(shù)和對(duì)應(yīng)參數(shù)的值。
在已設(shè)置的依賴參數(shù)
Region
后,選擇華東1(杭州)
;在已設(shè)置的對(duì)應(yīng)參數(shù)VpcId
后,選擇一個(gè)已有VPC。單擊添加子依賴參數(shù),選擇子依賴參數(shù)和對(duì)應(yīng)參數(shù)的值。
在已設(shè)置的子依賴參數(shù)
ZoneId
后,選擇華東 1 可用區(qū) K
;在已配置的對(duì)應(yīng)參數(shù)vSwitchId
后,選擇一個(gè)已有vSwitch。重復(fù)此步驟,添加華東 1 可用區(qū) J
和對(duì)應(yīng)可用區(qū)的vSwitch。單擊確定。
單擊保存服務(wù)。
使用資源棧組添加參數(shù)映射關(guān)系
操作步驟
在左側(cè)導(dǎo)航欄中,選擇我的服務(wù),并在我的服務(wù)頁面中選擇我創(chuàng)建的服務(wù),然后單擊創(chuàng)建新服務(wù)。
在創(chuàng)建新服務(wù)頁面,設(shè)置服務(wù)信息。
此處只列舉使用資源棧組添加參數(shù)映射需要特別配置的參數(shù),其他參數(shù),請(qǐng)參見創(chuàng)建全托管服務(wù)。
點(diǎn)擊添加自動(dòng)參數(shù)映射,在添加自動(dòng)參數(shù)映射彈窗中配置相關(guān)參數(shù)。
選擇使用資源棧組添加頁簽,并添加資源棧組。
若您有已創(chuàng)建的資源棧組,則您可以直接在資源棧組區(qū)域,選擇已創(chuàng)建資源棧組的地域、資源棧組ID。
若您還未創(chuàng)建資源棧組,則需要先完成資源棧組的創(chuàng)建,再選擇資源棧組。更多信息,請(qǐng)參見創(chuàng)建資源棧組。
為方便您的操作,計(jì)算巢為您提供了兩個(gè)創(chuàng)建資源棧組的最佳實(shí)踐,這兩個(gè)模板都會(huì)在各地域各可用區(qū)下創(chuàng)建VPC、交換機(jī)、安全組等信息。您只需要單擊對(duì)應(yīng)的名稱,即可跳轉(zhuǎn)到資源棧組創(chuàng)建頁面。然后根據(jù)界面提示填寫相應(yīng)的參數(shù),完成資源棧組的創(chuàng)建。
使用在某個(gè)地域創(chuàng)建VPC、交換機(jī)、安全組,并指定可用區(qū)數(shù)量創(chuàng)建資源棧時(shí),您需要指定可用區(qū)數(shù)量,且需要保證指定的可用區(qū)數(shù)量不大于地域中的可用區(qū)真實(shí)數(shù)量。
使用在某個(gè)地域所有可用區(qū)創(chuàng)建VPC、交換機(jī)、安全組創(chuàng)建資源棧時(shí),會(huì)默認(rèn)在所有可用區(qū)下創(chuàng)建。
單擊確定。
計(jì)算巢會(huì)自動(dòng)生成參數(shù)映射。這可能會(huì)耗時(shí)幾秒鐘,請(qǐng)您耐心等待。
單擊創(chuàng)建服務(wù),并在彈出的確認(rèn)彈窗中單擊確定。
服務(wù)實(shí)例部署效果
服務(wù)實(shí)例部署界面
服務(wù)創(chuàng)建完成后,在服務(wù)實(shí)例部署界面,用戶只需要選擇在參數(shù)映射中已配置的地域和可用區(qū)信息,并且VPC參數(shù)和vSwitch參數(shù)信息對(duì)用戶不可見。
服務(wù)實(shí)例部署完成
服務(wù)實(shí)例部署成功后,VPC參數(shù)和vSwitch參數(shù)的信息對(duì)用戶也不可見。
模板示例
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 此模板為單實(shí)例自定義鏡像模板示例,支持選擇已有基礎(chǔ)資源配置,支持配置ECS的付費(fèi)模式為預(yù)付費(fèi)或者后付費(fèi)
en: >-
This template supports single-instance with custom image, including
scenarios using existing and creating ECS by prepaid or postpaid model
Parameters:
SystemDiskCategory:
AssociationProperty: 'ALIYUN::ECS::Disk::SystemDiskCategory'
AssociationPropertyMetadata:
InstanceType: InstanceType
ZoneId: ZoneId
Type: String
Description:
zh-cn: >-
<font color='blue'><b>可選值:</b></font><br>[cloud_efficiency: <font
color='green'>高效云盤</font>]<br>[cloud_ssd: <font
color='green'>SSD云盤</font>]<br>[cloud_essd: <font
color='green'>ESSD云盤</font>]<br>[cloud: <font color='green'>普通云盤</font>]
en: >-
<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency:
<font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font
color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font
color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font
color='green'>Cloud Disk</font>]
Label:
zh-cn: 系統(tǒng)盤類型
en: System Disk Type
ECSPeriodUnit:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${InstanceChargeType}'
- PostPaid
Description:
zh-cn: '云服務(wù)器預(yù)付費(fèi)資源的購買時(shí)長周期,取值:[Week(周), Month(月)],<br>'
en: 'ECS Purchase cycle of prepaid resource, value: [Week, Month]<br>'
Default: Week
AllowedValues:
- Week
- Month
Label:
zh-cn: 云服務(wù)器預(yù)付費(fèi)資源的購買周期
en: ECS Purchase cycle of prepaid resources
Type: String
ECSPeriod:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${InstanceChargeType}'
- PostPaid
Description:
zh-cn: >-
云服務(wù)器預(yù)付費(fèi)資源的購買時(shí)長,當(dāng)預(yù)付費(fèi)資源的購買周期為Week時(shí),取值范圍:[1,2,3,4];
當(dāng)預(yù)付費(fèi)資源的購買周期為Month時(shí),取值:[1,2,3,4,5,6,7,8,9,12,24,36,48,60]<br>
en: >-
When the purchase cycle of prepaid resource is week, the value range is:
[1,2,3,4]; when the purchase cycle of prepaid resource is month, the
value is: [1,2,3,4,5,6,7,8,9,12,24,36,48,60]<br>
Default: 1
Label:
zh-cn: 云服務(wù)器預(yù)付費(fèi)資源的購買時(shí)長
en: ECS Purchase duration of prepaid resources
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 12
- 24
- 36
- 48
- 60
Type: Number
SecurityGroupId:
AssociationPropertyMetadata:
VpcId: VpcId
Description:
zh-cn: 現(xiàn)有安全組的實(shí)例ID
en: The instance ID of an existing security group.
Default: null
Label:
zh-cn: 安全組ID
en: Security Group ID
AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
Type: String
SystemDiskSize:
Default: 40
Type: Number
Description:
zh-cn: '系統(tǒng)盤大小, 取值范圍:[40, 500], 單位:GB。'
en: 'System disk size, range of values: 40-500, units: GB.'
Label:
zh-cn: 系統(tǒng)盤空間
en: System Disk Space
ZoneId:
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
Type: String
Description:
zh-cn: 可用區(qū)配置決定了新建ECS實(shí)例的可用區(qū)。此外,如果您選擇已有基礎(chǔ)資源配置,僅能選到該可用區(qū)下的交換機(jī)。
en: >-
ECS VSwitch Zone ID defines the Availability Zone for creating ECS
instance. If you choose existing Infrastructure Configuration,you can
only find the VSwitch under the Availability zone.
Label:
zh-cn: ECS交換機(jī)可用區(qū)
en: ECS VSwitch Zone ID
DataDiskCategory:
AssociationProperty: 'ALIYUN::ECS::Disk::DataDiskCategory'
AssociationPropertyMetadata:
InstanceType: InstanceType
ZoneId: ZoneId
Type: String
Description:
zh-cn: >-
<font color='blue'><b>可選值:</b></font><br>[cloud_efficiency: <font
color='green'>高效云盤</font>]<br>[cloud_ssd: <font
color='green'>SSD云盤</font>]<br>[cloud_essd: <font
color='green'>ESSD云盤</font>]<br>[cloud: <font color='green'>普通云盤</font>]
en: >-
<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency:
<font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font
color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font
color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font
color='green'>Cloud Disk</font>]
Label:
zh-cn: 數(shù)據(jù)盤類型
en: Data Disk Type
InstanceChargeType:
Default: PostPaid
Label:
zh-cn: ECS實(shí)例的付費(fèi)模式
en: ECS Instance Billing Method
Type: String
Description:
zh-cn: >-
<font color='blue'><b>可選值:</b></font><br>[PostPaid: <font
color='green'>按量付費(fèi)。</font>]<br>[PrePaid: <font
color='green'>預(yù)付費(fèi),包年包月。</font>]
en: >-
<font color='blue'><b>Optional values:</b></font><br>[PostPaid: <font
color='green'>Pay as you go.</font>]<br> [PrePaid: <font
color='green'>Prepaid, subscription.</font>]
AllowedValues:
- PostPaid
- PrePaid
VpcId:
Default: null
AssociationProperty: 'ALIYUN::ECS::VPC::VPCId'
Type: String
Description:
zh-cn: '請(qǐng)選擇已有的VPC<br><b><font color=''blue''>如找不到VPC,請(qǐng)切換地域。</font></b>'
en: >-
Please select the existing VPC. <br><b><font color='blue'>If you can't
find the VPC, please switch Regions.</font></b>
Label:
zh-cn: 現(xiàn)有VPC的實(shí)例ID
en: Existing VPC ID
DataDiskSize:
Description:
zh-cn: ECS實(shí)例數(shù)據(jù)盤大小,單位為GiB。取值范圍:20~32768
en: 'ECS Instance disk size, range of values: 20-32768, units: GB'
Default: 100
MaxValue: 32768
MinValue: 20
Label:
zh-cn: 數(shù)據(jù)盤空間
en: Data Disk Space
Type: Number
VSwitchId:
AssociationPropertyMetadata:
VpcId: VpcId
ZoneId: ZoneId
Description:
zh-cn: 現(xiàn)有網(wǎng)絡(luò)交換機(jī)的實(shí)例ID
en: The instance ID of an existing network switch.
Default: null
Label:
zh-cn: 網(wǎng)絡(luò)交換機(jī)ID
en: VSwitch ID
AssociationProperty: 'ALIYUN::ECS::VSwitch::VSwitchId'
Type: String
Password:
ConstraintDescription:
zh-cn: '長度8-30,必須包含三項(xiàng)(大寫字母、小寫字母、數(shù)字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符號(hào))。'
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
Description:
zh-cn: >-
服務(wù)器登錄密碼,長度8-30,必須包含三項(xiàng)(大寫字母、小寫字母、數(shù)字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符號(hào))。
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in).
MinLength: 8
Label:
zh-cn: 實(shí)例密碼
en: Instance Password
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
NoEcho: true
MaxLength: 30
Type: String
InstanceType:
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: '${InstanceChargeType}'
ZoneId: ZoneId
Type: String
Label:
zh-cn: 實(shí)例類型
en: Instance Type
InternetChargeType:
Type: String
Description:
zh-cn: >-
<font color='blue'><b>可選值:</b></font><br>[PayByBandwidth: <font
color='green'>按帶寬付費(fèi)。</font>]<br>[PayByTraffic: <font
color='green'>按流量付費(fèi)。</font>],<br>默認(rèn)為PayByTraffic
en: >-
<font color='blue'><b>Optional values:</b></font><br>[PayByBandwidth:
<font color='green'>Pay by bandwidth. </font>]<br>[PayByTraffic: <font
color='green'>Pay by traffic. </font>],<br>The default is PayByTraffic
Label:
en: InternetChargeType
zh-cn: 流量付費(fèi)類型
AllowedValues:
- PayByBandwidth
- PayByTraffic
Default: PayByTraffic
InternetMaxBandwidthOut:
Type: Number
Description:
en: >-
ECS Internet Max Bandwidth Out. Value range: 0~100. Unit: Mbps. Default
value: 0.
zh-cn: ECS最大出帶寬。取值范圍:0~100。單位:Mbps。默認(rèn)值:0。
Label:
en: 'Internet Max BandwidthOut '
zh-cn: 實(shí)例公網(wǎng)帶寬
Default: 0
MaxValue: 100
MinValue: 0
Outputs:
InstanceIds:
Value:
'Fn::GetAtt':
- ECSInstances
- InstanceIds
Conditions: {}
Resources:
ECSInstances:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
SystemDiskCategory:
Ref: SystemDiskCategory
VpcId:
Ref: VpcId
InstanceChargeType:
Ref: InstanceChargeType
AllocatePublicIP: true
SecurityGroupId:
Ref: SecurityGroupId
InternetChargeType:
Ref: InternetChargeType
InternetMaxBandwidthOut:
Ref: InternetMaxBandwidthOut
DiskMappings:
- Category:
Ref: DataDiskCategory
Size:
Ref: DataDiskSize
SystemDiskSize:
Ref: SystemDiskSize
ImageId: centos_7
PeriodUnit:
Ref: ECSPeriodUnit
VSwitchId:
Ref: VSwitchId
Period:
Ref: ECSPeriod
Password:
Ref: Password
InstanceType:
Ref: InstanceType
ZoneId:
Ref: ZoneId
MaxAmount: 1
Metadata:
'ALIYUN::ROS::Designer':
id: 3d97f557-f6c2-475f-bdca-942c45e583b5
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId
Label:
default:
zh-cn: 可用區(qū)配置
en: Zone Configuration
- Parameters:
- VpcId
- VSwitchId
- SecurityGroupId
Label:
default:
zh-cn: 選擇已有基礎(chǔ)資源配置
en: Choose existing Infrastructure Configuration
- Parameters:
- InstanceChargeType
- ECSPeriodUnit
- ECSPeriod
- InstanceType
- SystemDiskCategory
- SystemDiskSize
- DataDiskCategory
- DataDiskSize
- InternetChargeType
- InternetMaxBandwidthOut
- Password
Label:
default:
zh-cn: ECS 配置(必填)
en: ECS Configuration
TemplateTags:
- 'acs:example:ISV軟件部署:自定義鏡像創(chuàng)建單實(shí)例ECS云服務(wù)器'