Tous les produits
Search
Centre de documentation

Resource Orchestration Service:ALIYUN::ALB::Listener

Dernière mise à jour :Aug 12, 2026

Crée un écouteur HTTP, HTTPS ou QUIC pour une instance Application Load Balancer (ALB).

Syntaxe

{
  "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
  }
}

Propriétés

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

DefaultActions

List

Oui

Oui

Liste des actions de règle.

Valeur d'exemple :

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

Pour plus d'informations, consultez Propriété DefaultActions.

ListenerPort

Integer

Oui

Non

Port d'écoute.

Valeurs valides : 1 à 65535.

ListenerProtocol

String

Oui

Non

Protocole d'écoute.

Valeurs valides :

  • HTTP

  • HTTPS

  • QUIC

LoadBalancerId

String

Oui

Non

ID de l'instance Application Load Balancer (ALB).

Aucune

CaCertificates

List

Non

Oui

Informations sur le certificat CA.

Pour plus d'informations, consultez Propriété CaCertificates.

CaEnabled

Boolean

Non

Oui

Indique s'il faut activer l'authentification mutuelle.

Valeurs valides :

  • true : active l'authentification mutuelle.

  • false (par défaut) : désactive l'authentification mutuelle.

Certificates

List

Non

Oui

Certificats serveur.

Pour plus d'informations, consultez Propriété Certificates.

GzipEnabled

Boolean

Non

Oui

Indique s'il faut activer la compression Gzip pour certains types de fichiers.

Valeurs valides :

  • true (par défaut) : active la compression Gzip.

  • false : désactive la compression Gzip.

Http2Enabled

Boolean

Non

Oui

Indique s'il faut activer HTTP/2.

Valeurs valides :

  • true (par défaut) : active HTTP/2.

  • false : désactive HTTP/2.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

IdleTimeout

Integer

Non

Oui

Délai d'inactivité de la connexion.

Valeurs valides : 1 à 60.

Valeur par défaut : 15.

Unité : secondes.

Si aucune requête n'est reçue pendant cette période, l'équilibreur de charge ferme temporairement la connexion et la rétablit lors de la requête suivante.

ListenerDescription

String

Non

Oui

Description de l'écouteur.

Longueur : 2 à 256 caractères.

ListenerStatus

String

Non

Oui

État de l'écouteur.

Valeurs valides :

  • Running : en cours d'exécution.

  • Stopped : l'écouteur est arrêté.

LogConfig

Map

Non

Oui

Configuration des journaux.

Pour plus d'informations, consultez Propriété LogConfig.

QuicConfig

Map

Non

Oui

Configuration de l'écouteur QUIC associé.

Pour plus d'informations, consultez Propriété QuicConfig.

RequestTimeout

Integer

Non

Oui

Délai d'expiration de la requête.

Valeurs valides : 1 à 180.

Valeur par défaut : 60.

Unité : secondes.

Si le serveur backend ne répond pas dans ce délai, l'équilibreur de charge renvoie une erreur HTTP 504 au client.

SecurityPolicyId

String

Non

Oui

ID de la politique de sécurité.

Vous pouvez utiliser des politiques de sécurité système ou personnalisées.

Valeur par défaut : tls_cipher_policy_1_0, qui correspond à une politique de sécurité définie par le système.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForConfig

Map

Non

Oui

Configuration du champ d'en-tête X-Forwarded-For.

Pour plus d'informations, consultez Propriété XForwardedForConfig.

Syntaxe DefaultActions

"DefaultActions": [
  {
    "Type": String,
    "ForwardGroupConfig": Map
  }
]

Propriété DefaultActions

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

ForwardGroupConfig

Map

Oui

Oui

Configuration de l'action de transfert.

Pour plus d'informations, consultez Propriété ForwardGroupConfig.

Type

String

Oui

Oui

Type d'action.

Définissez ce paramètre sur ForwardGroup pour transférer les requêtes vers plusieurs groupes vServer.

Syntaxe ForwardGroupConfig

"ForwardGroupConfig": {
  "ServerGroupTuples": List
}

Propriétés ForwardGroupConfig

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

ServerGroupTuples

List

Oui

Oui

Groupe vServer de destination pour le transfert.

Pour plus d'informations, consultez Propriété ServerGroupTuples.

Syntaxe ServerGroupTuples

"ServerGroupTuples": [
  {
    "ServerGroupId": String
  }
]

Propriétés ServerGroupTuples

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

ServerGroupId

String

Oui

Oui

ID du groupe vServer de destination pour le transfert.

Aucune

Syntaxe Certificates

"Certificates": [
  {
    "CertificateId": String
  }
]

Propriétés Certificates

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

CertificateId

String

Non

Oui

ID du certificat serveur.

Seuls les certificats serveur sont pris en charge.

Syntaxe QuicConfig

"QuicConfig": {
  "QuicListenerId": String,
  "QuicUpgradeEnabled": Boolean
}

Propriétés QuicConfig

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

QuicListenerId

String

Non

Oui

ID de l'écouteur QUIC à associer.

Vous devez spécifier ce paramètre si QuicUpgradeEnabled est défini sur true.

Remarque
  • Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

  • L'écouteur d'origine et l'écouteur QUIC associé doivent appartenir à la même instance ALB. L'écouteur QUIC ne doit pas avoir été associé à un autre écouteur.

QuicUpgradeEnabled

Boolean

Non

Oui

Indique s'il faut activer la mise à niveau QUIC.

Valeurs valides :

  • true : active la mise à niveau QUIC.

  • false (par défaut) : désactive la mise à niveau QUIC.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

Syntaxe LogConfig

"LogConfig": {
  "AccessLogTracingConfig": Map,
  "AccessLogRecordCustomizedHeadersEnabled": Boolean
}

Propriétés LogConfig

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

AccessLogTracingConfig

Map

Non

Oui

Configuration X-Trace pour les journaux d'accès.

Pour plus d'informations, consultez Propriété AccessLogTracingConfig.

AccessLogRecordCustomizedHeadersEnabled

Boolean

Non

Oui

Indique s'il faut inclure les en-têtes personnalisés dans les journaux d'accès.

Valeurs valides :

  • true : activé.

  • false : désactivé.

Syntaxe AccessLogTracingConfig

"AccessLogTracingConfig": {
  "TracingSample": Integer,
  "TracingType": String,
  "TracingEnabled": Boolean
}

Propriétés AccessLogTracingConfig

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

TracingEnabled

Boolean

Non

Oui

Indique s'il faut activer X-Trace.

Valeurs valides :

  • true : activé.

  • false : désactivé.

Remarque

Vous pouvez définir ce paramètre sur true uniquement si la fonctionnalité de journal d'accès (AccessLogEnabled) est activée.

TracingSample

Integer

Non

Oui

Taux d'échantillonnage pour X-Trace.

Valeur valide : 1 à 10000.

Remarque

Cette valeur prend effet uniquement si TracingEnabled est défini sur true.

TracingType

String

Non

Oui

Type X-Trace.

Valeur valide : Zipkin.

Remarque

Cette valeur prend effet uniquement si TracingEnabled est défini sur true.

Syntaxe 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
}

Propriétés XForwardedForConfig

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

XForwardedForClientCertClientVerifyAlias

String

Non

Oui

Nom de l'en-tête personnalisé utilisé pour récupérer le résultat de vérification du certificat client.

Ce paramètre prend effet uniquement si XForwardedForClientCertClientVerifyEnabled est défini sur true.

Longueur : 1 à 40 caractères. Caractères valides : lettres minuscules, chiffres, tirets (-) et traits de soulignement (_).

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertClientVerifyEnabled

Boolean

Non

Oui

Indique s'il faut récupérer le résultat de vérification du certificat client depuis le champ d'en-tête X-Forwarded-Clientcert-clientverify.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertFingerprintAlias

String

Non

Oui

Nom de l'en-tête personnalisé utilisé pour récupérer l'empreinte du certificat client.

Ce paramètre prend effet uniquement si XForwardedForClientCertFingerprintEnabled est défini sur true.

Longueur : 1 à 40 caractères. Caractères valides : lettres minuscules, chiffres, tirets (-) et traits de soulignement (_).

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertFingerprintEnabled

Boolean

Non

Oui

Indique s'il faut récupérer l'empreinte du certificat client depuis le champ d'en-tête X-Forwarded-Clientcert-fingerprint.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertIssuerDNAlias

String

Non

Oui

Nom de l'en-tête personnalisé utilisé pour récupérer les informations sur l'émetteur du certificat client.

Ce paramètre prend effet uniquement si XForwardedForClientCertIssuerDNEnabled est défini sur true.

Longueur : 1 à 40 caractères. Caractères valides : lettres minuscules, chiffres, tirets (-) et traits de soulignement (_).

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertIssuerDNEnabled

Boolean

Non

Oui

Indique s'il faut récupérer les informations sur l'émetteur du certificat client depuis le champ d'en-tête X-Forwarded-Clientcert-issuerdn.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertSubjectDNAlias

String

Non

Oui

Nom de l'en-tête personnalisé utilisé pour récupérer les informations sur le sujet du certificat client.

Ce paramètre prend effet uniquement si XForwardedForClientCertSubjectDNEnabled est défini sur true.

Longueur : 1 à 40 caractères. Caractères valides : lettres minuscules, chiffres, tirets (-) et traits de soulignement (_).

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientCertSubjectDNEnabled

Boolean

Non

Oui

Indique s'il faut récupérer les informations sur le sujet du certificat client depuis le champ d'en-tête X-Forwarded-Clientcert-subjectdn.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTPS.

XForwardedForClientSourceIpsEnabled

Boolean

Non

Oui

Indique s'il faut obtenir le port source du client depuis le champ d'en-tête X-Forwarded-Client-SourceIps.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

XForwardedForClientSourceIpsTrusted

String

Non

Oui

Adresse IP du proxy de confiance.

Application Load Balancer (ALB) parcourt le champ d'en-tête X-Forwarded-For de droite à gauche. ALB sélectionne la première adresse IP qui ne figure pas dans la liste des IP de confiance comme adresse IP d'origine. Cette adresse IP est utilisée pour la limitation basée sur l'IP source.

XForwardedForClientSrcPortEnabled

Boolean

Non

Oui

Indique s'il faut récupérer le port client depuis le champ d'en-tête X-Forwarded-Client-Port.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTP et HTTPS.

XForwardedForEnabled

Boolean

Non

Oui

Indique s'il faut récupérer l'adresse IP d'origine depuis le champ d'en-tête X-Forwarded-For.

Valeurs valides :

  • true (par défaut) : activé.

  • false : désactivé.

Remarque

Ce paramètre est pris en charge uniquement pour les écouteurs HTTP et HTTPS.

XForwardedForHostEnabled

Boolean

Non

Oui

Indique s'il faut récupérer le nom de domaine du client depuis le champ d'en-tête X-Forwarded-Host.

Valeurs valides :

  • true : Oui.

  • false (par défaut) : Non.

Remarque

Ce paramètre est pris en charge pour les écouteurs HTTP, HTTPS et QUIC.

XForwardedForProcessingMode

String

Non

Oui

Mode de traitement du champ d'en-tête X-Forwarded-For.

Cette valeur prend effet uniquement si XForwardedForEnabled est défini sur true. Valeurs valides :

  • append (valeur par défaut) : Ajouter.

  • remove : supprimer.

Remarque
  • Définissez append pour ajouter l'adresse IP du dernier saut à l'en-tête X-Forwarded-For avant d'envoyer la requête au service backend.

  • Définissez remove pour supprimer l'en-tête X-Forwarded-For avant d'envoyer la requête au service backend, que la requête inclue ou non l'en-tête X-Forwarded-For.

  • Ce paramètre s'applique aux écouteurs HTTP et HTTPS.

XForwardedForProtoEnabled

Boolean

Non

Oui

Indique s'il faut récupérer le protocole d'écoute depuis le champ d'en-tête X-Forwarded-Proto.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

XForwardedForSLBIdEnabled

Boolean

Non

Oui

Indique s'il faut récupérer l'ID de l'instance ALB depuis le champ d'en-tête SLB-ID.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

XForwardedForSLBPortEnabled

Boolean

Non

Oui

Indique s'il faut récupérer le port d'écoute depuis le champ d'en-tête X-Forwarded-Port.

Valeurs valides :

  • true : activé.

  • false (par défaut) : désactivé.

Syntaxe CaCertificates

"CaCertificates": [
  {
    "CertificateId": String
  }
]

Propriétés CaCertificates

Nom de la propriété

Type

Obligatoire

Mise à jour autorisée

Description

Contrainte

CertificateId

String

Non

Oui

ID du certificat CA.

Aucune

Valeurs de retour

Fn::GetAtt

  • ListenerId : ID de l'écouteur.

  • LoadBalancerId : ID de l'instance Application Load Balancer (ALB).

Exemples

Scénario 1 : Créer un écouteur HTTP.

Création rapide

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"
        ]
      }
    }
  }
}

Scénario 2 : Créer une instance ALB double zone et un écouteur HTTP.

Création rapide

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"
      ]
    }
  }
}

Scénario 3 : Déployer un site web NGINX haute disponibilité.

Création rapide

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"
      ]
    }
  }
}

Pour plus d'exemples, consultez les modèles publics incluant cette ressource.