すべてのプロダクト
Search
ドキュメントセンター

Resource Orchestration Service:ALIYUN::ALB::Listener

最終更新日:Feb 07, 2026

ALIYUN::ALB::Listener リソースタイプは、Application Load Balancer (ALB) インスタンス向けに HTTP、HTTPS、または QUIC リスナーを作成します。

構文

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

プロパティ

プロパティ名

必須

更新可

説明

制約

DefaultActions

List

はい

はい

ルールアクションのリストです。

例:

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

詳細については、「DefaultActions プロパティ」をご参照ください。

ListenerPort

Integer

はい

いいえ

リスニングポートです。

有効な値: 1 ~ 65535。

ListenerProtocol

String

はい

いいえ

リスニングプロトコルです。

有効な値:

  • HTTP

  • HTTPS

  • QUIC

LoadBalancerId

String

はい

いいえ

Application Load Balancer (ALB) インスタンスの ID です。

なし

CaCertificates

List

いいえ

はい

CA 証明書の情報です。

詳細については、「CaCertificates プロパティ」をご参照ください。

CaEnabled

Boolean

いいえ

はい

相互認証を有効にするかどうかを指定します。

有効な値:

  • true: 相互認証を有効にします。

  • false (デフォルト): 相互認証を無効にします。

Certificates

List

いいえ

はい

証明書です。

詳細については、「Certificates プロパティ」をご参照ください。

GzipEnabled

Boolean

いいえ

はい

特定のファイルタイプに対して Gzip 圧縮を有効にするかどうかを指定します。

有効な値:

  • true (デフォルト): Gzip 圧縮を有効にします。

  • false: Gzip 圧縮を無効にします。

Http2Enabled

Boolean

いいえ

はい

HTTP/2 を有効にするかどうかを指定します。

有効な値:

  • true (デフォルト): HTTP/2 を有効にします。

  • false: HTTP/2 を無効にします。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

IdleTimeout

Integer

いいえ

はい

接続アイドルタイムアウト期間です。

有効な値: 1 ~ 60。

デフォルト値: 15。

単位: 秒。

タイムアウト期間内にリクエストが到着しなかった場合、ロードバランサーは現在の接続を一時的に閉じます。次のリクエストが到着すると、ロードバランサーは新しい接続を再確立します。

ListenerDescription

String

いいえ

はい

リスナーの説明です。

長さ: 2 ~ 256 文字。

ListenerStatus

String

いいえ

はい

リスナーのステータスです。

有効な値:

  • Status: 実行中。

  • Stopped: リスナーが停止しています。

LogConfig

Map

いいえ

はい

ログ構成です。

詳細については、「LogConfig プロパティ」をご参照ください。

QuicConfig

Map

いいえ

はい

関連付けられた QUIC リスナーの構成です。

詳細については、「QuicConfig プロパティ」をご参照ください。

RequestTimeout

Integer

いいえ

はい

リクエストタイムアウト期間です。

有効な値: 1 ~ 180。

デフォルト値: 60。

単位: 秒。

バックエンドサーバーがタイムアウト期間内に応答しない場合、ロードバランサーは待機を中止し、クライアントに HTTP エラーコード 504 を返します。

SecurityPolicyId

String

いいえ

はい

セキュリティポリシーの ID です。

システム定義またはカスタムのセキュリティポリシーを使用できます。

デフォルト値: tls_cipher_policy_1_0 (システム定義のセキュリティポリシー)。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForConfig

Map

いいえ

はい

X-Forwarded-For ヘッダーの構成です。

詳細については、「XForwardedForConfig プロパティ」をご参照ください。

DefaultActions の構文

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

DefaultActions プロパティ

プロパティ名

必須

更新可

説明

制約

ForwardGroupConfig

Map

はい

はい

転送操作の構成です。

詳細については、「ForwardGroupConfig プロパティ」をご参照ください。

Type

String

はい

はい

操作タイプです。

複数の vServer グループにリクエストを転送する場合は、このパラメーターを ForwardGroup に設定します。

ForwardGroupConfig の構文

"ForwardGroupConfig": {
  "ServerGroupTuples": List
}

ForwardGroupConfig のプロパティ

プロパティ名

必須

更新可

説明

制約

ServerGroupTuples

List

はい

はい

転送先の vServer グループです。

詳細については、「ServerGroupTuples プロパティ」をご参照ください。

ServerGroupTuples の構文

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

ServerGroupTuples のプロパティ

プロパティ名

必須

更新可

説明

制約

ServerGroupId

String

はい

はい

転送先の vServer グループの ID です。

なし

Certificates の構文

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

Certificates のプロパティ

プロパティ名

必須

更新可

説明

制約

CertificateId

String

いいえ

はい

サーバー証明書の ID です。

サーバー証明書のみがサポートされています。

QuicConfig の構文

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

QuicConfig のプロパティ

プロパティ名

必須

更新可

説明

制約

QuicListenerId

String

いいえ

はい

関連付ける QUIC リスナーの ID です。

QuicUpgradeEnabled を true に設定する場合は、このパラメーターを指定する必要があります。

説明
  • このパラメーターは HTTPS リスナーでのみサポートされます。

  • 元のリスナーと関連付けられた QUIC リスナーは、同じ ALB インスタンスに属している必要があります。また、QUIC リスナーは他のリスナーに関連付けられていない必要があります。

QuicUpgradeEnabled

Boolean

いいえ

はい

QUIC アップグレードを有効にするかどうかを指定します。

有効な値:

  • true: 機能を有効にします。

  • false (デフォルト): シャットダウンします。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

LogConfig の構文

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

LogConfig のプロパティ

プロパティ名

必須

更新可

説明

制約

AccessLogTracingConfig

Map

いいえ

はい

アクセスログの X-Trace 構成です。

詳細については、「AccessLogTracingConfig プロパティ」をご参照ください。

AccessLogRecordCustomizedHeadersEnabled

Boolean

いいえ

はい

カスタムヘッダーをアクセスログに含めるかどうかを指定します。

有効な値:

  • True: 有効化。

  • `false` の値は、シャットダウンを示します。

AccessLogTracingConfig の構文

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

AccessLogTracingConfig のプロパティ

プロパティ名

必須

更新可

説明

制約

TracingEnabled

Boolean

いいえ

はい

X-Trace を有効にするかどうかを指定します。

有効な値:

  • true: はい。

  • false: いいえ。

説明

アクセスログ機能 (AccessLogEnabled) が有効な場合にのみ、このパラメーターを true に設定できます。

TracingSample

Integer

いいえ

はい

X-Trace のサンプリング率です。

有効な値: 1 ~ 10000

説明

この値は TracingEnabledtrue に設定されている場合にのみ有効です。

TracingType

String

いいえ

はい

X-Trace のタイプです。

有効な値: Zipkin

説明

この値は TracingEnabledtrue に設定されている場合にのみ有効です。

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
}

XForwardedForConfig のプロパティ

プロパティ名

必須

更新可

説明

制約

XForwardedForClientCertClientVerifyAlias

String

いいえ

はい

クライアント証明書の検証結果を取得するために使用されるカスタムヘッダー名です。

XForwardedForClientCertClientVerifyEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。

長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertClientVerifyEnabled

Boolean

いいえ

はい

X-Forwarded-Clientcert-clientverify ヘッダーからクライアント証明書の検証結果を取得するかどうかを指定します。

有効な値:

  • True: 成功。

  • false (デフォルト値): 失敗。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertFingerprintAlias

String

いいえ

はい

クライアント証明書の指紋を取得するために使用されるカスタムヘッダー名です。

XForwardedForClientCertFingerprintEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。

長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertFingerprintEnabled

Boolean

いいえ

はい

X-Forwarded-Clientcert-fingerprint ヘッダーからクライアント証明書の指紋を取得するかどうかを指定します。

有効な値:

  • true: 成功。

  • false (デフォルト値): 失敗。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertIssuerDNAlias

String

いいえ

はい

クライアント証明書の発行者情報を取得するために使用されるカスタムヘッダー名です。

XForwardedForClientCertIssuerDNEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。

長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertIssuerDNEnabled

Boolean

いいえ

はい

X-Forwarded-Clientcert-issuerdn ヘッダーからクライアント証明書の発行者情報を取得するかどうかを指定します。

有効な値:

  • true: 成功。

  • false (デフォルト): 失敗。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertSubjectDNAlias

String

いいえ

はい

クライアント証明書のサブジェクト情報を取得するために使用されるカスタムヘッダー名です。

XForwardedForClientCertSubjectDNEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。

長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientCertSubjectDNEnabled

Boolean

いいえ

はい

X-Forwarded-Clientcert-subjectdn ヘッダーからクライアント証明書のサブジェクト情報を取得するかどうかを指定します。

有効な値:

  • true: 成功。

  • false (デフォルト): 無効。

説明

このパラメーターは HTTPS リスナーでのみサポートされます。

XForwardedForClientSourceIpsEnabled

Boolean

いいえ

はい

X-Forwarded-Client-SourceIps ヘッダーからクライアントの送信元ポートを取得するかどうかを指定します。

有効な値:

  • true: 成功。

  • false (デフォルト): 失敗。

XForwardedForClientSourceIpsTrusted

String

いいえ

はい

信頼済みプロキシの IP アドレスです。

Application Load Balancer (ALB) は、X-Forwarded-For ヘッダーを右から左に走査します。ALB は、信頼済み IP リストに含まれていない最初の IP アドレスを送信元 IP アドレスとして選択します。この IP アドレスは、送信元 IP を基準とした速度制限に使用されます。

XForwardedForClientSrcPortEnabled

Boolean

いいえ

はい

X-Forwarded-Client-Port ヘッダーからクライアントポートを取得するかどうかを指定します。

有効な値:

  • True: 成功。

  • false (デフォルト値): リクエストは失敗します。

説明

このパラメーターは HTTP および HTTPS リスナーでのみサポートされます。

XForwardedForEnabled

Boolean

いいえ

はい

X-Forwarded-For ヘッダーから送信元 IP アドレスを取得するかどうかを指定します。

有効な値:

  • true (デフォルト値): 成功。

  • false: 失敗。

説明

このパラメーターは HTTP および HTTPS リスナーでのみサポートされます。

XForwardedForHostEnabled

Boolean

いいえ

はい

X-Forwarded-Host ヘッダーからクライアントのドメイン名を取得するかどうかを指定します。

有効な値:

  • true: はい。

  • false (デフォルト): いいえ。

説明

このパラメーターは HTTP、HTTPS、QUIC リスナーでサポートされます。

XForwardedForProcessingMode

String

いいえ

はい

X-Forwarded-For ヘッダーの処理モードです。

この値は XForwardedForEnabledtrue に設定されている場合にのみ有効です。有効な値:

  • append (デフォルト値): 追加。

  • remove: 削除。

説明
  • append を設定すると、バックエンドサービスにリクエストを送信する前に、X-Forwarded-For ヘッダーに最終ホップの IP アドレスが追加されます。

  • remove を設定すると、バックエンドサービスにリクエストを送信する前に、X-Forwarded-For ヘッダーが削除されます (リクエストに X-Forwarded-For ヘッダーが含まれているかどうかに関係なく)。

  • このパラメーターは HTTP および HTTPS リスナーに適用されます。

XForwardedForProtoEnabled

Boolean

いいえ

はい

X-Forwarded-Proto ヘッダーからリスニングプロトコルを取得するかどうかを指定します。

有効な値:

  • true: 正常終了。

  • false (デフォルト値): リクエストは失敗します。

XForwardedForSLBIdEnabled

Boolean

いいえ

はい

SLB-ID ヘッダーから ALB インスタンス ID を取得するかどうかを指定します。

有効な値:

  • True: 成功。

  • false (デフォルト): 失敗。

XForwardedForSLBPortEnabled

Boolean

いいえ

はい

X-Forwarded-Port ヘッダーからリスニングポートを取得するかどうかを指定します。

有効な値:

  • true: 正常終了。

  • false (デフォルト):渡されません。

CaCertificates の構文

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

CaCertificates のプロパティ

プロパティ名

必須

更新可

説明

制約

CertificateId

String

いいえ

はい

CA 証明書の ID です。

なし

戻り値

Fn::GetAtt

  • ListenerId: リスナーの ID。

  • LoadBalancerId: Application Load Balancer (ALB) インスタンスの ID。

シナリオ 1: HTTP リスナーを作成します。

クイック作成

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  LoadBalancerId:
    Type: String
    Description: ALB インスタンスの ID。
    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: リスナーの ID。
    Value:
      Fn::GetAtt:
        - Listener
        - ListenerId                
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "LoadBalancerId": {
      "Type": "String",
      "Description": "ALB インスタンスの ID。",
      "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": "リスナーの ID。",
      "Value": {
        "Fn::GetAtt": [
          "Listener",
          "ListenerId"
        ]
      }
    }
  }
}

シナリオ 2: 2 つの可用性ゾーンを持つ ALB インスタンスと HTTP リスナーを作成します。

クイック作成

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 2 つの可用性ゾーンを持つ 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": "2 つの可用性ゾーンを持つ 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"
      ]
    }
  }
}

シナリオ 3: 高可用性 NGINX ウェブサイトをデプロイします。

クイック作成

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: VPC、ECS インスタンス、ALB、セキュリティグループ、および自動デプロイ構成を含む、2 つの可用性ゾーンを持つ高可用性 NGINX ウェブサイトを作成します。
  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: このソリューションでは、スポットインスタンスを作成し、自動的に NGINX サービスをデプロイします。
      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: このソリューションでは、スポットインスタンスを作成し、自動的に NGINX サービスをデプロイします。
      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 アクセス 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": "VPC、ECS インスタンス、ALB、セキュリティグループ、および自動デプロイ構成を含む、2 つの可用性ゾーンを持つ高可用性 NGINX ウェブサイトを作成します。",
    "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": "このソリューションでは、スポットインスタンスを作成し、自動的に NGINX サービスをデプロイします。",
        "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": "このソリューションでは、スポットインスタンスを作成し、自動的に NGINX サービスをデプロイします。",
        "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 アクセス 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"
      ]
    }
  }
}

その他の例については、「このリソースを含むパブリックテンプレート」をご参照ください。