

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# サイズが大きすぎる設定項目の変更の通知例
<a name="oversized-notification-example"></a>

がリソースの設定変更 AWS Config を検出すると、設定項目 (CI) 通知が送信されます。通知が Amazon Simple Notification Service (Amazon SNS) の最大許容サイズを超えている場合、通知には設定項目の概要が含まれます。

通知の全詳細は、`s3BucketLocation` フィールドで指定した Amazon S3 バケット内に表示されています。

次の例は、Amazon EC2 インスタンスの CI を示す通知です。通知には、変更の概要と Amazon S3 バケット内の通知の参照先が含まれています。

```
View the Timeline for this Resource in the Console:
    https://console.aws.amazon.com/config/home?region=us-west-2#/timeline/AWS::EC2::Instance/resourceId_14b76876-7969-4097-ab8e-a31942b02e80?time=2016-10-06T16:46:16.261Z
    
    The full configuration item change notification for this resource exceeded the maximum size allowed by Amazon Simple Notification Service (SNS). A summary of the configuration item is provided here. You can view the complete notification in the specified Amazon S3 bucket location.
    
    New State Record Summary:
    ----------------------------
    {
      "configurationItemSummary": {
        "changeType": "UPDATE",
        "configurationItemVersion": "1.2",
        "configurationItemCaptureTime": "2016-10-06T16:46:16.261Z",
        "configurationStateId": 0,
        "awsAccountId": "123456789012",
        "configurationItemStatus": "OK",
        "resourceType": "AWS::EC2::Instance",
        "resourceId": "resourceId_14b76876-7969-4097-ab8e-a31942b02e80",
        "resourceName": null,
        "ARN": "arn:aws:ec2:us-west-2:123456789012:instance/resourceId_14b76876-7969-4097-ab8e-a31942b02e80",
        "awsRegion": "us-west-2",
        "availabilityZone": null,
        "configurationStateMd5Hash": "8f1ee69b287895a0f8bc5753eca68e96",
        "resourceCreationTime": "2016-10-06T16:46:10.489Z"
      },
      "s3DeliverySummary": {
        "s3BucketLocation": "amzn-s3-demo-bucket/AWSLogs/123456789012/Config/us-west-2/2016/10/6/OversizedChangeNotification/AWS::EC2::Instance/resourceId_14b76876-7969-4097-ab8e-a31942b02e80/123456789012_Config_us-west-2_ChangeNotification_AWS::EC2::Instance_resourceId_14b76876-7969-4097-ab8e-a31942b02e80_20161006T164616Z_0.json.gz",
        "errorCode": null,
        "errorMessage": null
      },
      "notificationCreationTime": "2016-10-06T16:46:16.261Z",
      "messageType": "OversizedConfigurationItemChangeNotification",
      "recordVersion": "1.0"
    }
```

## オーバーサイズの設定項目にアクセスする方法
<a name="oversized-notification-example-access"></a>

設定項目がオーバーサイズの場合は、概要のみが Amazon SNS に送信されます。完全な設定項目 (CI) は Amazon S3 に保存されます。

次のコード例は、完全な CI にアクセスする方法を示しています。

```
import boto3
import json

def handle_oversized_configuration_item(event):
    """
    Example of handling an oversized configuration item notification
    
    When a configuration item is oversized:
    1. AWS Config sends a summary notification through SNS
    2. The complete configuration item is stored in S3
    3. Use get_resource_config_history API to retrieve the complete configuration
    """
    
    # Extract information from the summary notification
    if event['messageType'] == 'OversizedConfigurationItemChangeNotification':
        summary = event['configurationItemSummary']
        resource_type = summary['resourceType']
        resource_id = summary['resourceId']
        
        # Initialize AWS Config client
        config_client = boto3.client('config')
        
        # Retrieve the complete configuration item
        response = config_client.get_resource_config_history(
            resourceType=resource_type,
            resourceId=resource_id
        )
        
        if response['configurationItems']:
            config_item = response['configurationItems'][0]
            
            # For EC2 instances, the configuration contains instance details
            configuration = json.loads(config_item['configuration'])
            print(f"Instance Configuration: {configuration}")
            
            # Handle supplementary configuration if present
            if 'supplementaryConfiguration' in config_item:
                for key, value in config_item['supplementaryConfiguration'].items():
                    if isinstance(value, str):
                        config_item['supplementaryConfiguration'][key] = json.loads(value)
                print(f"Supplementary Configuration: {config_item['supplementaryConfiguration']}")
            
            return config_item
            
        # If needed, you can also access the complete notification from S3
        s3_location = event['s3DeliverySummary']['s3BucketLocation']
        print(f"Complete notification available in S3: {s3_location}")
    
    return None
```

## 仕組み
<a name="handle-oversized-config-workflow"></a>

1. 関数は、 AWS Config 通知を含むイベントパラメータを受け入れます。

1. メッセージタイプがオーバーサイズの設定通知であるかどうかをチェックします。

1. 関数は、概要からリソースタイプと ID を抽出します。

1.  AWS Config クライアントを使用して、完全な設定履歴を取得します。

1. 関数は、メイン設定と補足設定の両方を処理します。

1. 必要に応じて、指定された S3 の場所から完全な通知にアクセスできます。