複数回テンプレートを実行する際に同じパラメーター値を使用する場合、これらの実行を作成する際にパラメーター値を検索して入力する必要があります。 作業を容易にするために、CloudOps Orchestration Service(OOS)のパラメーターストア機能を使用して、特定のパラメーターに値を割り当てることができます。 実行を作成するときは、繰り返し検索することなく、パラメーターストアからパラメーターを選択するだけで済みます。
OOS テンプレートで共通パラメーターを使用する
OOS は共通パラメーターを提供します。 ユーザーが作成および管理するカスタムパラメーターとは異なり、共通パラメーターは Alibaba Cloud によって管理されます。 共通パラメーターは簡単に使用できます。 次の図は、Elastic Compute Service(ECS)インスタンス上のさまざまなオペレーティングシステムの最新イメージを指定するパラメーターを示しています。

たとえば、ECS インスタンスを作成するたびに CentOS 8 イメージの最新バージョンを使用したいとします。 関連する共通パラメーターを使用しない場合は、centos_8_5_x64_20G_alibase_20220428.vhd などの最新イメージの ID を検索し、ECS インスタンスを作成するときにその ID を指定する必要があります。
作業を容易にするために、OOS テンプレートで ECS イメージを指定する共通パラメーターを直接使用できます。 次のサンプルコードは例を示しています。 この例では、latestCentos8ImageId パラメーターを使用して、CentOS 8 イメージの最新バージョンの ID を指定しています。 必要なイメージの ID を検索する必要はなく、latestCentos8ImageId パラメーターの共通パラメーター名を指定するだけです。 共通パラメーターは Alibaba Cloud によって管理されています。 この例では、latestCentos8ImageId パラメーターは aliyun/services/ecs/images/linux/almalinux-latest/almalinux_9_2_x64 に設定されています。 システムは自動的に最新の CentOS 8 イメージを識別します。
Description: Example template, run instance
FormatVersion: OOS-2019-06-01
Parameters:
latestCentos8ImageId:
Type: String
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceType:
Label:
en: InstanceType
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
RegionId: regionId
securityGroupId:
Label:
en: SecurityGroupId
Type: String
AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
AssociationPropertyMetadata:
RegionId: regionId
vSwitchId:
Label:
en: VSwitchId
Type: String
AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
AssociationPropertyMetadata:
RegionId: regionId
Filters:
- SecurityGroupId: securityGroupId
Tasks:
- Name: runInstances
Action: ACS::ECS::RunInstances
Description:
en: Creates one or more ECS instances.
Properties:
imageId: '{{ latestCentOS8ImageId }}'
instanceType: '{{ instanceType }}'
securityGroupId: '{{ securityGroupId }}'
vSwitchId: '{{ vSwitchId }}'
amount: 1
Outputs:
instanceId:
ValueSelector: instanceIds[0]
Type: String
パラメーター構成
OOS コンソールでは、{{oos:共通パラメーター名}} の形式で共通パラメーターを手動で指定できます。 例: {{oos:aliyun/services/ecs/images/linux/almalinux-latest/almalinux_9_2_x64}}。
また、latestCentos8ImageId フィールドの横にある [パラメーターの選択] アイコンをクリックして、必要な共通パラメーターを選択することもできます。

または、OOS テンプレートで OOS 共通パラメーターの形式で共通パラメーターを直接指定することもできます。 次のサンプルコードは例を示しています。
Description: Example template, run instance
FormatVersion: OOS-2019-06-01
Parameters:
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceType:
Label:
en: InstanceType
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
RegionId: regionId
securityGroupId:
Label:
en: SecurityGroupId
Type: String
AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
AssociationPropertyMetadata:
RegionId: regionId
vSwitchId:
Label:
en: VSwitchId
Type: String
AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
AssociationPropertyMetadata:
RegionId: regionId
Filters:
- SecurityGroupId: securityGroupId
Tasks:
- Name: runInstances
Action: ACS::ECS::RunInstances
Description:
en: Creates one or more ECS instances.
Properties:
imageId: '{{oos:aliyun/services/ecs/images/linux/almalinux-latest/almalinux_9_2_x64}}'
instanceType: '{{ instanceType }}'
securityGroupId: '{{ securityGroupId }}'
vSwitchId: '{{ vSwitchId }}'
amount: 1
Outputs:
instanceId:
ValueSelector: instanceIds[0]
Type: StringROS テンプレートで共通パラメーターを使用する
ROS テンプレートの構文に基づいて、Resource Orchestration Service(ROS)テンプレートで共通パラメーターを使用できます。 たとえば、imageId パラメーターを aliyun/services/ecs/centos-latest/centos_8_5_64 に設定して、CentOS 8 イメージの最新バージョンを使用できます。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
InstanceType:
Type: String
Default: ECS.c6.large
ImageId:
Type: 'ALIYUN::OOS::Parameter::Value'
Default: aliyun/services/ecs/centos-latest/centos_8_5_64
SecurityGroupId:
Type: String
AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
AssociationPropertyMetadata:
VpcId: '${VpcId}'
VpcId:
Type: String
AssociationProperty: 'ALIYUN::ECS::VPC::VPCId'
AssociationPropertyMetadata:
RegionId: '${RegionId}'
Resources:
ECS:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
ImageId:
Ref: ImageId
InstanceType:
Ref: InstanceType
MaxAmount: 1
SecurityGroupId:
Ref: SecurityGroupId
VpcId:
Ref: VpcId
NetworkType: vpc
Outputs:
InstanceIds:
Value:
'Fn::GetAtt':
- ECS
- InstanceIds
ROS コンソールで、[ImageId] フィールドに共通パラメーターの名前を指定します。

共通パラメーターを {{resolve:oos:共通パラメーター名}} フォーマットで参照することもできます。
また、ROS テンプレートの Resources セクションで {{resolve:oos:共通パラメーター名}} の形式で共通パラメーターを参照することもできます。
たとえば、Resources セクションの ImageId パラメーターに {{resolve:oos:aliyun/services/ecs/centos-latest/centos_8_5_64}} を指定できます。 次のサンプルコードは例を示しています。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
InstanceType:
Type: String
Default: ECS.c6.large
SecurityGroupId:
Type: String
AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
AssociationPropertyMetadata:
VpcId: '${VpcId}'
VpcId:
Type: String
AssociationProperty: 'ALIYUN::ECS::VPC::VPCId'
AssociationPropertyMetadata:
RegionId: '${RegionId}'
Resources:
ECS:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
ImageId: '{{resolve:oos:aliyun/services/ecs/centos-latest/centos_8_5_64}}'
InstanceType:
Ref: InstanceType
MaxAmount: 1
SecurityGroupId:
Ref: SecurityGroupId
VpcId:
Ref: VpcId
NetworkType: vpc
Outputs:
InstanceIds:
Value:
'Fn::GetAtt':
- ECS
- InstanceIds