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

Resource Orchestration Service:パラメーターの値に基づいて異なるパラメーターセットを表示する

最終更新日:Jan 16, 2025

テンプレートを作成する際に、パラメーターを異なるパラメーターセットに関連付けることができます。複数の値を持つパラメーターがある場合は、パラメーターに指定した値に基づいて異なるパラメーターセットを設定できます。このトピックでは、パラメーターの値に基づいて異なるパラメーターセットを表示する方法について説明します。この例では、targetInstanceChargeType パラメーターの値に基づいて、targetPeriodUnit パラメーターと targetPeriod パラメーターが表示されます。

テンプレート構文

テンプレートの Parameters セクションで AssociationProperty パラメーターと AssociationPropertyMetadata パラメーターを指定することで、パラメーターに指定した値に基づいて異なるパラメーターセットが表示されるようにできます。この例では、targetInstanceChargeType パラメーターの値が指定されています。AssociationPropertyMetadata では、異なるパラメーターセットが表示されるかどうかを決定するために、Visible に関数を指定する必要があります。次のサンプルコードは、Visible を指定する方法を示しています。

Visible:
  Condition: Object // 異なるパラメーターセットが表示される条件を 1 つ以上指定します。

Condition に指定できる関数と例を以下に示します。

  • 関数: "Fn::Equals": ['${targetInstanceChargeType}', "PostPaid"]

  • 関数: "Fn::Not": ${condition}

  • 関数: "Fn::And": [${condition1}, ${condition2}, ...]

  • 関数: "Fn::Or": [${condition1}, ${condition2}, ...]

サンプルテンプレート

次のサンプルテンプレートでは、課金方法を取得するために AssociationProperty が指定され、異なるパラメーターセットにフィルター条件を追加するために AssociationPropertyMetadata が指定されています。このようにして、ROS コンソールはリソースを作成するときにパラメーターをフィルタリングできます。

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: This template supports single-instance with custom image, including scenarios using existing or creating new VPC, VSwitch, SecurityGroup and creating ECS by prepaid or postpaid model. // このテンプレートは、カスタムイメージを使用した単一インスタンスをサポートしており、既存のVPC、VSwitch、SecurityGroupの使用または新規作成、およびプリペイドまたはポストペイドモデルによるECSの作成などのシナリオが含まれます。
Parameters:
  targetInstanceChargeType:
    Description:
      name-en: targetInstanceChargeType
    Type: String
    AssociationProperty: ChargeType
  targetPeriodUnit:
    Description:
      name-en: The unit of the subscription period // サブスクリプション期間の単位
    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 // インスタンスのサブスクリプション期間
      en: 'Valid values: Valid values when PeriodUnit is set to Week: 1, 2, 3, and 4. Valid values when PeriodUnit is set to Month: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60.' // 有効な値:PeriodUnitがWeekに設定されている場合の有効な値:1、2、3、4。PeriodUnitがMonthに設定されている場合の有効な値:1、2、3、4、5、6、7、8、9、12、24、36、48、60。
    Type: Number
    AllowedValues:
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 7
      - 8
      - 9
      - 12
      - 24
      - 36
      - 48
      - 60
    Default: 1
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${targetInstanceChargeType}
              - PostPaid

パラメーター:

  • targetInstanceChargeType: 課金方法。AssociationProperty パラメーターは ChargeType に設定されています。この場合、ROS コンソールは targetInstanceChargeType パラメーターの値に基づいてパラメーターをフィルタリングします。

  • targetPeriodUnit: サブスクリプション課金方法の単位。AssociationPropertyMetadata パラメーターは {"Visible": {"Condition": {"Fn::Not": {"Fn::Equals": ["${targetInstanceChargeType}","PostPaid"]}}}} に設定されています。これは、targetInstanceChargeType パラメーターが PostPaid に設定されていない場合に targetPeriodUnit パラメーターが表示されることを指定します。

    説明

    targetInstanceChargeType パラメーターの有効な値は PrePaid と PostPaid です。

  • targetPeriod: 購入するサブスクリプションリソースの期間。AssociationPropertyMetadata パラメーターは {"Visible": {"Condition": {"Fn::Not": {"Fn::Equals": ["${targetInstanceChargeType}","PostPaid"]}}}} に設定されています。これは、targetInstanceChargeType パラメーターが PostPaid に設定されていない場合に targetPeriod パラメーターが表示されることを指定します。

サンプル GUI

上記のテンプレートを使用してスタックを作成する際にサブスクリプション課金方法を選択すると、ROS コンソールは次の図に示すパラメーターを表示します。

targetInstanceChargeType