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

Resource Orchestration Service:依存関係に基づくパラメーターの動的表示

最終更新日:Jun 17, 2026

別のパラメーターの値に基づいて、テンプレートのパラメーターを条件付きで表示または非表示にできます。たとえば、課金方法がサブスクリプションの場合にのみ、期間単位とサブスクリプション期間を表示できます。

テンプレート構文

別のパラメーターの値に基づいて表示/非表示を制御するには、パラメーターに AssociationPropertyAssociationPropertyMetadata を指定します。AssociationPropertyMetadata では、関数を使用してパラメーターを表示するかどうかを判定する Visible フィールドを定義します。構文は次のとおりです:

Visible:
  Condition: Object # このパラメーターを表示するための条件。

Condition フィールドは、次の関数に対応しています:

  • 関数: "Fn::Equals": ["${targetInstanceChargeType}", "PostPaid"]
  • 関数: "Fn::Not": ${condition}
  • 関数: "Fn::And": [${condition1}, ${condition2}, ...]
  • 関数: "Fn::Or": [${condition1}, ${condition2}, ...]

テンプレート例

この例では、AssociationPropertytargetInstanceChargeType パラメーターに設定し、これを課金方法の制御パラメーターとします。続いて、依存パラメーターに AssociationPropertyMetadata を使用して、表示条件を定義します。これにより、スタックの作成時に動的なパラメーターのフィルタリングが可能になります。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 単一 ECS インスタンスをカスタムイメージから作成するためのテンプレート例です。新しいベースリソース (VPC、VSwitch、セキュリティグループ) を作成するか、既存のリソースを使用することができます。ECS インスタンスの課金方法として、サブスクリプションと従量課金の両方に対応しています。
  en: An example template for creating a single ECS instance from a custom image. You can either create new base resources (VPC, VSwitch, security group) or use existing ones. Supports both subscription and pay-as-you-go billing methods for the ECS instance.
Parameters:
  targetInstanceChargeType:
    Description:
      name-en: targetInstanceChargeType
      name-zh-cn: 課金方法
    Type: String
    AssociationProperty: ChargeType
  targetPeriodUnit:
    Description:
      name-en: The unit of the subscription period
      name-zh-cn: サブスクリプションの期間単位
    Type: String
    AllowedValues:
      - Week
      - Month
    Default: Month
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${targetInstanceChargeType}
              - PostPaid
  targetPeriod:
    Description:
      name-en: The subscription period of the instance
      name-zh-cn: サブスクリプション期間
      en: 'Valid values: 1, 2, 3, and 4 if PeriodUnit is Week. 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60 if PeriodUnit is Month.'
      zh-cn: '有効値:PeriodUnit が Week の場合:1、2、3、4。PeriodUnit が Month の場合:1、2、3、4、5、6、7、8、9、12、24、36、48、60。'
    Type: Number
    Default: 1
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${targetInstanceChargeType}
              - PostPaid

パラメーター:

  • targetInstanceChargeType:課金方法。AssociationPropertyChargeType に設定されているため、他のパラメーターの表示/非表示は、このパラメーターの値に依存します。
  • targetPeriodUnit:期間単位。AssociationPropertyMetadata{"Visible": {"Condition": {"Fn::Not": {"Fn::Equals": ["${targetInstanceChargeType}","PostPaid"]}}}} に設定されています。この条件により、targetInstanceChargeTypePostPaid に設定されていない場合にのみ、targetPeriodUnit パラメーターが表示されます。
    説明 targetInstanceChargeType パラメーターは、課金方法がサブスクリプションの場合は PrePaid を、従量課金の場合は PostPaid を値として取ります。
  • targetPeriod:サブスクリプション期間。AssociationPropertyMetadata{"Visible": {"Condition": {"Fn::Not": {"Fn::Equals": ["${targetInstanceChargeType}","PostPaid"]}}}} は に設定されています。この条件により、targetInstanceChargeTypePostPaid に設定されていない場合にのみ、targetPeriod パラメーターが表示されます。

コンソールでの設定

このテンプレートからサブスクリプションの課金方法でスタックを作成すると、ROS コンソールには次の依存パラメーターが表示されます: [PeriodUnit][Week] または [Month] を選択できます) および [Subscription period][PeriodUnit][Week] に設定されている場合、サブスクリプション期間の有効な値は 1、2、3、4 です。[PeriodUnit][Month] に設定されている場合、有効な値は 1、2、3、4、5、6、7、8、9、12、24、36、48、60 です。