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 | はい | はい | ルールアクションのリストです。 | 例: 詳細については、「DefaultActions プロパティ」をご参照ください。 |
ListenerPort | Integer | はい | いいえ | リスニングポートです。 | 有効な値: 1 ~ 65535。 |
ListenerProtocol | String | はい | いいえ | リスニングプロトコルです。 | 有効な値:
|
LoadBalancerId | String | はい | いいえ | Application Load Balancer (ALB) インスタンスの ID です。 | なし |
CaCertificates | List | いいえ | はい | CA 証明書の情報です。 | 詳細については、「CaCertificates プロパティ」をご参照ください。 |
CaEnabled | Boolean | いいえ | はい | 相互認証を有効にするかどうかを指定します。 | 有効な値:
|
Certificates | List | いいえ | はい | 証明書です。 | 詳細については、「Certificates プロパティ」をご参照ください。 |
GzipEnabled | Boolean | いいえ | はい | 特定のファイルタイプに対して Gzip 圧縮を有効にするかどうかを指定します。 | 有効な値:
|
Http2Enabled | Boolean | いいえ | はい | HTTP/2 を有効にするかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
IdleTimeout | Integer | いいえ | はい | 接続アイドルタイムアウト期間です。 | 有効な値: 1 ~ 60。 デフォルト値: 15。 単位: 秒。 タイムアウト期間内にリクエストが到着しなかった場合、ロードバランサーは現在の接続を一時的に閉じます。次のリクエストが到着すると、ロードバランサーは新しい接続を再確立します。 |
ListenerDescription | String | いいえ | はい | リスナーの説明です。 | 長さ: 2 ~ 256 文字。 |
ListenerStatus | String | いいえ | はい | リスナーのステータスです。 | 有効な値:
|
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 に設定する場合は、このパラメーターを指定する必要があります。 説明
|
QuicUpgradeEnabled | Boolean | いいえ | はい | QUIC アップグレードを有効にするかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
LogConfig の構文
"LogConfig": {
"AccessLogTracingConfig": Map,
"AccessLogRecordCustomizedHeadersEnabled": Boolean
}LogConfig のプロパティ
プロパティ名 | 型 | 必須 | 更新可 | 説明 | 制約 |
AccessLogTracingConfig | Map | いいえ | はい | アクセスログの X-Trace 構成です。 | 詳細については、「AccessLogTracingConfig プロパティ」をご参照ください。 |
AccessLogRecordCustomizedHeadersEnabled | Boolean | いいえ | はい | カスタムヘッダーをアクセスログに含めるかどうかを指定します。 | 有効な値:
|
AccessLogTracingConfig の構文
"AccessLogTracingConfig": {
"TracingSample": Integer,
"TracingType": String,
"TracingEnabled": Boolean
}AccessLogTracingConfig のプロパティ
プロパティ名 | 型 | 必須 | 更新可 | 説明 | 制約 |
TracingEnabled | Boolean | いいえ | はい | X-Trace を有効にするかどうかを指定します。 | 有効な値:
説明 アクセスログ機能 (AccessLogEnabled) が有効な場合にのみ、このパラメーターを true に設定できます。 |
TracingSample | Integer | いいえ | はい | X-Trace のサンプリング率です。 | 有効な値: 1 ~ 10000。 説明 この値は TracingEnabled が true に設定されている場合にのみ有効です。 |
TracingType | String | いいえ | はい | X-Trace のタイプです。 | 有効な値: Zipkin。 説明 この値は TracingEnabled が true に設定されている場合にのみ有効です。 |
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 ヘッダーからクライアント証明書の検証結果を取得するかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientCertFingerprintAlias | String | いいえ | はい | クライアント証明書の指紋を取得するために使用されるカスタムヘッダー名です。 | XForwardedForClientCertFingerprintEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。 長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。 説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientCertFingerprintEnabled | Boolean | いいえ | はい | X-Forwarded-Clientcert-fingerprint ヘッダーからクライアント証明書の指紋を取得するかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientCertIssuerDNAlias | String | いいえ | はい | クライアント証明書の発行者情報を取得するために使用されるカスタムヘッダー名です。 | XForwardedForClientCertIssuerDNEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。 長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。 説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientCertIssuerDNEnabled | Boolean | いいえ | はい | X-Forwarded-Clientcert-issuerdn ヘッダーからクライアント証明書の発行者情報を取得するかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientCertSubjectDNAlias | String | いいえ | はい | クライアント証明書のサブジェクト情報を取得するために使用されるカスタムヘッダー名です。 | XForwardedForClientCertSubjectDNEnabled が true に設定されている場合にのみ、このパラメーターが有効になります。 長さ: 1 ~ 40 文字。有効な文字: 小文字、数字、ハイフン (-)、アンダースコア (_)。 説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientCertSubjectDNEnabled | Boolean | いいえ | はい | X-Forwarded-Clientcert-subjectdn ヘッダーからクライアント証明書のサブジェクト情報を取得するかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTPS リスナーでのみサポートされます。 |
XForwardedForClientSourceIpsEnabled | Boolean | いいえ | はい | X-Forwarded-Client-SourceIps ヘッダーからクライアントの送信元ポートを取得するかどうかを指定します。 | 有効な値:
|
XForwardedForClientSourceIpsTrusted | String | いいえ | はい | 信頼済みプロキシの IP アドレスです。 | Application Load Balancer (ALB) は、 |
XForwardedForClientSrcPortEnabled | Boolean | いいえ | はい | X-Forwarded-Client-Port ヘッダーからクライアントポートを取得するかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTP および HTTPS リスナーでのみサポートされます。 |
XForwardedForEnabled | Boolean | いいえ | はい | X-Forwarded-For ヘッダーから送信元 IP アドレスを取得するかどうかを指定します。 | 有効な値:
説明 このパラメーターは HTTP および HTTPS リスナーでのみサポートされます。 |
XForwardedForHostEnabled | Boolean | いいえ | はい |
| 有効な値:
説明 このパラメーターは HTTP、HTTPS、QUIC リスナーでサポートされます。 |
XForwardedForProcessingMode | String | いいえ | はい |
| この値は XForwardedForEnabled が true に設定されている場合にのみ有効です。有効な値:
説明
|
XForwardedForProtoEnabled | Boolean | いいえ | はい | X-Forwarded-Proto ヘッダーからリスニングプロトコルを取得するかどうかを指定します。 | 有効な値:
|
XForwardedForSLBIdEnabled | Boolean | いいえ | はい | SLB-ID ヘッダーから ALB インスタンス ID を取得するかどうかを指定します。 | 有効な値:
|
XForwardedForSLBPortEnabled | Boolean | いいえ | はい | X-Forwarded-Port ヘッダーからリスニングポートを取得するかどうかを指定します。 | 有効な値:
|
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"
]
}
}
}その他の例については、「このリソースを含むパブリックテンプレート」をご参照ください。