全部产品
Search
文档中心

Resource Orchestration Service:ALIYUN::ALB::Listener

更新时间:Feb 07, 2026

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:

[
        {
          "ForwardGroupConfig": {
            "ServerGroupTuples": [
              {
                "ServerGroupId": "sgp-46ndzg2wz4v5mp****"
              }
            ]
          },
          "Type": "ForwardGroup"
        }
      ]

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:

  • HTTP

  • HTTPS

  • QUIC

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:

  • true: mengaktifkan otentikasi timbal balik.

  • false (default): menonaktifkan otentikasi timbal balik.

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:

  • true (default): mengaktifkan kompresi Gzip.

  • false: menonaktifkan kompresi Gzip.

Http2Enabled

Boolean

Tidak

Ya

Menentukan apakah akan mengaktifkan HTTP/2.

Nilai valid:

  • true (default): mengaktifkan HTTP/2.

  • false: menonaktifkan HTTP/2.

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:

  • Status: running.

  • Stopped: Pendengar dihentikan.

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
  • Parameter ini hanya didukung untuk pendengar HTTPS.

  • Pendengar asli dan pendengar QUIC terkait harus berada dalam instans ALB yang sama. Pendengar QUIC tidak boleh telah dikaitkan dengan pendengar lain.

QuicUpgradeEnabled

Boolean

Tidak

Ya

Menentukan apakah akan mengaktifkan peningkatan QUIC.

Nilai valid:

  • true: Mengaktifkan fitur.

  • false (default): matikan.

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:

  • True berarti diaktifkan.

  • Nilai `false` menunjukkan dimatikan.

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:

  • true: Ya.

  • false: Tidak.

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:

  • True menunjukkan lulus.

  • false (nilai default): Menunjukkan gagal.

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:

  • true: Uji lulus.

  • false (nilai default): Operasi gagal.

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:

  • true: Operasi berhasil.

  • false (default): Gagal.

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:

  • true: Uji lulus.

  • false (default): Dinonaktifkan.

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:

  • true: lulus.

  • false (default): Operasi gagal.

XForwardedForClientSourceIpsTrusted

String

Tidak

Ya

Alamat IP proksi tepercaya.

Application Load Balancer (ALB) melintasi field header X-Forwarded-For dari kanan ke kiri. ALB memilih alamat IP pertama yang tidak ada dalam daftar IP tepercaya sebagai alamat IP asal. Alamat IP ini digunakan untuk pembatasan kecepatan berbasis IP sumber.

XForwardedForClientSrcPortEnabled

Boolean

Tidak

Ya

Menentukan apakah akan mengambil port klien dari field header X-Forwarded-Client-Port.

Nilai valid:

  • True menunjukkan lulus.

  • false (nilai default): Permintaan tidak lolos.

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:

  • true (nilai default): Lolos.

  • false: Operasi gagal.

Catatan

Parameter ini hanya didukung untuk pendengar HTTP dan HTTPS.

XForwardedForHostEnabled

Boolean

Tidak

Ya

Menentukan apakah akan mengambil nama domain klien dari field header X-Forwarded-Host.

Nilai valid:

  • true: Ya.

  • false (default): Tidak.

Catatan

Parameter ini didukung untuk pendengar HTTP, HTTPS, dan QUIC.

XForwardedForProcessingMode

String

Tidak

Ya

Mode pemrosesan field header X-Forwarded-For.

Nilai ini hanya berlaku jika XForwardedForEnabled diatur ke true. Nilai valid:

  • append (nilai default): tambahkan.

  • remove: hapus.

Catatan
  • Atur append untuk menambahkan alamat IP hop terakhir ke header X-Forwarded-For sebelum mengirim permintaan ke layanan backend.

  • Atur remove untuk menghapus header X-Forwarded-For sebelum mengirim permintaan ke layanan backend, terlepas dari apakah permintaan tersebut menyertakan header X-Forwarded-For.

  • Parameter ini berlaku untuk pendengar HTTP dan HTTPS.

XForwardedForProtoEnabled

Boolean

Tidak

Ya

Menentukan apakah akan mengambil protokol pendengaran dari field header X-Forwarded-Proto.

Nilai valid:

  • true: Pemeriksaan lolos.

  • false (nilai default): Permintaan tidak lolos.

XForwardedForSLBIdEnabled

Boolean

Tidak

Ya

Menentukan apakah akan mengambil ID instans ALB dari field header SLB-ID.

Nilai valid:

  • True berarti lolos.

  • false (default): Pemeriksaan gagal.

XForwardedForSLBPortEnabled

Boolean

Tidak

Ya

Menentukan apakah akan mengambil port pendengaran dari field header X-Forwarded-Port.

Nilai valid:

  • true: Pemeriksaan lolos.

  • false (default): tidak lolos.

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.

Buat cepat

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.

Buat cepat

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.

Buat cepat

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.