Resource Orchestration Service (ROS) を使用すると、ECS インスタンスやその依存関係など、必要な Alibaba Cloud リソースをテンプレートで定義できます。ROS オーケストレーションエンジンは、このテンプレートに基づいてすべてのリソースを自動的にプロビジョニングおよび設定し、デプロイメントとメンテナンスを自動化します。本トピックでは、Object Storage Service (OSS) と ROS を使用して Nginx アプリケーションをデプロイする方法について説明します。
前提条件
-
バケットを作成済みで、そのアクセス制御リスト (ACL) を非公開に設定しています。「バケットの作成」をご参照ください。
-
Nginx インストールパッケージ をダウンロード済みです。
ステップ 1:Nginx パッケージをバケットにアップロード
-
OSS コンソール にログインします。
-
左側のナビゲーションウィンドウで バケット をクリックします。表示されたページで、対象のバケット名をクリックします。
-
左側のナビゲーションウィンドウで を選択します。
-
ダウンロード済みの Nginx インストールパッケージをアップロードします。
オブジェクトをアップロードする際、ACL を パブリック読み取り に設定し、他のパラメーターはデフォルト設定のままにしてください。「オブジェクトのアップロード」をご参照ください。
-
オブジェクト URL を取得します。
ファイルのアップロードが完了したら、Nginx インストールパッケージファイルの右側にある 詳細 をクリックし、次に オブジェクト URL のコピー をクリックします。

ステップ 2:ROS でスタックを作成
-
テンプレートを選択します。
-
ROS コンソール にログインします。
-
左側のナビゲーションウィンドウで [スタック] をクリックします。
-
上部のナビゲーションバーで、リージョンドロップダウンリストから 中国 (杭州) を選択します。
-
[スタック] ページで [スタックの作成] をクリックします。「テンプレートの指定」を 既存テンプレートの使用 に、「テンプレートのインポート方法」を テンプレート内容の入力 に設定します。[JSON] タブで、以下のテンプレート内容を貼り付け、[次へ] をクリックします。
{ "ROSTemplateFormatVersion": "2015-09-01", "Description": "", "Parameters": { "NginxDownloadUrl": { "Type": "String", "Description": { "zh-cn": "nginx-*.rpmのダウンロードパス", "en": "The download URL of the nginx-*.rpm package." }, "Label": { "zh-cn": "Nginxダウンロードアドレス", "en": "Nginx Download URL" } }, "ZoneId": { "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId", "Type": "String", "Description": { "zh-cn": "可用区ID。
<b>注: <font color='blue'>選択前に、該当可用区でECSリソースの仕様がサポートされているか確認してください。他のVSwitchとは異なる可用区の選択を推奨します</font>", "en": "The ID of the availability zone.
<b>Note: <font color='blue'>Before you make a selection, confirm that the required instance type is available in the selected availability zone. We recommend that you select an availability zone different from where your other VSwitches reside.</font>" }, "Label": { "zh-cn": "VSwitch可用区", "en": "VSwitch Availability Zone" } }, "ImageId": { "Default": "centos_7", "Type": "String", "Description": { "zh-cn": "CentOS 7 のイメージ ID を使用してください。詳細については:<a href='https://www.alibabacloud.com/help/document_detail/112977.html' target='_blank'><font color='blue'>イメージの検索</font></a>", "en": "The ID of the image.
<b>Note: <font color='blue'>You must use a CentOS 7 image. For more information, see <a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'>Find images</a>.</font>" }, "Label": { "zh-cn": "イメージ", "en": "Image" } }, "InstanceType": { "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType", "AssociationPropertyMetadata": { "ZoneId": "ZoneId" }, "Label": { "zh-cn": "インスタンスタイプ", "en": "Instance Type" }, "Type": "String", "Description": { "zh-cn": "<font color='blue'>1. インスタンスタイプを選択する前に、選択した可用区で該当インスタンスタイプが利用可能かどうか確認してください。一部のインスタンスタイプは事前にチケットを送信する必要があります</font>
<font color='blue'><b>2. 選択可能なインスタンスタイプの一覧</font><br></font>[ecs.c5.large <font color='green'>2 vCPU 4 GiB 内部帯域幅 1 Gbps 秒間パケット数 30 万 PPS</font>]
[ecs.c5.xlarge <font color='green'>4 vCPU 8 GiB 内部帯域幅 1.5 Gbps 秒間パケット数 50 万 PPS</font>]
[ecs.c5.2xlarge <font color='green'>8 vCPU 16 GiB 内部帯域幅 2.5 Gbps 秒間パケット数 80 万 PPS</font>]", "en": "<font color='blue'>1. Before you select an instance type, confirm that it is available in the selected availability zone. Some instance types require you to submit a ticket in advance.</font>
<font color='blue'><b>2. Available instance types:</font>
[ecs.c5.large: <font color='green'>2 vCPUs, 4 GiB, 1 Gbit/s internal bandwidth, 300,000 PPS</font>]<br>[ecs.c5.xlarge: <font color='green'>4 vCPUs, 8 GiB, 1.5 Gbit/s internal bandwidth, 500,000 PPS</font>]<br>[ecs.c5.2xlarge: <font color='green'>8 vCPUs, 16 GiB, 2.5 Gbit/s internal bandwidth, 800,000 PPS</font>]" } }, "SystemDiskCategory": { "Default": "cloud_efficiency", "Label": { "zh-cn": "システムディスクタイプ", "en": "System Disk Type" }, "Type": "String", "Description": { "en": "<font color='blue'><b>有効な値:</font>
[cloud_efficiency: <font color='green'>Ultra Disk</font>]<br>[cloud_ssd: <font color='green'>Standard SSD</font>]<br>[cloud_essd: <font color='green'>ESSD</font>]<br>[cloud: <font color='green'>Basic Disk</font>]<br>[ephemeral_ssd: <font color='green'>local SSD disk</font>]", "zh-cn": "<font color='blue'><b>選択可能な値:</font><br>[cloud_efficiency: <font color='green'>高效云盘</font>]<br>[cloud_ssd: <font color='green'>SSD云盘</font>]<br>[cloud_essd: <font color='green'>ESSD云盘</font>]<br>[cloud: <font color='green'>普通云盘</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盘</font>]" }, "AllowedValues": [ "cloud_efficiency", "cloud_ssd", "cloud", "cloud_essd", "ephemeral_ssd" ] }, "InstancePassword": { "Type": "String", "Description": { "zh-cn": "サーバーログインパスワード。長さは 8~30 文字で、大文字、小文字、数字、特殊文字(() ` ~ ! @ # $ % ^ & * _ - + = | { } [ ] : ; ' < > , . ? /)のうち 3 種類以上を含める必要があります。", "en": "The logon password of the ECS instance. 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 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/" }, "MinLength": 8, "Label": { "zh-cn": "インスタンスパスワード", "en": "Instance Password" }, "AllowedPattern": "[0-9A-Za-z\\_\\-\\&:;'<>,=%`~!@#\\(\\)\\$\\^\\*\\+\\|\\{\\}\\[\\]\\.\\?\\/]+$", "NoEcho": true, "MaxLength": 30, "ConstraintDescription": { "zh-cn": "長さは 8~30 文字で、大文字、小文字、数字、特殊文字(() ` ~ ! @ # $ % ^ & * _ - + = | { } [ ] : ; ' < > , . ? /)のうち 3 種類以上を含める必要があります。", "en": "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 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/" } }, "SecurityGroup": { "Type": "String", "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId", "Description": { "zh-cn": "既存の業務用セキュリティグループのインスタンス ID です。ECS コンソールの [ネットワークとセキュリティ] > [セキュリティグループ] で確認できます。", "en": "The ID of an existing security group. You can go to the ECS console and choose Network & Security > Security Groups to view the security group ID." }, "Label": { "zh-cn": "セキュリティグループ ID", "en": "Security Group ID" } }, "VPC": { "AssociationProperty": "ALIYUN::ECS::VPC::VPCId", "Type": "String", "Description": { "zh-cn": "既存の仮想プライベートクラウド (VPC) のインスタンス ID です。VPC コンソールの [仮想プライベートクラウド] で確認できます。", "en": "The ID of an existing VPC. You can go to the VPC console to view the VPC ID." }, "Label": { "zh-cn": "既存 VPC のインスタンス ID", "en": "Existing VPC Instance ID" } }, "VSwitch": { "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId", "Type": "String", "Description": { "zh-cn": "既存の業務用ネットワーク VSwitch のインスタンス ID です。VPC コンソールの [仮想プライベートクラウド] > [VSwitch] で確認できます。", "en": "The ID of an existing VSwitch. You can go to the VPC console and choose Resources > VSwitches to view the VSwitch ID." }, "Label": { "zh-cn": "ネットワーク VSwitch ID", "en": "VSwitch ID" } } }, "Metadata": { "ALIYUN::ROS::Interface": { "ParameterGroups": [ { "Parameters": [ "VPC", "VSwitch", "SecurityGroup" ], "Label": { "default": { "zh-cn": "基本リソース設定", "en": "Basic Resource Configuration" } } }, { "Parameters": [ "ZoneId", "ImageId", "InstanceType", "SystemDiskCategory", "InstancePassword", "NginxDownloadUrl" ], "Label": { "default": { "zh-cn": "ECS クラウドサーバー設定", "en": "ECS Instance Configuration" } } } ], "TemplateTags": [ "acs:example:Linux application service:Create Nginx application with ROS and OSS" ] } }, "Resources": { "WebServer": { "Type": "ALIYUN::ECS::Instance", "Properties": { "InternetMaxBandwidthOut": 80, "IoOptimized": "optimized", "VpcId": { "Ref": "VPC" }, "UserData": { "Fn::Join": [ "", [ "#!/bin/bash \n", "NginxUrl=", { "Ref": "NginxDownloadUrl" }, "\n", "yum -y install aria2 \n", "aria2c $NginxUrl \n", "rpm -ivh nginx-*.rpm \n", "yum -y install nginx \n", "systemctl enable nginx.service \n", "systemctl restart nginx.service \n" ] ] }, "SecurityGroupId": { "Ref": "SecurityGroup" }, "VSwitchId": { "Ref": "VSwitch" }, "ImageId": { "Ref": "ImageId" }, "InstanceType": { "Ref": "InstanceType" }, "SystemDiskCategory": { "Ref": "SystemDiskCategory" }, "Password": { "Ref": "InstancePassword" } } } }, "Outputs": { "NginxUrl": { "Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "WebServer", "PublicIp" ] }, ":80" ] ] } } } }
-
-
パラメーターを設定します。
-
[パラメーターの設定] タブで、スタック名 を指定します。
-
テンプレートパラメーターの設定 セクションで、次の表に従ってパラメーターを設定します。
セクション
パラメーター
説明
基本リソース設定
既存 VPC のインスタンス ID
ドロップダウンリストからご利用の VPC ID を選択します。
VSwitch ID
ドロップダウンリストからご利用の VSwitch ID を選択します。
セキュリティグループ ID
ドロップダウンリストからご利用のセキュリティグループ ID を選択します。
ECS インスタンス設定
VSwitch 可用区
可用区を選択します(例:ゾーン G)。
イメージ
centos_7 を入力します。
インスタンスタイプ
インスタンスタイプを選択します。
システムディスクタイプ
cloud_ssd を選択します。
インスタンスパスワード
インスタンスのパスワードを入力します。
Nginx ダウンロード URL
ステップ 1 で取得した Nginx インストールパッケージのオブジェクト URL を入力します。
-
リソーススタックの設定 セクションで、デフォルト設定のままにします。
-
[作成] をクリックします。
-
-
デプロイメントを確認します。
-
作成されたスタックの名前をクリックします。
-
[出力]タブをクリックし、次に NginxUrl に表示されている URL をクリックします。

URL をクリックすると、Nginx のウェルカムページが表示されます。これにより、Nginx が実行中であることが確認できます。

ページにアクセスできない場合は、HTTP ポート
80のインバウンドトラフィックを許可するようにセキュリティグループルールを追加してください。「セキュリティグループルールの追加」をご参照ください。
-