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

Cloud Config:コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成する

最終更新日:Apr 12, 2025

Cloud Config では、コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成できます。Cloud Config でサポートされているマネージドルール、またはビジネス要件に基づいて作成した条件ルールを含むコンプライアンスパッケージテンプレートを定義、インポート、およびエクスポートできます。これは、ビジネスのコンプライアンスを管理するための強力なツールを提供します。このトピックでは、ビジネス要件に基づいてコンプライアンスルールのセットを効率的に定義できるように、コンプライアンスパッケージテンプレートの構造とパラメーターについて説明します。

テンプレート構造

コンプライアンスパッケージテンプレートは JSON ファイルでエクスポートされます。ファイル名はコンプライアンスパッケージの名前で、ファイル名拡張子は .json です。.txt または .json ファイルでコンプライアンスパッケージテンプレートをインポートできます。ファイルサイズは 1 MB を超えることはできません。ファイルの内容は、compliancePackTemplate(オプション)と configRuleTemplates(必須)の 2 つの部分で構成されます。

compliancePackTemplate

compliancePackTemplate には、コンプライアンスパッケージの名前、説明、およびリスクレベルが含まれます。JSON 形式の構文:

{
  "riskLevel": 1,
  "compliancePackName": "The name of the compliance package", // コンプライアンスパッケージの名前
  "description": "The description of the compliance package", // コンプライアンスパッケージの説明
  "scope": {
    "complianceResourceTypes": [
      "The resource types to which the rule is applicable" // ルールが適用可能なリソースタイプ
    ],
    "complianceResourceIds": [
      "The ID of the evaluated resource" // 評価対象リソースの ID
    ],
    "complianceExcludeResourceIds": [
      "The ID of the excluded resource" // 除外対象リソースの ID
    ],
    "complianceRegionIds": [
      "The ID of the evaluated region" // 評価対象リージョンの ID
    ],
    "complianceExcludeRegionIds": [
      "The ID of the excluded region" // 除外対象リージョンの ID
    ],
    "complianceResourceGroupIds": [
      "The ID of the evaluated resource group" // 評価対象リソースグループの ID
    ],
    "complianceExcludeResourceGroupIds": [
      "The ID of the excluded resource group" // 除外対象リソースグループの ID
    ],
    "complianceTagsScope": [
      {
        "tagKey": "The effective tag key", // 有効なタグキー
        "tagValue": "The effective tag value" // 有効なタグ値
      }
    ],
    "complianceExcludeTagsScope": [
      {
        "tagKey": "The excluded tag key", // 除外対象のタグキー
        "tagValue": "The excluded tag value" // 除外対象のタグ値
      }
    ]
  }
}

パラメーター

必須

説明

compliancePackName

いいえ

コンプライアンスパッケージの名前。コンプライアンスシナリオに基づいて名前を指定することをお勧めします。コンプライアンスパッケージの名前は、次のルールに基づいて決定されます。

  • API リクエストまたはコンフィギュレーションファイルでコンプライアンスパッケージの名前が指定されていない場合、コンプライアンスパッケージにはデフォルトで ミリ秒レベルの UNIX タイムスタンプ.json の形式で名前が付けられます。

  • API リクエストとコンフィギュレーションファイルでコンプライアンスパッケージの名前が指定されている場合、コンフィギュレーションファイルで指定されている名前が優先されます。

riskLevel

いいえ

コンプライアンスパッケージのリスクレベル。このパラメーターは、さまざまなコンプライアンスパッケージの重要度を区別するために使用されます。有効な値:

  • 1: 低リスク。

  • 2: 中リスク。

  • 3: 高リスク。

description

いいえ

コンプライアンスパッケージの説明。このパラメーターは、コンプライアンスパッケージのアプリケーションシナリオを説明するために使用されます。

scope

いいえ

ルールの適用範囲。

例:

{
  "configRuleTemplates": [],
  "compliancePackTemplate": {
    "riskLevel": 2,
    "compliancePackName": "Write a compliance package template in a configuration file", // コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成する
    "scope": {
      "complianceResourceIds": [
        "i-t4n3u1pz97547xg****.i-t4n3u1pz97547xg0****.",
        "i-t4n1bxf3xr70wjh5****",
        "i-t4n133q6k9czgun****",
        "i-t4n3s3qqti2zaxu****"
      ],
      "complianceResourceGroupIds": [
        "rg-aek2yl36l*****"
      ],
      "complianceTagsScope": [
        {
          "tagKey": "config",
          "tagValue": "configTest"
        }
      ],
      "complianceRegionIds": [
        "ap-southeast-1"
      ]
    },
    "description": "Performs the import and export testing for writing a compliance package template in a configuration file." // コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成するためのインポートとエクスポートのテストを実行します。
  }
}

configRuleTemplates

configRuleTemplates には、コンプライアンスパッケージのルールが含まれています。ルールは JSON ARRAY タイプです。構文:

[
    {
        "configRuleName": "The name of the rule", // ルールの名前
        "riskLevel": 3,
        "scope": {
            "complianceResourceTypes": [
                "The resource types to which the rule is applicable" // ルールが適用可能なリソースタイプ
    ],
    "complianceResourceIds": [
      "The ID of the evaluated resource" // 評価対象リソースの ID
    ],
    "complianceExcludeResourceIds": [
      "The ID of the excluded resource" // 除外対象リソースの ID
    ],
    "complianceRegionIds": [
      "The ID of the evaluated region" // 評価対象リージョンの ID
    ],
    "complianceExcludeRegionIds": [
      "The ID of the excluded region" // 除外対象リージョンの ID
    ],
    "complianceResourceGroupIds": [
      "The ID of the evaluated resource group" // 評価対象リソースグループの ID
    ],
    "complianceExcludeResourceGroupIds": [
      "The ID of the excluded resource group" // 除外対象リソースグループの ID
    ],
    "complianceTagsScope": [
      {
        "tagKey": "The effective tag key", // 有効なタグキー
        "tagValue": "The effective tag value" // 有効なタグ値
      }
    ],
    "complianceExcludeTagsScope": [
      {
        "tagKey": "The excluded tag key", // 除外対象のタグキー
        "tagValue": "The excluded tag value" // 除外対象のタグ値
        }
      ]
    },
    "description": "The description of the rule", // ルールの説明
        "source": {
            "owner": "The source of the rule", // ルールのソース
            "identifier": "The identifier of the rule", // ルールの識別子
            "sourceDetails": [
                {
                    "messageType": "The trigger type of the rule", // ルールのトリガータイプ
                    "maximumExecutionFrequency": "The interval at which the rule is triggered" // ルールがトリガーされる間隔
                },
                {
                    "messageType": "The trigger type of the rule" // ルールのトリガータイプ
                }
            ],
            "conditions": "The content of the condition rule" // 条件ルールの内容
        },
        "inputParameters": {
            "paramName1": "The value of the paramName1 parameter", // paramName1 パラメーターの値
            "paramName2": "The value of the paramName2 parameter" // paramName2 パラメーターの値
        }
    }
]

パラメーター

必須

説明

configRuleName

はい

ルールの名前。

scope.complianceResourceTypes

はい

ルールが適用可能なリソースタイプ。値は JSON 配列です。

description

いいえ

ルールの説明。

source.owner

はい

ルールのソース。有効な値:

  • ALIYUN: Cloud Config でサポートされているマネージドルール。

  • CUSTOM_CONFIGURATION: ユーザー定義の条件ルール。コンプライアンスパッケージテンプレートは、ユーザー定義の条件ルールをサポートしています。conditions パラメーターを使用して、ビジネス要件に基づいて JSON 文字列で複雑なコンプライアンス条件を定義できます。

source.identifier

はい

ルールの識別子。値はルールのソースによって異なります。

  • ルールがユーザー定義の条件ルールの場合は、値を acs-config-configuration に設定します。

  • ルールが Cloud Config でサポートされているマネージドルールの場合は、このパラメーターをマネージドルールの識別子に設定します。例: oss-bucket-referer-limit。Cloud Config でサポートされているすべてのマネージドルールの詳細については、「マネージドルール」をご参照ください。

source.sourceDetails.messageType

はい

ルールのトリガータイプ。有効な値:

  • ConfigurationItemChangeNotification: ルールは構成の変更によってトリガーされます。関連リソースは、リソースの構成が変更された場合にのみルールに対してチェックされます。

  • ScheduledNotification: ルールは定期的にトリガーされます。関連リソースはルールに対して定期的にチェックされます。このパラメーターを ScheduledNotification に設定する場合は、maximumExecutionFrequency パラメーターも指定する必要があります。

source.sourceDetails.maximumExecutionFrequency

いいえ

ルールがトリガーされる間隔。有効な値:

  • One_Hour

  • Three_Hours

  • Six_Hours

  • Twelve_Hours

  • TwentyFour_Hours

説明

source.sourceDetails.messageType パラメーターを ScheduledNotification に設定する場合は、このパラメーターが必要です。

source.conditions

いいえ

条件ルールの内容。

説明

source.identifier パラメーターを acs-config-configuration に設定する場合は、このパラメーターが必要です。

inputParameters

いいえ

ルールの入力パラメーター。マネージドルールの入力パラメーターについては、「マネージドルール」の対応するリンクをクリックし、「ルールの詳細」セクションの「入力パラメーター」項目の説明をご参照ください。すべての入力パラメーターは STRING タイプです。入力パラメータールールの詳細

scope

いいえ

ルールの適用範囲。

riskLevel

いいえ

ルールのリスクレベル。有効な値:

  • 1: 高リスク。

  • 2: 中リスク。

  • 3: 低リスク。

例:

{
  "configRuleTemplates": [
    {
      "configRuleName": "ecs-instance-deletion-protection-enabled",
      "riskLevel": 3,
      "scope": {
        "complianceResourceIds": [
          "i-t4n3u1pz97547xg0****.i-t4n3u1pz97547xg0****",
          "i-t4n1bxf3xr70wjh5****",
          "i-t4n133q6k9czgun****",
          "i-t4n3s3qqti2zaxu****"
        ],
        "complianceResourceGroupIds": [
          "rg-aek2yl36lg****"
        ],
        "complianceTagsScope": [
          {
            "tagKey": "config",
            "tagValue": "configTest"
          }
        ],
        "complianceRegionIds": [
          "ap-southea****"
        ],
        "complianceResourceTypes": [
          "ACS::ECS::Instance"
        ]
      },
      "description": "Checks whether the release protection feature is enabled for each Elastic Compute Service (ECS) instance. If so, the evaluation result is Compliant.", // 各 Elastic Compute Service (ECS) インスタンスでリリース保護機能が有効になっているかどうかを確認します。有効になっている場合、評価結果は準拠です。
      "source": {
        "owner": "ALIYUN",
        "identifier": "ecs-instance-deletion-protection-enabled",
        "sourceDetails": [
          {
            "messageType": "ConfigurationItemChangeNotification"
          }
        ]
      },
      "inputParameters": {}
    }
  ],
  "compliancePackTemplate": {
    "riskLevel": 2,
    "compliancePackName": "Write a compliance package template in a configuration file", // コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成する
    "scope": {
      "complianceResourceIds": [
        "i-t4n3u1pz97547xg****.i-t4n3u1pz97547xg****",
        "i-t4n1bxf3xr70wjh5****",
        "i-t4n133q6k9czgunx****",
        "i-t4n3s3qqti2zaxux****"
      ],
      "complianceResourceGroupIds": [
        "rg-aek2yl36lgo****"
      ],
      "complianceTagsScope": [
        {
          "tagKey": "config",
          "tagValue": "configTest"
        }
      ],
      "complianceRegionIds": [
        "ap-southeast-1"
      ]
    },
    "description": "Performs the import and export testing for writing a compliance package template in a configuration file." // コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成するためのインポートとエクスポートのテストを実行します。
  }
}

{
  "configRuleTemplates": [
    {
      "configRuleName": "ecs-instance-chargetype-check",
      "riskLevel": 3,
      "scope": {
        "complianceResourceIds": [
          "i-t4n3u1pz97547xg0****.i-t4n3u1pz97547xg*****",
          "i-t4n1bxf3xr70wjh5*****",
          "i-t4n133q6k9czgun*****",
          "i-t4n3s3qqti2zaxu*****"
        ],
        "complianceResourceGroupIds": [
          "rg-aek2yl36l*****"
        ],
        "complianceTagsScope": [
          {
            "tagKey": "config",
            "tagValue": "configTest"
          }
        ],
        "complianceRegionIds": [
          "ap-southeast-1"
        ],
        "complianceResourceTypes": [
          "ACS::ECS::Instance"
        ]
      },
      "description": "Checks whether the billing method of each ECS instance is subscription. If so, the evaluation result is Compliant.", // 各 ECS インスタンスの課金方法がサブスクリプションであるかどうかを確認します。そうである場合、評価結果は準拠です。
      "source": {
        "owner": "ALIYUN",
        "identifier": "ecs-instance-chargetype-check",
        "sourceDetails": [
          {
            "messageType": "ConfigurationItemChangeNotification"
          }
        ]
      },
      "inputParameters": {}
    },
    {
      "configRuleName": "ecs-public-access-check",
      "riskLevel": 3,
      "scope": {
        "complianceResourceIds": [
          "i-t4n3u1pz97547x*****.i-t4n3u1pz97547*****",
          "i-t4n1bxf3xr70w*****",
          "i-t4n133q6k9czg*****",
          "i-t4n3s3qqti2zax******"
        ],
        "complianceResourceGroupIds": [
          "rg-aek2yl36l*****"
        ],
        "complianceTagsScope": [
          {
            "tagKey": "config",
            "tagValue": "configTest"
          }
        ],
        "complianceRegionIds": [
          "ap-southeast-1"
        ],
        "complianceResourceTypes": [
          "ACS::ECS::Instance"
        ]
      },
      "description": "Checks whether a public IPv4 address or an EIP is specified for each ECS instance. If not, the evaluation result is Compliant.", // 各 ECS インスタンスにパブリック IPv4 アドレスまたは EIP が指定されているかどうかを確認します。指定されていない場合、評価結果は準拠です。
      "source": {
        "owner": "ALIYUN",
        "identifier": "ecs-instance-no-public-ip",
        "sourceDetails": [
          {
            "messageType": "ConfigurationItemChangeNotification"
          }
        ]
      },
      "inputParameters": {}
    },
    {
      "configRuleName": "ecs-instance-deletion-protection-enabled",
      "riskLevel": 3,
      "scope": {
        "complianceResourceIds": [
          "i-t4n3u1pz9754*****.i-t4n3u1pz97547x*****",
          "i-t4n1bxf3xr70wj*****",
          "i-t4n133q6k9czgu*****",
          "i-t4n3s3qqti2zaxu*****"
        ],
        "complianceResourceGroupIds": [
          "rg-aek2yl36l****"
        ],
        "complianceTagsScope": [
          {
            "tagKey": "config",
            "tagValue": "configTest"
          }
        ],
        "complianceRegionIds": [
          "ap-southeast-1"
        ],
        "complianceResourceTypes": [
          "ACS::ECS::Instance"
        ]
      },
      "description": "Checks whether the release protection feature is enabled for each ECS instance. If so, the evaluation result is Compliant.", // 各 ECS インスタンスでリリース保護機能が有効になっているかどうかを確認します。有効になっている場合、評価結果は準拠です。
      "source": {
        "owner": "ALIYUN",
        "identifier": "ecs-instance-deletion-protection-enabled",
        "sourceDetails": [
          {
            "messageType": "ConfigurationItemChangeNotification"
          }
        ]
      },
      "inputParameters": {}
    }
  ],
  "compliancePackTemplate": {
    "riskLevel": 2,
    "compliancePackName": "Write a compliance package template in a configuration file", // コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成する
    "scope": {
      "complianceResourceIds": [
        "i-t4n3u1pz97547xg0*****.i-t4n3u1pz97547xg******",
        "i-t4n1bxf3xr70w******",
        "i-t4n133q6k9czgun*****",
        "i-t4n3s3qqti2zaxux*****"
      ],
      "complianceResourceGroupIds": [
        "rg-aek2yl36l******"
      ],
      "complianceTagsScope": [
        {
          "tagKey": "config",
          "tagValue": "configTest"
        }
      ],
      "complianceRegionIds": [
        "ap-southeast-1"
      ]
    },
    "description": "Performs the import and export testing for writing a compliance package template in a configuration file." // コンフィギュレーションファイルでコンプライアンスパッケージテンプレートを作成するためのインポートとエクスポートのテストを実行します。
  }
}

コンプライアンスパッケージテンプレートのインポートとエクスポート

.json または .txt ファイルのコンプライアンスパッケージテンプレートを Cloud Config にインポートできます。また、.json ファイルでコンプライアンスパッケージテンプレートをエクスポートすることもできます。その後、エクスポートされたテンプレートを共有およびバックアップできます。これは、ルールを柔軟かつ便利に管理するのに役立ちます。