`ALIYUN::ALB::LoadBalancer` タイプは、Application Load Balancer (ALB) インスタンスを作成するために使用されます。
構文
{
"Type": "ALIYUN::ALB::LoadBalancer",
"Properties": {
"BandwidthPackageId": String,
"LoadBalancerName": String,
"LoadBalancerEdition": String,
"VpcId": String,
"ResourceGroupId": String,
"LoadBalancerBillingConfig": Map,
"AddressType": String,
"AddressAllocatedMode": String,
"ZoneMappings": List,
"DeletionProtectionEnabled": Boolean,
"AddressIpVersion": String,
"ModificationProtectionConfig": Map,
"Tags": List,
"AccessLogConfig": Map,
"SecurityGroupIds": List,
"Ipv6AddressType": String
}
}プロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
AddressType | String | はい | いいえ | ALB インスタンスのアドレスタイプ。 | 有効な値:
|
LoadBalancerBillingConfig | Map | はい | いいえ | 課金構成。 | 詳細については、「LoadBalancerBillingConfig のプロパティ」をご参照ください。 |
LoadBalancerEdition | String | はい | はい | ALB インスタンスのエディション。 | 有効な値:
|
VpcId | String | はい | いいえ | VPC の ID。 | なし |
ZoneMappings | List | はい | いいえ | ゾーンと vSwitch のリスト。 | 少なくとも 2 つのゾーンを指定する必要があります。詳細については、「ZoneMappings のプロパティ」をご参照ください。 |
AccessLogConfig | Map | いいえ | はい | アクセスログの構成。 | 詳細については、「AccessLogConfig のプロパティ」をご参照ください。 |
AddressAllocatedMode | String | いいえ | いいえ | アドレスモード | 有効な値:
|
AddressIpVersion | String | いいえ | いいえ | ロードバランサーインスタンスの IP バージョン。 | 有効な値:
|
BandwidthPackageId | String | いいえ | はい | ALB インスタンスに関連付けられている共有帯域幅インスタンスの ID。 | このパラメーターは、AddressType が Internet に設定されている場合にのみ有効です。 |
DeletionProtectionEnabled | Boolean | いいえ | はい | 削除保護を有効にするかどうかを指定します。 | 有効な値:
|
Ipv6AddressType | String | いいえ | はい | ALB インスタンスがサービスを提供するために使用する IPv6 アドレスのタイプ。 | 有効な値: Internet:ALB インスタンスはパブリック IPv6 アドレスを使用します。ALB インスタンスのドメイン名はパブリック IPv6 アドレスに解決されます。 Intranet:ALB インスタンスはプライベート IPv6 アドレスを使用します。ALB インスタンスのドメイン名はプライベート IPv6 アドレスに解決されます。 |
LoadBalancerName | String | いいえ | はい | ALB インスタンスの名前。 | 名前は 1~80 文字である必要があります。文字、数字、ハイフン (-)、スラッシュ (/)、ピリオド (.)、アンダースコア (_) を使用できます。 このパラメーターを指定しない場合、システムは自動的にインスタンスに名前を割り当てます。 |
ModificationProtectionConfig | Map | いいえ | はい | 変更保護の構成。 | 詳細については、「ModificationProtectionConfig のプロパティ」をご参照ください。 |
ResourceGroupId | String | いいえ | はい | リソースグループの ID。 | なし |
SecurityGroupIds | List | いいえ | はい | ALB インスタンスが追加されるセキュリティグループの ID。 | セキュリティグループ機能はデフォルトでは有効になっていません。この機能を使用するには、アカウントマネージャーにご連絡ください。 |
Tags | List | いいえ | はい | ALB インスタンスのタグ。 | 最大 20 個のタグを追加できます。 詳細については、「Tags のプロパティ」をご参照ください。 |
AccessLogConfig の構文
"AccessLogConfig": {
"Enable": Boolean,
"LogStore": String,
"LogProject": String
}AccessLogConfig のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
LogProject | String | はい | いいえ | ログプロジェクト。 | なし |
LogStore | String | はい | いいえ | Logstore。 | なし |
Enable | Boolean | いいえ | はい | アクセスログ機能を有効にするかどうかを指定します。 | 有効な値:
|
LoadBalancerBillingConfig の構文
"LoadBalancerBillingConfig": {
"PayType": String
}LoadBalancerBillingConfig のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
PayType | String | はい | いいえ | ALB インスタンスの課金方法。 | 有効な値:PostPay。この値は従量課金方法を指定します。 |
ZoneMappings の構文
"ZoneMappings": [
{
"ZoneId": String,
"VSwitchId": String,
"AllocationId": String,
"LoadBalancerAddresses": List,
"IntranetAddress": String,
"EipType": String
}
]ZoneMappings のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
VSwitchId | String | はい | いいえ | vSwitch の ID。 | 各ゾーンには 1 つの vSwitch のみ含めることができます。 |
ZoneId | String | はい | いいえ | ゾーンの ID。 | なし |
AllocationId | String | いいえ | いいえ | ALB インスタンスに関連付けられている Elastic IP Address (EIP) の ID。 | なし |
EipType | String | いいえ | いいえ | パブリック EIP のタイプ。 | 有効な値:
説明 ALB が Anycast EIP をサポートするリージョンについては、「リージョンをまたいだアクセスを高速化するために ALB インスタンスに Anycast EIP を関連付ける」をご参照ください。 |
LoadBalancerAddresses | List | いいえ | いいえ | インスタンスアドレス。 | 詳細については、「LoadBalancerAddresses のプロパティ」をご参照ください。 |
IntranetAddress | String | いいえ | いいえ | プライベート IPv4 アドレス。 | なし |
LoadBalancerAddresses の構文
"ModificationProtectionConfig": {
"AllocationId": String,
"IntranetAddress": String,
"EipType": String
}LoadBalancerAddresses のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
AllocationId | String | はい | いいえ | ALB インスタンスに関連付けられている EIP の ID。 | なし |
EipType | String | いいえ | いいえ | パブリック EIP のタイプ。 | 有効な値:
説明 ALB が Anycast EIP をサポートするリージョンについては、「リージョンをまたいだアクセスを高速化するために ALB インスタンスに Anycast EIP を関連付ける」をご参照ください。 |
IntranetAddress | String | いいえ | いいえ | プライベート IPv4 アドレス。 | なし |
ModificationProtectionConfig の構文
"ModificationProtectionConfig": {
"Status": String,
"Reason": String
}ModificationProtectionConfig のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Status | String | はい | はい | 変更保護のステータス。 | 有効な値:
|
Reason | String | いいえ | はい | 変更保護を有効にする理由。 | 文字列は 2~128 文字で、英字または漢字で始まり、英字、漢字、数字、ピリオド (.)、アンダースコア (_)、ハイフン (-) のみを含む必要があります。 説明 このパラメーターは、Status が ConsoleProtection に設定されている場合にのみ有効です。 |
Tags の構文
"Tags": [
{
"Value": String,
"Key": String
}
]Tags のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Key | String | はい | いいえ | タグキー。 | タグキーは 1~128 文字である必要があります。 |
Value | String | いいえ | いいえ | タグ値。 | タグ値は 0~128 文字である必要があります。 |
戻り値
Fn::GetAtt
LoadBalancerEdition:ALB インスタンスのエディション。
VpcId:VPC の ID。
LoadBalancerId:ALB インスタンスの ID。
AddressType:ALB インスタンスのアドレスタイプ。
DNSName:ALB インスタンスのドメイン名。
ZoneMappings:ゾーンと vSwitch のリスト。
Arn:リソースの Alibaba Cloud リソース名 (ARN)。
例
シナリオ 1:Application Load Balancer (ALB) インスタンス。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
VpcId:
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
ZoneMappings:
Type: Json
Description: ゾーンとそのゾーン内の vSwitch。少なくとも 2 つのゾーンを指定する必要があります。
Default:
- ZoneId: cn-hangzhou-h
VSwitchId: vsw-bp1jhj254nwc7i0ge****
- ZoneId: cn-hangzhou-i
VSwitchId: vsw-bp1llps83qqb30znp****
Resources:
LoadBalancer:
Type: ALIYUN::ALB::LoadBalancer
Properties:
LoadBalancerName: TestLoadBalancer
LoadBalancerEdition: Basic
VpcId:
Ref: VpcId
LoadBalancerBillingConfig:
PayType: PostPay
ZoneMappings:
Ref: ZoneMappings
AddressType: Internet
Outputs:
LoadBalancerEdition:
Description: ALB インスタンスのエディション。
Value:
Fn::GetAtt:
- LoadBalancer
- LoadBalancerEdition
VpcId:
Description: ALB インスタンスがデプロイされている Virtual Private Cloud (VPC) の ID。
Value:
Fn::GetAtt:
- LoadBalancer
- VpcId
LoadBalancerId:
Description: ALB インスタンスの ID。
Value:
Fn::GetAtt:
- LoadBalancer
- LoadBalancerId
AddressType:
Description: ALB インスタンスがサービスを提供するために使用する IP アドレスのタイプ。
Value:
Fn::GetAtt:
- LoadBalancer
- AddressType
DNSName:
Description: ALB インスタンスのドメイン名。
Value:
Fn::GetAtt:
- LoadBalancer
- DNSName
ZoneMappings:
Description: ゾーンにマッピングされているゾーン、vSwitch、およびアドレス。
Value:
Fn::GetAtt:
- LoadBalancer
- ZoneMappings {
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"ZoneMappings": {
"Type": "Json",
"Description": "ゾーンとそのゾーン内の vSwitch。少なくとも 2 つのゾーンを指定する必要があります。",
"Default": [
{
"ZoneId": "cn-hangzhou-h",
"VSwitchId": "vsw-bp1jhj254nwc7i0ge****"
},
{
"ZoneId": "cn-hangzhou-i",
"VSwitchId": "vsw-bp1llps83qqb30znp****"
}
]
}
},
"Resources": {
"LoadBalancer": {
"Type": "ALIYUN::ALB::LoadBalancer",
"Properties": {
"LoadBalancerName": "TestLoadBalancer",
"LoadBalancerEdition": "Basic",
"VpcId": {
"Ref": "VpcId"
},
"LoadBalancerBillingConfig": {
"PayType": "PostPay"
},
"ZoneMappings": {
"Ref": "ZoneMappings"
},
"AddressType": "Internet"
}
}
},
"Outputs": {
"LoadBalancerEdition": {
"Description": "ALB インスタンスのエディション。",
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"LoadBalancerEdition"
]
}
},
"VpcId": {
"Description": "ALB インスタンスがデプロイされている Virtual Private Cloud (VPC) の ID。",
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"VpcId"
]
}
},
"LoadBalancerId": {
"Description": "ALB インスタンスの ID。",
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"LoadBalancerId"
]
}
},
"AddressType": {
"Description": "ALB インスタンスがサービスを提供するために使用する IP アドレスのタイプ。",
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"AddressType"
]
}
},
"DNSName": {
"Description": "ALB インスタンスのドメイン名。",
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"DNSName"
]
}
},
"ZoneMappings": {
"Description": "ゾーンにマッピングされているゾーン、vSwitch、およびアドレス。",
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"ZoneMappings"
]
}
}
}
}シナリオ 2:ESS を使用して自動スケーリングを行うデュアルゾーン ALB インスタンスの作成。
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: アプリケーションの高可用性を確保するため、Auto Scaling (ESS) とともにデュアルアベイラビリティゾーンの ALB (Application Load Balancer) を作成します。これには、セキュリティグループと NGINX の自動インストール構成が含まれます。
Parameters:
CommonName:
Type: String
Default: elastic-app
ZoneId1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId2
Label:
en: アベイラビリティゾーン
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId1
Label:
en: アベイラビリティゾーン
InstanceType1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: インスタンスタイプ
InstanceType2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: インスタンスタイプ
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
サーバーのログインパスワード。長さは 8~30 文字で、大文字、小文字、数字、および ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ の特殊文字のうち 3 種類を含める必要があります。
Label:
en: インスタンスパスワード
ConstraintDescription:
en: >-
長さは 8~30 文字で、大文字、小文字、数字、および ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ の特殊文字のうち 3 種類を含める必要があります。
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
Default: null
ScalingTime:
Type: String
Label:
en: 自動拡張実行時間
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'YYYY-MM-DDThh:mmZ'
Description:
en: >-
このソリューションの作成には 3~5 分かかると推定されます。
拡張効果を確認するには、5 分以上待つことを推奨します。
ScalingTime2:
Type: String
Label:
en: 自動スケーリング実行時間
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'YYYY-MM-DDThh:mmZ'
Description:
en: 拡張時間の 5~10 分後に縮小効果を確認することを推奨します。
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_20231219.vhd
InstanceName:
Fn::Sub: ${CommonName}-ecs-1
InstanceType:
Ref: InstanceType1
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 0
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 "これは instance1 です。インスタンス ID は $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_20231219.vhd
InstanceName:
Fn::Sub: ${CommonName}-ecs-2
InstanceType:
Ref: InstanceType2
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 0
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 "これは instance2 です。インスタンス ID は $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
EssScalingGroup:
Type: 'ALIYUN::ESS::ScalingGroup'
Properties:
VSwitchIds:
- Ref: VSwitch1
- Ref: VSwitch2
ScalingGroupName:
Fn::Sub: ${CommonName}-${ALIYUN::StackId}
RemovalPolicys:
- NewestInstance
MinSize: 0
MaxSize: 4
DefaultCooldown: 300
MultiAZPolicy: COMPOSABLE
AzBalance: true
DependsOn: SecurityGroup
EssServerGroupAttachment:
Type: 'ALIYUN::ESS::ServerGroupAttachment'
DependsOn: EssScalingGroupEnable
Properties:
ScalingGroupId:
Ref: EssScalingGroup
ForceAttach: true
ServerGroups:
- Type: ALB
Port: 80
ServerGroupId:
Ref: AlbServerGroup
Weight: 100
EssScalingConfiguration:
Type: 'ALIYUN::ESS::ScalingConfiguration'
Properties:
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
ScalingConfigurationName:
Fn::Sub: ${CommonName}-asc
ScalingGroupId:
Ref: EssScalingGroup
InstanceTypes:
- Ref: InstanceType1
- Ref: InstanceType2
SystemDiskCategory: cloud_essd
SystemDiskSize: 40
Password:
Ref: InstancePassword
InstanceName:
Fn::Sub: ${CommonName}-ess
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 "このインスタンスは ess からのものです。インスタンス ID は $instanceId です" > /usr/share/nginx/html/index.html
systemctl start nginx
systemctl enable nginx
EssScalingGroupEnable:
Type: 'ALIYUN::ESS::ScalingGroupEnable'
Properties:
ScalingGroupId:
Ref: EssScalingGroup
ScalingConfigurationId:
Ref: EssScalingConfiguration
EssScalingRule:
Type: 'ALIYUN::ESS::ScalingRule'
Properties:
ScalingRuleName:
Fn::Sub: ${CommonName}-asr-rule
ScalingGroupId:
Ref: EssScalingGroup
ScalingRuleType: SimpleScalingRule
AdjustmentType: QuantityChangeInCapacity
AdjustmentValue: 1
Cooldown: 60
EssScalingRule2:
Type: 'ALIYUN::ESS::ScalingRule'
Properties:
ScalingRuleName:
Fn::Sub: ${CommonName}-asr-rule2
ScalingGroupId:
Ref: EssScalingGroup
ScalingRuleType: SimpleScalingRule
AdjustmentType: QuantityChangeInCapacity
AdjustmentValue: -1
Cooldown: 60
EssScheduledTask:
Type: 'ALIYUN::ESS::ScheduledTask'
Properties:
ScheduledTaskName:
Fn::Sub: ${CommonName}-task1-${ALIYUN::StackId}
LaunchTime:
Ref: ScalingTime
ScheduledAction:
Fn::Sub: '${EssScalingRule.ScalingRuleAri}'
LaunchExpirationTime: 10
EssScheduledTask2:
Type: 'ALIYUN::ESS::ScheduledTask'
Properties:
ScheduledTaskName:
Fn::Sub: ${CommonName}-task2-${ALIYUN::StackId}
LaunchTime:
Ref: ScalingTime2
ScheduledAction:
Fn::Sub: '${EssScalingRule2.ScalingRuleAri}'
LaunchExpirationTime: 10
Outputs:
WebUrl:
Description:
en: Web のアドレス。
Value:
'Fn::Sub': 'http://${Alb.DNSName}'
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId1
- ZoneId2
- InstanceType1
- InstanceType2
- InstancePassword
- ScalingTime
- ScalingTime2
TemplateTags:
- acs:technical-solution:high-availability-architecture:Improve application availability using ALB and ESS-tech_solu_117
Hidden:
- CommonName
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"en": "アプリケーションの高可用性を確保するため、Auto Scaling (ESS) とともにデュアルアベイラビリティゾーンの ALB (Application Load Balancer) を作成します。これには、セキュリティグループと NGINX の自動インストール構成が含まれます。"
},
"Parameters": {
"CommonName": {
"Type": "String",
"Default": "elastic-app"
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "アベイラビリティゾーン"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "アベイラビリティゾーン"
}
},
"InstanceType1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "インスタンスタイプ"
}
},
"InstanceType2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "インスタンスタイプ"
}
},
"InstancePassword": {
"NoEcho": true,
"Type": "String",
"Description": {
"en": "サーバーのログインパスワード。長さは 8~30 文字で、大文字、小文字、数字、および ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ の特殊文字のうち 3 種類を含める必要があります。"
},
"Label": {
"en": "インスタンスパスワード"
},
"ConstraintDescription": {
"en": "長さは 8~30 文字で、大文字、小文字、数字、および ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ の特殊文字のうち 3 種類を含める必要があります。"
},
"AssociationProperty": "ALIYUN::ECS::Instance::Password",
"Default": null
},
"ScalingTime": {
"Type": "String",
"Label": {
"en": "自動拡張実行時間"
},
"AssociationProperty": "DateTime",
"AssociationPropertyMetadata": {
"Format": "YYYY-MM-DDThh:mmZ"
},
"Description": {
"en": "このソリューションの作成には 3~5 分かかると推定されます。拡張効果を確認するには、5 分以上待つことを推奨します。"
}
},
"ScalingTime2": {
"Type": "String",
"Label": {
"en": "自動スケーリング実行時間"
},
"AssociationProperty": "DateTime",
"AssociationPropertyMetadata": {
"Format": "YYYY-MM-DDThh:mmZ"
},
"Description": {
"en": "拡張時間の 5~10 分後に縮小効果を確認することを推奨します。"
}
}
},
"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_20231219.vhd",
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs-1"
},
"InstanceType": {
"Ref": "InstanceType1"
},
"SystemDiskCategory": "cloud_essd",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 0,
"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 \"これは instance1 です。インスタンス ID は $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_20231219.vhd",
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs-2"
},
"InstanceType": {
"Ref": "InstanceType2"
},
"SystemDiskCategory": "cloud_essd",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 0,
"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 \"これは instance2 です。インスタンス ID は $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"
}
},
"EssScalingGroup": {
"Type": "ALIYUN::ESS::ScalingGroup",
"Properties": {
"VSwitchIds": [
{
"Ref": "VSwitch1"
},
{
"Ref": "VSwitch2"
}
],
"ScalingGroupName": {
"Fn::Sub": "${CommonName}-${ALIYUN::StackId}"
},
"RemovalPolicys": [
"NewestInstance"
],
"MinSize": 0,
"MaxSize": 4,
"DefaultCooldown": 300,
"MultiAZPolicy": "COMPOSABLE",
"AzBalance": true
},
"DependsOn": "SecurityGroup"
},
"EssServerGroupAttachment": {
"Type": "ALIYUN::ESS::ServerGroupAttachment",
"DependsOn": "EssScalingGroupEnable",
"Properties": {
"ScalingGroupId": {
"Ref": "EssScalingGroup"
},
"ForceAttach": true,
"ServerGroups": [
{
"Type": "ALB",
"Port": 80,
"ServerGroupId": {
"Ref": "AlbServerGroup"
},
"Weight": 100
}
]
}
},
"EssScalingConfiguration": {
"Type": "ALIYUN::ESS::ScalingConfiguration",
"Properties": {
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
"ScalingConfigurationName": {
"Fn::Sub": "${CommonName}-asc"
},
"ScalingGroupId": {
"Ref": "EssScalingGroup"
},
"InstanceTypes": [
{
"Ref": "InstanceType1"
},
{
"Ref": "InstanceType2"
}
],
"SystemDiskCategory": "cloud_essd",
"SystemDiskSize": 40,
"Password": {
"Ref": "InstancePassword"
},
"InstanceName": {
"Fn::Sub": "${CommonName}-ess"
},
"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 \"このインスタンスは ess からのものです。インスタンス ID は $instanceId です\" > /usr/share/nginx/html/index.html \nsystemctl start nginx \nsystemctl enable nginx"
}
}
},
"EssScalingGroupEnable": {
"Type": "ALIYUN::ESS::ScalingGroupEnable",
"Properties": {
"ScalingGroupId": {
"Ref": "EssScalingGroup"
},
"ScalingConfigurationId": {
"Ref": "EssScalingConfiguration"
}
}
},
"EssScalingRule": {
"Type": "ALIYUN::ESS::ScalingRule",
"Properties": {
"ScalingRuleName": {
"Fn::Sub": "${CommonName}-asr-rule"
},
"ScalingGroupId": {
"Ref": "EssScalingGroup"
},
"ScalingRuleType": "SimpleScalingRule",
"AdjustmentType": "QuantityChangeInCapacity",
"AdjustmentValue": 1,
"Cooldown": 60
}
},
"EssScalingRule2": {
"Type": "ALIYUN::ESS::ScalingRule",
"Properties": {
"ScalingRuleName": {
"Fn::Sub": "${CommonName}-asr-rule2"
},
"ScalingGroupId": {
"Ref": "EssScalingGroup"
},
"ScalingRuleType": "SimpleScalingRule",
"AdjustmentType": "QuantityChangeInCapacity",
"AdjustmentValue": -1,
"Cooldown": 60
}
},
"EssScheduledTask": {
"Type": "ALIYUN::ESS::ScheduledTask",
"Properties": {
"ScheduledTaskName": {
"Fn::Sub": "${CommonName}-task1-${ALIYUN::StackId}"
},
"LaunchTime": {
"Ref": "ScalingTime"
},
"ScheduledAction": {
"Fn::Sub": "${EssScalingRule.ScalingRuleAri}"
},
"LaunchExpirationTime": 10
}
},
"EssScheduledTask2": {
"Type": "ALIYUN::ESS::ScheduledTask",
"Properties": {
"ScheduledTaskName": {
"Fn::Sub": "${CommonName}-task2-${ALIYUN::StackId}"
},
"LaunchTime": {
"Ref": "ScalingTime2"
},
"ScheduledAction": {
"Fn::Sub": "${EssScalingRule2.ScalingRuleAri}"
},
"LaunchExpirationTime": 10
}
}
},
"Outputs": {
"WebUrl": {
"Description": {
"en": "Web のアドレス。"
},
"Value": {
"Fn::Sub": "http://${Alb.DNSName}"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId1",
"ZoneId2",
"InstanceType1",
"InstanceType2",
"InstancePassword",
"ScalingTime",
"ScalingTime2"
]
}
],
"TemplateTags": [
"acs:technical-solution:high-availability-architecture:Improve application availability using ALB and ESS-tech_solu_117"
],
"Hidden": [
"CommonName"
]
}
}
}シナリオ 3:高可用性 NGINX ウェブサイトの構築。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: Build a high-availability NGINX website across two zones. The template includes a VPC, ECS instances, an ALB instance, security groups, and automatic 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.
ja: 2 つの可用性ゾーンにまたがる高可用性 NGINX ウェブサイトを構築します。このテンプレートには、VPC、ECS インスタンス、ALB インスタンス、セキュリティグループ、および自動デプロイ構成が含まれます。
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
ja: 可用性ゾーン
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
AutoSelectFirst: true
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: Zone 2
ja: 可用性ゾーン
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
ja: インスタンスタイプ
Description:
zh-cn: This solution creates a spot instance and automatically deploys the NGINX service.
en: >-
This solution will create a spot instance and automatically deploy a
nginx service.
ja: このソリューションでは、スポットインスタンスを作成し、NGINX サービスを自動的にデプロイします。
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
ja: インスタンスタイプ
Description:
zh-cn: This solution creates a spot instance and automatically deploys the NGINX service.
en: >-
This solution will create a spot instance and automatically deploy a
nginx service.
ja: このソリューションでは、スポットインスタンスを作成し、NGINX サービスを自動的にデプロイします。
Default: null
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
The logon password of the server. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
ja: >-
サーバーのログインパスワードです。パスワードは 8~30 文字の長さで、大文字、小文字、数字、特殊文字 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ のうち少なくとも 3 種類を含む必要があります。
Label:
en: Instance Password
zh-cn: Instance Password
ja: インスタンスパスワード
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 'The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
ja: パスワードは 8~30 文字の長さで、大文字、小文字、数字、特殊文字 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ のうち少なくとも 3 種類を含む必要があります。
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: The web endpoint.
en: The Addresses of Web.
ja: Web エンドポイント。
Value:
'Fn::Sub': 'http://${Alb.DNSName}'
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ZoneId1
- InstanceType1
- ZoneId2
- InstanceType2
- InstancePassword
TemplateTags:
- acs:example:elastic-computing:Build a high-availability NGINX website
Hidden:
- CommonName
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"en": "Virtual Private Cloud (VPC)、Elastic Compute Service (ECS) インスタンス、Application Load Balancer (ALB)、セキュリティグループ、および自動デプロイ構成を含む、デュアルアベイラビリティゾーンの高可用性 NGINX ウェブサイトを構築します。"
},
"Parameters": {
"CommonName": {
"Type": "String",
"Default": "elastic-app"
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"AutoSelectFirst": true,
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "アベイラビリティゾーン"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"AutoSelectFirst": true,
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "アベイラビリティゾーン"
}
},
"InstanceType1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"SpotStrategy": "SpotAsPriceGo",
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "インスタンスタイプ"
},
"Description": {
"en": "このソリューションは、スポットインスタンスを作成し、NGINX サービスを自動的にデプロイします。"
},
"Default": null
},
"InstanceType2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"SpotStrategy": "SpotAsPriceGo",
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "インスタンスタイプ"
},
"Description": {
"en": "このソリューションは、スポットインスタンスを作成し、NGINX サービスを自動的にデプロイします。"
},
"Default": null
},
"InstancePassword": {
"NoEcho": true,
"Type": "String",
"Description": {
"en": "サーバーのログインパスワード。長さは 8~30 文字で、大文字、小文字、数字、および ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ の特殊文字のうち 3 種類を含める必要があります。"
},
"Label": {
"en": "インスタンスパスワード"
},
"ConstraintDescription": {
"en": "長さは 8~30 文字で、大文字、小文字、数字、および ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ の特殊文字のうち 3 種類を含める必要があります。"
},
"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 \"Nginx へようこそ。現在のインスタンスは $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 \"Nginx へようこそ。現在のインスタンスは $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": {
"en": "Web のアドレス。"
},
"Value": {
"Fn::Sub": "http://${Alb.DNSName}"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId1",
"InstanceType1",
"ZoneId2",
"InstanceType2",
"InstancePassword"
]
}
],
"TemplateTags": [
"acs:example:elastic-computing:Build a high-availability NGINX website"
],
"Hidden": [
"CommonName"
]
}
}
}詳細については、「このリソースを含むパブリックテンプレート」をご参照ください。