Tipe resource ALIYUN::ALB::Listener digunakan untuk membuat pendengar HTTP, HTTPS, atau QUIC pada instans Application Load Balancer (ALB).
Sintaksis
{
"Type": "ALIYUN::ALB::Listener",
"Properties": {
"RequestTimeout": Integer,
"ListenerPort": Integer,
"Http2Enabled": Boolean,
"DefaultActions": List,
"Certificates": List,
"IdleTimeout": Integer,
"LoadBalancerId": String,
"ListenerProtocol": String,
"QuicConfig": Map,
"GzipEnabled": Boolean,
"SecurityPolicyId": String,
"ListenerDescription": String,
"XForwardedForConfig": Map,
"CaEnabled": Boolean,
"CaCertificates": List,
"ListenerStatus": String,
"LogConfig": Map
}
}Properti
Nama properti | Type | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
DefaultActions | List | Ya | Ya | Daftar aksi aturan. | Contoh nilai: Untuk informasi selengkapnya, lihat properti DefaultActions. |
ListenerPort | Integer | Ya | Tidak | Port pendengar (Listener Port). | Nilai valid: 1 hingga 65535. |
ListenerProtocol | String | Ya | Tidak | Protokol pendengaran. | Nilai valid:
|
LoadBalancerId | String | Ya | Tidak | ID instans Application Load Balancer (ALB). | Tidak ada |
CaCertificates | List | Tidak | Ya | Informasi sertifikat CA. | Untuk informasi selengkapnya, lihat properti CaCertificates. |
CaEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengaktifkan otentikasi timbal balik. | Nilai valid:
|
Certificates | List | Tidak | Ya | Sertifikat | Untuk informasi selengkapnya, lihat properti Certificates. |
GzipEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengaktifkan kompresi Gzip untuk jenis file tertentu. | Nilai valid:
|
Http2Enabled | Boolean | Tidak | Ya | Menentukan apakah akan mengaktifkan HTTP/2. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
IdleTimeout | Integer | Tidak | Ya | Periode timeout koneksi idle. | Nilai valid: 1 hingga 60. Nilai default: 15. Unit: detik. Jika tidak ada permintaan yang tiba dalam periode timeout, load balancer sementara menutup koneksi saat ini. Load balancer membuat koneksi baru ketika permintaan berikutnya tiba. |
ListenerDescription | String | Tidak | Ya | Deskripsi pendengar. | Panjang: 2 hingga 256 karakter. |
ListenerStatus | String | Tidak | Ya | Status pendengar. | Nilai valid:
|
LogConfig | Map | Tidak | Ya | Konfigurasi log. | Untuk informasi selengkapnya, lihat properti LogConfig. |
QuicConfig | Map | Tidak | Ya | Konfigurasi pendengar QUIC terkait. | Untuk informasi selengkapnya, lihat properti QuicConfig. |
RequestTimeout | Integer | Tidak | Ya | Periode timeout permintaan. | Nilai valid: 1 hingga 180. Nilai default: 60. Unit: detik. Jika server backend tidak merespons dalam periode timeout, load balancer berhenti menunggu dan mengembalikan kode kesalahan HTTP 504 ke klien. |
SecurityPolicyId | String | Tidak | Ya | ID kebijakan keamanan. | Anda dapat menggunakan kebijakan keamanan yang ditentukan sistem atau kustom. Nilai default: tls_cipher_policy_1_0, yang menunjukkan kebijakan keamanan yang ditentukan sistem. Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForConfig | Map | Tidak | Ya | Konfigurasi field header X-Forwarded-For. | Untuk informasi selengkapnya, lihat properti XForwardedForConfig. |
Sintaksis DefaultActions
"DefaultActions": [
{
"Type": String,
"ForwardGroupConfig": Map
}
]Properti DefaultActions
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
ForwardGroupConfig | Map | Ya | Ya | Konfigurasi untuk aksi penerusan. | Untuk informasi selengkapnya, lihat properti ForwardGroupConfig. |
Type | String | Ya | Ya | Jenis aksi. | Atur parameter ini ke ForwardGroup untuk meneruskan permintaan ke beberapa kelompok vServer. |
Sintaksis ForwardGroupConfig
"ForwardGroupConfig": {
"ServerGroupTuples": List
}Properti ForwardGroupConfig
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
ServerGroupTuples | List | Ya | Ya | Kelompok vServer tujuan untuk penerusan. | Untuk informasi selengkapnya, lihat properti ServerGroupTuples. |
Sintaksis ServerGroupTuples
"ServerGroupTuples": [
{
"ServerGroupId": String
}
]Properti ServerGroupTuples
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
ServerGroupId | String | Ya | Ya | ID kelompok vServer tujuan untuk penerusan. | Tidak ada |
Sintaksis Certificates
"Certificates": [
{
"CertificateId": String
}
]Properti Certificates
Nama properti | Jenis | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
CertificateId | String | Tidak | Ya | ID sertifikat server. | Hanya sertifikat server yang didukung. |
Sintaksis QuicConfig
"QuicConfig": {
"QuicListenerId": String,
"QuicUpgradeEnabled": Boolean
}Properti QuicConfig
Nama properti | Jenis | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
QuicListenerId | String | Tidak | Ya | ID pendengar QUIC yang akan dikaitkan. | Anda harus menentukan parameter ini jika QuicUpgradeEnabled diatur ke true. Catatan
|
QuicUpgradeEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengaktifkan peningkatan QUIC. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
Sintaksis LogConfig
"LogConfig": {
"AccessLogTracingConfig": Map,
"AccessLogRecordCustomizedHeadersEnabled": Boolean
}Properti LogConfig
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
AccessLogTracingConfig | Map | Tidak | Ya | Konfigurasi X-Trace untuk log akses. | Untuk informasi selengkapnya, lihat properti AccessLogTracingConfig. |
AccessLogRecordCustomizedHeadersEnabled | Boolean | Tidak | Ya | Menentukan apakah akan menyertakan header kustom dalam log akses. | Nilai valid:
|
Sintaksis AccessLogTracingConfig
"AccessLogTracingConfig": {
"TracingSample": Integer,
"TracingType": String,
"TracingEnabled": Boolean
}Properti AccessLogTracingConfig
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
TracingEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengaktifkan X-Trace. | Nilai valid:
Catatan Anda hanya dapat mengatur parameter ini ke true jika fitur log akses (AccessLogEnabled) diaktifkan. |
TracingSample | Integer | Tidak | Ya | Laju pengambilan sampel untuk X-Trace. | Nilai valid: 1 hingga 10000. Catatan Nilai ini hanya berlaku jika TracingEnabled diatur ke true. |
TracingType | String | Tidak | Ya | Jenis X-Trace. | Nilai valid: Zipkin. Catatan Nilai ini hanya berlaku jika TracingEnabled diatur ke true. |
Sintaksis XForwardedForConfig
"XForwardedForConfig": {
"XForwardedForClientCertFingerprintAlias": String,
"XForwardedForClientCertFingerprintEnabled": Boolean,
"XForwardedForClientCertIssuerDNAlias": String,
"XForwardedForClientCertClientVerifyAlias": String,
"XForwardedForSLBIdEnabled": Boolean,
"XForwardedForClientCertSubjectDNEnabled": Boolean,
"XForwardedForClientCertSubjectDNAlias": String,
"XForwardedForProtoEnabled": Boolean,
"XForwardedForClientSrcPortEnabled": Boolean,
"XForwardedForSLBPortEnabled": Boolean,
"XForwardedForEnabled": Boolean,
"XForwardedForClientCertIssuerDNEnabled": Boolean,
"XForwardedForClientCertClientVerifyEnabled": Boolean,
"XForwardedForClientSourceIpsEnabled": Boolean,
"XForwardedForClientSourceIpsTrusted": String,
"XForwardedForProcessingMode": String,
"XForwardedForHostEnabled": Boolean
}Properti XForwardedForConfig
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
XForwardedForClientCertClientVerifyAlias | String | Tidak | Ya | Nama header kustom yang digunakan untuk mengambil hasil verifikasi sertifikat klien. | Parameter ini hanya berlaku jika XForwardedForClientCertClientVerifyEnabled diatur ke true. Panjang: 1 hingga 40 karakter. Karakter valid: huruf kecil, angka, tanda hubung (-), dan garis bawah (_). Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertClientVerifyEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil hasil verifikasi sertifikat klien dari field header X-Forwarded-Clientcert-clientverify. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertFingerprintAlias | String | Tidak | Ya | Nama header kustom yang digunakan untuk mengambil sidik jari sertifikat klien. | Parameter ini hanya berlaku jika XForwardedForClientCertFingerprintEnabled diatur ke true. Panjang: 1 hingga 40 karakter. Karakter valid: huruf kecil, angka, tanda hubung (-), dan garis bawah (_). Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertFingerprintEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil sidik jari sertifikat klien dari field header X-Forwarded-Clientcert-fingerprint. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertIssuerDNAlias | String | Tidak | Ya | Nama header kustom yang digunakan untuk mengambil informasi penerbit sertifikat klien. | Parameter ini hanya berlaku jika XForwardedForClientCertIssuerDNEnabled diatur ke true. Panjang: 1 hingga 40 karakter. Karakter valid: huruf kecil, angka, tanda hubung (-), dan garis bawah (_). Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertIssuerDNEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil informasi penerbit sertifikat klien dari field header X-Forwarded-Clientcert-issuerdn. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertSubjectDNAlias | String | Tidak | Ya | Nama header kustom yang digunakan untuk mengambil informasi subjek sertifikat klien. | Parameter ini hanya berlaku jika XForwardedForClientCertSubjectDNEnabled diatur ke true. Panjang: 1 hingga 40 karakter. Karakter valid: huruf kecil, angka, tanda hubung (-), dan garis bawah (_). Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientCertSubjectDNEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil informasi subjek sertifikat klien dari field header X-Forwarded-Clientcert-subjectdn. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTPS. |
XForwardedForClientSourceIpsEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mendapatkan port sumber klien dari field header X-Forwarded-Client-SourceIps. | Nilai valid:
|
XForwardedForClientSourceIpsTrusted | String | Tidak | Ya | Alamat IP proksi tepercaya. | Application Load Balancer (ALB) melintasi field header |
XForwardedForClientSrcPortEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil port klien dari field header X-Forwarded-Client-Port. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTP dan HTTPS. |
XForwardedForEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil alamat IP asal dari field header X-Forwarded-For. | Nilai valid:
Catatan Parameter ini hanya didukung untuk pendengar HTTP dan HTTPS. |
XForwardedForHostEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil nama domain klien dari field header | Nilai valid:
Catatan Parameter ini didukung untuk pendengar HTTP, HTTPS, dan QUIC. |
XForwardedForProcessingMode | String | Tidak | Ya | Mode pemrosesan field header | Nilai ini hanya berlaku jika XForwardedForEnabled diatur ke true. Nilai valid:
Catatan
|
XForwardedForProtoEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil protokol pendengaran dari field header X-Forwarded-Proto. | Nilai valid:
|
XForwardedForSLBIdEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil ID instans ALB dari field header SLB-ID. | Nilai valid:
|
XForwardedForSLBPortEnabled | Boolean | Tidak | Ya | Menentukan apakah akan mengambil port pendengaran dari field header X-Forwarded-Port. | Nilai valid:
|
Sintaksis CaCertificates
"CaCertificates": [
{
"CertificateId": String
}
]Properti CaCertificates
Nama properti | Tipe | Wajib | Pembaruan diizinkan | Deskripsi | Batasan |
CertificateId | String | Tidak | Ya | ID sertifikat CA. | Tidak ada |
Nilai kembalian
Fn::GetAtt
ListenerId: ID pendengar.
LoadBalancerId: ID instans Application Load Balancer (ALB).
Contoh
Skenario 1: Buat pendengar HTTP.
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
LoadBalancerId:
Type: String
Description: The ID of the ALB instance.
Default: lb-bp1iilcd9ujny84z8****
Resources:
Listener:
Type: ALIYUN::ALB::Listener
Properties:
ListenerPort: 80
DefaultActions:
- ForwardGroupConfig:
ServerGroupTuples:
- ServerGroupId: sgp-46ndzg2wz4v5mp****
Type: ForwardGroup
LoadBalancerId:
Ref: LoadBalancerId
ListenerProtocol: HTTP
Outputs:
ListenerId:
Description: The ID of the listener.
Value:
Fn::GetAtt:
- Listener
- ListenerId {
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"LoadBalancerId": {
"Type": "String",
"Description": "The ID of the ALB instance.",
"Default": "lb-bp1iilcd9ujny84z8****"
}
},
"Resources": {
"Listener": {
"Type": "ALIYUN::ALB::Listener",
"Properties": {
"ListenerPort": 80,
"DefaultActions": [
{
"ForwardGroupConfig": {
"ServerGroupTuples": [
{
"ServerGroupId": "sgp-46ndzg2wz4v5mp****"
}
]
},
"Type": "ForwardGroup"
}
],
"LoadBalancerId": {
"Ref": "LoadBalancerId"
},
"ListenerProtocol": "HTTP"
}
}
},
"Outputs": {
"ListenerId": {
"Description": "The ID of the listener.",
"Value": {
"Fn::GetAtt": [
"Listener",
"ListenerId"
]
}
}
}
}Skenario 2: Buat instans ALB dua zona dan pendengar HTTP.
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: Create a dual-Availability-Zone ALB.
en: Create a dual-Availability-Zone ALB.
Parameters:
CommonName:
Type: String
Default: elastic-app
ZoneId1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId2
Label:
en: Availability Zone
zh-cn: Zone 1
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: Zone 2
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
CidrBlock: 192.168.0.0/16
VpcName:
Fn::Sub: ${CommonName}-vpc
VSwitch1:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.1.0/24
ZoneId:
Ref: ZoneId1
VSwitchName:
Fn::Sub: ${CommonName}-vsw
VSwitch2:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.2.0/24
ZoneId:
Ref: ZoneId2
VSwitchName:
Fn::Sub: ${CommonName}-vsw
Alb:
Type: 'ALIYUN::ALB::LoadBalancer'
Properties:
LoadBalancerName:
Fn::Sub: ${CommonName}-alb
LoadBalancerEdition: Basic
VpcId:
Ref: Vpc
LoadBalancerBillingConfig:
PayType: PostPay
AddressType: Internet
ZoneMappings:
- ZoneId:
Ref: ZoneId1
VSwitchId:
Ref: VSwitch1
- ZoneId:
Ref: ZoneId2
VSwitchId:
Ref: VSwitch2
AlbServerGroup:
Type: 'ALIYUN::ALB::ServerGroup'
Properties:
VpcId:
Ref: Vpc
ServerGroupType: Instance
ServerGroupName:
Fn::Sub: ${CommonName}-server-group
HealthCheckConfig:
HealthCheckConnectPort: 80
HealthCheckCodes:
- http_2xx
- http_3xx
HealthCheckProtocol: HTTP
HealthCheckEnabled: true
HealthCheckPath: /
StickySessionConfig:
StickySessionEnabled: false
AlbListener:
Type: 'ALIYUN::ALB::Listener'
Properties:
ListenerPort: 80
DefaultActions:
- Type: ForwardGroup
ForwardGroupConfig:
ServerGroupTuples:
- ServerGroupId:
Ref: AlbServerGroup
LoadBalancerId:
Ref: Alb
ListenerProtocol: HTTP
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId1
- ZoneId2
Hidden:
- CommonName
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "Create a dual-Availability-Zone ALB.",
"en": "Create a dual-Availability-Zone ALB."
},
"Parameters": {
"CommonName": {
"Type": "String",
"Default": "elastic-app"
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "Zone 1"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "Zone 2"
}
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16",
"VpcName": {
"Fn::Sub": "${CommonName}-vpc"
}
}
},
"VSwitch1": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.1.0/24",
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
}
}
},
"VSwitch2": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.2.0/24",
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
}
}
},
"Alb": {
"Type": "ALIYUN::ALB::LoadBalancer",
"Properties": {
"LoadBalancerName": {
"Fn::Sub": "${CommonName}-alb"
},
"LoadBalancerEdition": "Basic",
"VpcId": {
"Ref": "Vpc"
},
"LoadBalancerBillingConfig": {
"PayType": "PostPay"
},
"AddressType": "Internet",
"ZoneMappings": [
{
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchId": {
"Ref": "VSwitch1"
}
},
{
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchId": {
"Ref": "VSwitch2"
}
}
]
}
},
"AlbServerGroup": {
"Type": "ALIYUN::ALB::ServerGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"ServerGroupType": "Instance",
"ServerGroupName": {
"Fn::Sub": "${CommonName}-server-group"
},
"HealthCheckConfig": {
"HealthCheckConnectPort": 80,
"HealthCheckCodes": [
"http_2xx",
"http_3xx"
],
"HealthCheckProtocol": "HTTP",
"HealthCheckEnabled": true,
"HealthCheckPath": "/"
},
"StickySessionConfig": {
"StickySessionEnabled": false
}
}
},
"AlbListener": {
"Type": "ALIYUN::ALB::Listener",
"Properties": {
"ListenerPort": 80,
"DefaultActions": [
{
"Type": "ForwardGroup",
"ForwardGroupConfig": {
"ServerGroupTuples": [
{
"ServerGroupId": {
"Ref": "AlbServerGroup"
}
}
]
}
}
],
"LoadBalancerId": {
"Ref": "Alb"
},
"ListenerProtocol": "HTTP"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId1",
"ZoneId2"
]
}
],
"Hidden": [
"CommonName"
]
}
}
}Skenario 3: Menerapkan situs web NGINX dengan ketersediaan tinggi.
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: Create a dual-Availability-Zone high-availability NGINX website, including a VPC, ECS instances, an ALB, security groups, and automated deployment configurations.
en: Establish a dual-Availability-Zone high-availability NGINX website, encompassing a Virtual Private Cloud (VPC), Elastic Cloud Server (ECS) instances, an Application Load Balancer (ALB), Security Groups, and automated deployment configurations.
Parameters:
CommonName:
Type: String
Default: elastic-app
ZoneId1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
AutoSelectFirst: true
ExclusiveTo:
- ZoneId2
Label:
en: Availability Zone
zh-cn: Zone 1
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
AutoSelectFirst: true
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: Zone 2
InstanceType1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
SpotStrategy: SpotAsPriceGo
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: Instance Type
zh-cn: Instance type 1
Description:
zh-cn: This solution creates a spot instance and automatically deploys an NGINX service.
en: This solution will create a spot instance and automatically deploy an NGINX service.
Default: null
InstanceType2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
SpotStrategy: SpotAsPriceGo
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: Instance Type
zh-cn: Instance type 2
Description:
zh-cn: This solution creates a spot instance and automatically deploys an NGINX service.
en: This solution will create a spot instance and automatically deploy an NGINX service.
Default: null
InstancePassword:
NoEcho: true
Type: String
Description:
en: Server login password. Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
zh-cn: Server logon password. Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
Label:
en: Instance Password
zh-cn: Instance password
ConstraintDescription:
en: Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
zh-cn: Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
Default: null
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
CidrBlock: 192.168.0.0/16
VpcName:
Fn::Sub: ${CommonName}-vpc
VSwitch1:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.1.0/24
ZoneId:
Ref: ZoneId1
VSwitchName:
Fn::Sub: ${CommonName}-vsw
VSwitch2:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.2.0/24
ZoneId:
Ref: ZoneId2
VSwitchName:
Fn::Sub: ${CommonName}-vsw
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: ${CommonName}-sg
SecurityGroupIngress:
- PortRange: 443/443
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
EcsInstance1:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId1
VSwitchId:
Ref: VSwitch1
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_9_x64_20G_alibase_
InstanceName:
Fn::Sub: ${CommonName}-ecs-1
InstanceType:
Ref: InstanceType1
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 0
SpotStrategy: SpotAsPriceGo
Password:
Ref: InstancePassword
UserData:
Fn::Sub: |-
#!/bin/bash
yum -y install nginx-1.20.1
instanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`
echo "Welcome to NGINX. Current instance is $instanceId" > /usr/share/nginx/html/index.html
systemctl start nginx
systemctl enable nginx
EcsInstance2:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId2
VSwitchId:
Ref: VSwitch2
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_9_x64_20G_alibase_
InstanceName:
Fn::Sub: ${CommonName}-ecs-2
InstanceType:
Ref: InstanceType2
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 0
SpotStrategy: SpotAsPriceGo
Password:
Ref: InstancePassword
UserData:
Fn::Sub: |-
#!/bin/bash
yum -y install nginx-1.20.1
instanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`
echo "Welcome to NGINX. Current instance is $instanceId" > /usr/share/nginx/html/index.html
systemctl start nginx
systemctl enable nginx
Alb:
Type: 'ALIYUN::ALB::LoadBalancer'
Properties:
LoadBalancerName:
Fn::Sub: ${CommonName}-alb
LoadBalancerEdition: Basic
VpcId:
Ref: Vpc
LoadBalancerBillingConfig:
PayType: PostPay
AddressType: Internet
ZoneMappings:
- ZoneId:
Ref: ZoneId1
VSwitchId:
Ref: VSwitch1
- ZoneId:
Ref: ZoneId2
VSwitchId:
Ref: VSwitch2
AlbServerGroup:
Type: 'ALIYUN::ALB::ServerGroup'
Properties:
VpcId:
Ref: Vpc
ServerGroupType: Instance
ServerGroupName:
Fn::Sub: ${CommonName}-server-group
HealthCheckConfig:
HealthCheckConnectPort: 80
HealthCheckCodes:
- http_2xx
- http_3xx
HealthCheckProtocol: HTTP
HealthCheckEnabled: true
HealthCheckPath: /
StickySessionConfig:
StickySessionEnabled: false
AlbBackendServerAttachment:
Type: 'ALIYUN::ALB::BackendServerAttachment'
Properties:
ServerGroupId:
Ref: AlbServerGroup
Servers:
- ServerType: Ecs
ServerId:
Ref: EcsInstance1
Port: 80
- ServerType: Ecs
ServerId:
Ref: EcsInstance2
Port: 80
AlbListener:
Type: 'ALIYUN::ALB::Listener'
Properties:
ListenerPort: 80
DefaultActions:
- Type: ForwardGroup
ForwardGroupConfig:
ServerGroupTuples:
- ServerGroupId:
Ref: AlbServerGroup
LoadBalancerId:
Ref: Alb
ListenerProtocol: HTTP
Outputs:
WebUrl:
Description:
zh-cn: Web access URL.
en: The web access URL.
Value:
'Fn::Sub': 'http://${Alb.DNSName}'
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId1
- InstanceType1
- ZoneId2
- InstanceType2
- InstancePassword
TemplateTags:
- acs:example:elastic computing:Deploy a high-availability NGINX website
Hidden:
- CommonName
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "Create a dual-Availability-Zone high-availability NGINX website, including a VPC, ECS instances, an ALB, security groups, and automated deployment configurations.",
"en": "Establish a dual-Availability-Zone high-availability NGINX website, encompassing a Virtual Private Cloud (VPC), Elastic Cloud Server (ECS) instances, an Application Load Balancer (ALB), Security Groups, and automated deployment configurations."
},
"Parameters": {
"CommonName": {
"Type": "String",
"Default": "elastic-app"
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"AutoSelectFirst": true,
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "Zone 1"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"AutoSelectFirst": true,
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "Zone 2"
}
},
"InstanceType1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"SpotStrategy": "SpotAsPriceGo",
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "Instance Type",
"zh-cn": "Instance type 1"
},
"Description": {
"zh-cn": "This solution creates a spot instance and automatically deploys an NGINX service.",
"en": "This solution will create a spot instance and automatically deploy an NGINX service."
},
"Default": null
},
"InstanceType2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"SpotStrategy": "SpotAsPriceGo",
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "Instance Type",
"zh-cn": "Instance type 2"
},
"Description": {
"zh-cn": "This solution creates a spot instance and automatically deploys an NGINX service.",
"en": "This solution will create a spot instance and automatically deploy an NGINX service."
},
"Default": null
},
"InstancePassword": {
"NoEcho": true,
"Type": "String",
"Description": {
"en": "Server login password. Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/",
"zh-cn": "Server logon password. Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
},
"Label": {
"en": "Instance Password",
"zh-cn": "Instance password"
},
"ConstraintDescription": {
"en": "Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/",
"zh-cn": "Length: 8 to 30 characters. Must contain three of the following: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
},
"AssociationProperty": "ALIYUN::ECS::Instance::Password",
"Default": null
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16",
"VpcName": {
"Fn::Sub": "${CommonName}-vpc"
}
}
},
"VSwitch1": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.1.0/24",
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
}
}
},
"VSwitch2": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.2.0/24",
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
}
}
},
"SecurityGroup": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupName": {
"Fn::Sub": "${CommonName}-sg"
},
"SecurityGroupIngress": [
{
"PortRange": "443/443",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
},
{
"PortRange": "80/80",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
}
]
}
},
"EcsInstance1": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchId": {
"Ref": "VSwitch1"
},
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"ImageId": "aliyun_3_9_x64_20G_alibase_",
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs-1"
},
"InstanceType": {
"Ref": "InstanceType1"
},
"SystemDiskCategory": "cloud_essd",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 0,
"SpotStrategy": "SpotAsPriceGo",
"Password": {
"Ref": "InstancePassword"
},
"UserData": {
"Fn::Sub": "#!/bin/bash\nyum -y install nginx-1.20.1\ninstanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`\necho \"Welcome to NGINX. Current instance is $instanceId\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
}
}
},
"EcsInstance2": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchId": {
"Ref": "VSwitch2"
},
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"ImageId": "aliyun_3_9_x64_20G_alibase_",
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs-2"
},
"InstanceType": {
"Ref": "InstanceType2"
},
"SystemDiskCategory": "cloud_essd",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 0,
"SpotStrategy": "SpotAsPriceGo",
"Password": {
"Ref": "InstancePassword"
},
"UserData": {
"Fn::Sub": "#!/bin/bash\nyum -y install nginx-1.20.1\ninstanceId=`curl http://100.100.100.200/latest/meta-data/instance-id`\necho \"Welcome to NGINX. Current instance is $instanceId\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
}
}
},
"Alb": {
"Type": "ALIYUN::ALB::LoadBalancer",
"Properties": {
"LoadBalancerName": {
"Fn::Sub": "${CommonName}-alb"
},
"LoadBalancerEdition": "Basic",
"VpcId": {
"Ref": "Vpc"
},
"LoadBalancerBillingConfig": {
"PayType": "PostPay"
},
"AddressType": "Internet",
"ZoneMappings": [
{
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchId": {
"Ref": "VSwitch1"
}
},
{
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchId": {
"Ref": "VSwitch2"
}
}
]
}
},
"AlbServerGroup": {
"Type": "ALIYUN::ALB::ServerGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"ServerGroupType": "Instance",
"ServerGroupName": {
"Fn::Sub": "${CommonName}-server-group"
},
"HealthCheckConfig": {
"HealthCheckConnectPort": 80,
"HealthCheckCodes": [
"http_2xx",
"http_3xx"
],
"HealthCheckProtocol": "HTTP",
"HealthCheckEnabled": true,
"HealthCheckPath": "/"
},
"StickySessionConfig": {
"StickySessionEnabled": false
}
}
},
"AlbBackendServerAttachment": {
"Type": "ALIYUN::ALB::BackendServerAttachment",
"Properties": {
"ServerGroupId": {
"Ref": "AlbServerGroup"
},
"Servers": [
{
"ServerType": "Ecs",
"ServerId": {
"Ref": "EcsInstance1"
},
"Port": 80
},
{
"ServerType": "Ecs",
"ServerId": {
"Ref": "EcsInstance2"
},
"Port": 80
}
]
}
},
"AlbListener": {
"Type": "ALIYUN::ALB::Listener",
"Properties": {
"ListenerPort": 80,
"DefaultActions": [
{
"Type": "ForwardGroup",
"ForwardGroupConfig": {
"ServerGroupTuples": [
{
"ServerGroupId": {
"Ref": "AlbServerGroup"
}
}
]
}
}
],
"LoadBalancerId": {
"Ref": "Alb"
},
"ListenerProtocol": "HTTP"
}
}
},
"Outputs": {
"WebUrl": {
"Description": {
"zh-cn": "Web access URL.",
"en": "The web access URL."
},
"Value": {
"Fn::Sub": "http://${Alb.DNSName}"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId1",
"InstanceType1",
"ZoneId2",
"InstanceType2",
"InstancePassword"
]
}
],
"TemplateTags": [
"acs:example:elastic computing:Deploy a high-availability NGINX website"
],
"Hidden": [
"CommonName"
]
}
}
}Untuk contoh lainnya, lihat templat publik yang mencakup resource ini.