You can use a scenario template to quickly create a Compute Nest service. This topic describes how to deploy a service that contains two ECS instances, one SLB instance with the ECS instances as backend servers, and one RDS instance.
Prerequisites
You can use this guide to quickly deploy a service if you meet one of the following conditions:
-
You deploy your software by creating ECS instances from a custom image.
-
You have published a product as an image on Alibaba Cloud Marketplace.
Procedure
Create a service
-
Log in to the Compute Nest console.
-
In the left-side navigation pane, click My Services. On the Created Services tab, click Create Service.
-
Select Build Custom Service, choose Private Service as the service type, and then click Next: Configure Settings.
-
On the Configure Service page, configure the following settings.
-
In the Basic Information section, upload a Service Icon and enter the Service Name, Service Description, and Version Description.
-
In the Service Deployment section, configure the cloud resources for the service.
-
For Deployment Settings, select All Regions.
-
For Template Entry, select Scenario-based Template. In Scenario, select create two ECS and SLB and add ECS to the SLB backend server, and create an RDS-existing VPC. After you select the scenario, the template content is automatically populated. No modifications are necessary.
For a detailed description of the template content, see the ROS console. The template architecture is shown in the following figure:
-
Click Add Plan. Configure two packages and disable the custom package option. For Package 1, set instance type to
ecs.g6.large, SLB instance specification toslb.s1.small, and billing method toPostPaid. For Package 2, set instance type toecs.g8i.large, SLB instance specification toslb.s2.medium, and billing method toPrePaid. -
For Deployment Package Association, select a distributed image from a deployment artifact to replace the image in the template. The image to be replaced is
centos_7, and the associated resource isEcsInstanceGroup. -
Do not configure an application group.
To group resources in the template, click Create Application Group.
-
-
In the Service O&M section, configure the O&M features for the service.
-
In the O & M section, configure O&M notifications. Select the User authorization required checkbox, and then select a permission policy from the list, such as
AliyunComputeNestPolicyForFullAccessfor full access. -
In the Monitoring section, configure resource monitoring. Under Resource monitoring, select Use the same CloudMonitor alert template, and then select a template from the drop-down list, such as Managed Service Alert Template. Prometheus monitoring is disabled by default.
-
For Logging, Upgrade, and Modify Configurations, keep the default settings.
-
-
In the Advanced Configuration section, no further configuration is required.
-
-
Click Create Service.
In the dialog box that appears, accept the service agreement and review standards, and then click OK.
-
Test the service.
After you save the service, test it to ensure it works as expected. For more information, see Test a service.
-
Publish the service.
After the service passes the test, submit it for review. Once approved, you can publish the service. For more information, see Publish a service.
Deploy a service instance
-
After the service is published, create a service instance from the deployment link. On the configuration page, you must specify the vSwitch availability zone, select an existing VPC instance ID and vSwitch instance ID, and choose the desired package. Then, click Next: Confirm Order.
-
On the confirmation page, verify the parameter information, grant permissions to the service provider, and then click Create Now. A summary of the service instance information is displayed, including parameters such as region, instance type, and SLB instance specification.
-
After the service instance is deployed, navigate to the Resources page to view the created cloud resources. You can see the created cloud resources, such as a security group, vSwitch, and VPC.
Advanced operations
Automatically add ECS instances to the RDS whitelist
-
When creating the service, select and modify the scenario template from this topic. Redefine the
SecurityIPListsection (refer to the attachment for the full template). After you complete the modification, configure the service by following the steps above. In the template, the SecurityIPList section uses theFn::JoinandFn::GetAttfunctions to automatically retrieve thePrivateIpsof theEcsInstanceGroupand add them to the RDS whitelist.
Attachment
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: >-
Use an existing VPC, vSwitch, and security group to create one RDS instance, one SLB instance, and two ECS
instances. Bind all ECS instances to the SLB instance.
zh-cn: 使用已有VPC、VSWitch、SecurityGroup,创建1个RDS、1个SLB、2个ECS实例,并将所有ECS实例绑定到SLB上。
Parameters:
ZoneId:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance:ZoneId'
Description:
zh-cn: 可用区ID。
en: The ID of the availability zone.
Label:
zh-cn: 交换机可用区
en: VSwitch Availability Zone
VpcId:
AssociationProperty: 'ALIYUN::ECS::VPC::VPCId'
Type: String
Description:
en: >-
The ID of the existing VPC. You can find the ID, which starts with vpc-, in the
Virtual Private Cloud console.
zh-cn: 现有虚拟专有网络的实例ID
Label:
en: VPC ID
zh-cn: 专有网络VPC实例ID
VSwitch:
AssociationProperty: 'ALIYUN::ECS::VSwitch::VSwitchId'
AssociationPropertyMetadata:
VpcId: '${VpcId}'
ZoneId: '${ZoneId}'
Type: String
Description:
en: >-
The ID of the existing vSwitch. You can find the ID in the Virtual
Private Cloud console under VSwitches.
zh-cn: 现有业务网络交换机的实例ID
Label:
en: vSwitch ID
zh-cn: 交换机实例ID
SecurityGroup:
Type: String
AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
AssociationPropertyMetadata:
VpcId: '${VpcId}'
Description:
en: >-
The ID of the existing security group. You can find the ID, which starts with sg-, in the
ECS console under Network & Security.
zh-cn: 现有业务安全组的实例ID
Label:
en: Business Security Group ID
zh-cn: 业务安全组ID
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
The logon password for the server. The password must be 8 to 30 characters in length and contain characters from at least three of the following types: uppercase letters,
lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/.
zh-cn: >-
服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符号)。
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
Label:
en: Instance Password
zh-cn: 实例密码
ConstraintDescription:
en: >-
The password must be 8 to 30 characters in length and contain characters from at least three of the following types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/.
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)。'
MinLength: 8
MaxLength: 30
DataDiskCategory:
AssociationProperty: 'ALIYUN::ECS::Disk::DataDiskCategory'
AssociationPropertyMetadata:
InstanceType: '${EcsInstanceType}'
ZoneId: '${ZoneId}'
Type: String
Description:
en: >-
<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency:
<font color='green'>Ultra Disk</font>]<br>[cloud_ssd: <font
color='green'>Standard SSD</font>]<br>[cloud_essd: <font
color='green'>ESSD</font>]<br>[cloud: <font
color='green'>Basic Disk</font>]<br>[ephemeral_ssd: <font
color='green'>Local SSD</font>]
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>]<br>[ephemeral_ssd: <font
color='green'>本地SSD盘</font>]
Label:
en: Disk Type
zh-cn: 数据盘类型
DataDiskSize:
Type: Number
Description:
en: 'The size of the data disk. Unit: GiB. Valid values: 20 to 23768.'
zh-cn: 实例数据盘大小,单位为GiB。取值范围:20~23768。
Label:
en: Data Disk Size
zh-cn: 数据盘空间
MinValue: 20
MaxValue: 23768
Default: 20
SystemDiskSize:
Default: 40
Type: Number
MinValue: 40
MaxValue: 500
Description:
zh-cn: '系统盘大小, 取值范围:[40, 500], 单位:GB。'
en: 'The size of the system disk. Unit: GB. Valid values: 40 to 500.'
Label:
zh-cn: 系统盘空间
en: System Disk Size
EcsInstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
ZoneId: '${ZoneId}'
InstanceChargeType: '${InstanceChargeType}'
LoadBalancerSpec:
Type: String
AssociationProperty: 'ALIYUN::SLB::Instance::InstanceType'
Description:
en: >-
Instance specifications. For more information, see <a
href='https://www.alibabacloud.com/help/doc-detail/85939.html'
target='_blank'><b><font color='blue'>Performance-guaranteed
instances</b></font></a>.
zh-cn: >-
实例规格,</br>详见:</b><a
href='https://help.aliyun.com/document_detail/85939.html'
target='_blank'><b><font color='blue'>性能保障型</b></font></a>
Label:
en: Specifications
zh-cn: 规格
Default: slb.s1.small
SystemDiskCategory:
AssociationProperty: 'ALIYUN::ECS::Disk::DataDiskCategory'
AssociationPropertyMetadata:
InstanceType: '${EcsInstanceType}'
ZoneId: '${ZoneId}'
Type: String
Description:
en: >-
<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency:
<font color='green'>Ultra Disk</font>]<br>[cloud_ssd: <font
color='green'>Standard SSD</font>]<br>[cloud_essd: <font
color='green'>ESSD</font>]<br>[cloud: <font
color='green'>Basic Disk</font>]<br>[ephemeral_ssd: <font
color='green'>Local SSD</font>]
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>]<br>[ephemeral_ssd: <font
color='green'>本地SSD盘</font>]
Label:
en: System Disk Category
zh-cn: 系统盘类型
DBInstanceEngineAndVersion:
Type: String
Description:
zh-cn: 数据库实例引擎类型加版本,默认为Mysql-8.0,现在支持Mysql/SQLServer/PostgreSQL/PPAS/MariaDB。
en: >-
The database engine and version of the instance. Default value: MySQL-8.0. Supported engines: MySQL, SQLServer, PostgreSQL, PPAS, and MariaDB.
Label:
zh-cn: 类型加版本
en: Engine and Version
Default: MySQL-8.0
DBInstanceClass:
Label:
zh-cn: 实例规格
en: DB Instance Class
Type: String
Description:
zh-cn: >-
根据数据库引擎的类型和可用的区域支持选择实例规格;<br>请参见详细信息:<a
href='https://help.aliyun.com/document_detail/26312.html'
target='_blank'><b><font color='blue'>实例规格表</font></b></a>
en: >-
Select the instance type based on the database engine and the supported region. For more information, see <a
href='https://www.alibabacloud.com/help/doc-detail/26312.html'
target='_blank'><b><font color='blue'>Instance types</font></b></a>.
Default: rds.mysql.c1.large
AssociationProperty: 'ALIYUN::RDS::Instance::InstanceType'
AssociationPropertyMetadata:
ZoneId: '${ZoneId}'
InstanceChargeType: '${RdsDBInstancePayType}'
DBInstanceStorage:
Label:
zh-cn: 实例存储
en: Storage
Type: Number
Description:
zh-cn: RDS实例大小范围为20-2000,每5个增量,单位为GB
en: >-
The storage capacity of the RDS instance. Unit: GB. Valid values: 20 to 2000, in increments of 5.
MinValue: 20
MaxValue: 2000
ConstraintDescription:
zh-cn: RDS实例大小范围为20-2000,每5个增量,单位为GB
en: >-
The storage capacity of the RDS instance. Unit: GB. Valid values: 20 to 2000, in increments of 5.
Default: 20
DBInstanceNetType:
AllowedValues:
- Internet
- Intranet
Description:
zh-cn: 数据库实例网络类型,默认为Intranet.Internet用于公共访问,Intranet用于私人访问。
en: >-
The network type of the database instance. Default value: Intranet. A value of Internet indicates public access, while Intranet indicates private access.
Type: String
Default: Intranet
Label:
zh-cn: 网络类型
en: Network Type
ECSPeriodUnit:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${InstanceChargeType}'
- PostPaid
Description:
zh-cn: '云服务器预付费资源的购买时长周期,取值:[Week(周), Month(月)],<br>'
en: 'The billing cycle for the subscription ECS resource. Valid values: Week and Month.'
Default: Week
AllowedValues:
- Week
- Month
Label:
zh-cn: 云服务器预付费资源的购买周期
en: ECS Purchase Cycle of Subscription Resources
Type: String
ECSPeriod:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${InstanceChargeType}'
- PostPaid
Description:
zh-cn: >-
云服务器预付费资源的购买时长,当预付费资源的购买周期为Week时,取值范围:[1,2,3,4];
当预付费资源的购买周期为Month时,取值:[1,2,3,4,5,6,7,8,9,12,24,36,48,60]<br>
en: >-
The subscription duration for the ECS resource. If you set ECSPeriodUnit to Week, valid values are 1, 2, 3, and 4. If you set ECSPeriodUnit to Month, valid values are 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60.
Default: 1
Label:
zh-cn: 云服务器预付费资源的购买时长
en: ECS Purchase Duration of Subscription Resources
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 12
- 24
- 36
- 48
- 60
Type: Number
InstanceChargeType:
Default: PostPaid
Label:
zh-cn: ECS实例的付费模式
en: ECS Instance Billing Method
Type: String
Description:
zh-cn: >-
<font color='blue'><b>可选值:</b></font><br>[PostPaid: <font
color='green'>按量付费。</font>]<br>[PrePaid: <font
color='green'>预付费,包年包月。</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'>subscription.</font>]
AllowedValues:
- PostPaid
- PrePaid
SLBPayType:
Default: PayOnDemand
Label:
zh-cn: SLB实例的付费模式
en: SLB Instance Billing Method
Type: String
Description:
zh-cn: >-
<font color='blue'><b>可选值:</b></font><br>[PayOnDemand: <font
color='green'>按量付费。</font>]<br>[PrePay: <font
color='green'>预付费,包年包月。</font>]
en: >-
<font color='blue'><b>Optional values:</b></font><br>[PayOnDemand: <font
color='green'>pay-as-you-go.</font>]<br> [PrePay: <font
color='green'>subscription.</font>]
AllowedValues:
- PayOnDemand
- PrePay
SLBPricingCycle:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${SLBPayType}'
- PayOnDemand
Description:
zh-cn: '负载均衡预付费资源的购买时长周期,取值:[month(月), year(年)],<br>'
en: 'The billing cycle for the subscription SLB resource. Valid values: month and year.'
Default: month
AllowedValues:
- month
- year
Label:
zh-cn: 负载均衡预付费资源的购买周期
en: SLB Purchase Cycle of Subscription Resources
Type: String
SLBDuration:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${SLBPayType}'
- PayOnDemand
Description:
zh-cn: >-
负载均衡预付费资源的购买时长,当预付费资源的购买周期为month时,取值范围:[1,2,3,4, 5,6,7,8,9];
当预付费资源的购买周期为year时,取值:[1,2,3]<br>
en: >-
The subscription duration for the SLB resource. If you set SLBPricingCycle to month, valid values are 1, 2, 3, 4, 5, 6, 7, 8, and 9. If you set SLBPricingCycle to year, valid values are 1, 2, and 3.
Default: 1
Label:
zh-cn: 负载均衡预付费资源的购买时长
en: SLB Purchase Duration of Subscription Resources
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
Type: Number
RdsDBInstancePayType:
Type: String
Description:
en: >-
<font color='blue'><b>Optional values: </b></font><br>[Postpaid: <font
color='green'>pay-as-you-go</font>]<br>[Prepaid: <font
color='green'>subscription</font>]<br><font
color='blue'>You cannot create a database or an account for a subscription instance.
zh-cn: >-
<font color='blue'><b>付费类型;可选值:</b></font><br>[Postpaid:<font
color='green'>按量付费</font>]<br>[Prepaid:<font
color='green'>预付费,包月</font>]<br>预付费,包月实例不创建数据库(db)和账号。
AllowedValues:
- Postpaid
- Prepaid
Label:
en: Billing Method
zh-cn: 付费类型
Default: Postpaid
RdsPeriodType:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${RdsDBInstancePayType}'
- Postpaid
Description:
zh-cn: '数据库实例预付费资源的购买时长周期,取值:[Month(月), Year(年)],<br>'
en: 'The billing cycle of the subscription RDS resource. Valid values: Month and Year.'
Default: Month
AllowedValues:
- Month
- Year
Label:
zh-cn: 云数据库预付费资源的购买周期
en: RDS Purchase Cycle of Subscription Resources
Type: String
RdsPeriod:
AssociationPropertyMetadata:
Visible:
Condition:
'Fn::Not':
'Fn::Equals':
- '${RdsDBInstancePayType}'
- Postpaid
Description:
zh-cn: >-
数据库实例预付费资源的购买时长,当预付费资源的购买周期为Month时,取值范围:[1,2,3,4, 5,6,7,8,9];
当预付费资源的购买周期为Year时,取值:[1,2,3]<br>
en: >-
The subscription duration of the RDS resource. If you set RdsPeriodType to Month, valid values are 1, 2, 3, 4, 5, 6, 7, 8, and 9. If you set RdsPeriodType to Year, valid values are 1, 2, and 3.
Default: 1
Label:
zh-cn: 数据库实例预付费资源的购买时长
en: RDS Purchase Duration of Subscription Resources
AllowedValues:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
Type: Number
Resources:
EcsInstanceGroup:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
Period:
Ref: ECSPeriod
PeriodUnit:
Ref: ECSPeriodUnit
IoOptimized: optimized
DiskMappings:
- Category:
Ref: DataDiskCategory
Device: /dev/xvdb
Size:
Ref: DataDiskSize
SystemDiskSize:
Ref: SystemDiskSize
InstanceChargeType:
Ref: InstanceChargeType
SecurityGroupId:
Ref: SecurityGroup
VSwitchId:
Ref: VSwitch
MaxAmount: 2
SystemDiskCategory:
Ref: SystemDiskCategory
InstanceName:
'Fn::Join':
- '-'
- - StackId
- Ref: 'ALIYUN::StackId'
VpcId:
Ref: VpcId
ImageId: centos_7
InstanceType:
Ref: EcsInstanceType
HostName:
'Fn::Join':
- '-'
- - StackId
- Ref: 'ALIYUN::StackId'
Password:
Ref: InstancePassword
AllocatePublicIP: false
Slb:
Type: 'ALIYUN::SLB::LoadBalancer'
Properties:
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitch
LoadBalancerName:
'Fn::Join':
- '-'
- - StackId
- Ref: 'ALIYUN::StackId'
PayType:
Ref: SLBPayType
PricingCycle:
Ref: SLBPricingCycle
Duration:
Ref: SLBDuration
AddressType: intranet
LoadBalancerSpec:
Ref: LoadBalancerSpec
AutoPay: true
SlbBackendServerAttachment:
DependsOn:
- EcsInstanceGroup
Type: 'ALIYUN::SLB::BackendServerAttachment'
Properties:
BackendServerList:
'Fn::GetAtt':
- EcsInstanceGroup
- InstanceIds
LoadBalancerId:
Ref: Slb
BackendServerWeightList:
- 100
- 100
SlbListener:
DependsOn: Slb
Type: 'ALIYUN::SLB::Listener'
Properties:
Persistence:
CookieTimeout: 60
StickySession: 'on'
PersistenceTimeout: 180
XForwardedFor: 'off'
StickySessionType: insert
ListenerPort: 3306
Bandwidth: -1
HealthCheck:
HttpCode: 'http_2xx,http_3xx,http_4xx,http_5xx'
HealthCheckType: tcp
UnhealthyThreshold: 3
Timeout: 5
HealthyThreshold: 3
Port: 3306
URI: /
Interval: 2
LoadBalancerId:
Ref: Slb
BackendServerPort: 3306
Protocol: tcp
Database:
Type: 'ALIYUN::RDS::DBInstance'
Properties:
PayType:
Ref: RdsDBInstancePayType
Period:
Ref: RdsPeriod
PeriodType:
Ref: RdsPeriodType
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitch
Engine:
'Fn::Select':
- '0'
- 'Fn::Split':
- '-'
- Ref: DBInstanceEngineAndVersion
EngineVersion:
'Fn::Select':
- '1'
- 'Fn::Split':
- '-'
- Ref: DBInstanceEngineAndVersion
DBInstanceClass:
Ref: DBInstanceClass
DBInstanceStorage:
Ref: DBInstanceStorage
DBInstanceNetType:
Ref: DBInstanceNetType
SecurityIPList:
Fn::Join:
- ','
- Fn::GetAtt:
- EcsInstanceGroup
- PrivateIps
Outputs:
LoadBalancerId:
Description:
en: The ID of the created load balancer.
zh-cn: 已创建负载平衡的ID。
Value:
'Fn::GetAtt':
- Slb
- LoadBalancerId
SlbIpAddress:
Description:
en: The IP address of the load balancer.
zh-cn: 负载均衡器的IP地址。
Value:
'Fn::GetAtt':
- Slb
- IpAddress
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId
- VpcId
- VSwitch
- SecurityGroup
Label:
default:
en: Network and Security Group
zh-cn: 网络和安全组
- Parameters:
- InstanceChargeType
- ECSPeriodUnit
- ECSPeriod
- EcsInstanceType
- SystemDiskCategory
- SystemDiskSize
- DataDiskCategory
- DataDiskSize
- InstancePassword
Label:
default:
en: ECS
zh-cn: 云服务器
- Parameters:
- SLBPayType
- SLBPricingCycle
- SLBDuration
- LoadBalancerSpec
Label:
default:
en: SLB
zh-cn: 负载均衡
- Parameters:
- RdsDBInstancePayType
- RdsPeriodType
- RdsPeriod
- DBInstanceEngineAndVersion
- DBInstanceClass
- DBInstanceStorage
- DBInstanceNetType
Label:
default:
en: RDS
zh-cn: 云数据库