

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

# Amazon SNS データ保護ポリシーの例
<a name="sns-message-data-protection-examples"></a>

**重要**  
Amazon SNS メッセージデータ保護は、新規顧客には利用できなくなりました。代替方法の詳細とガイダンスについては、[Amazon SNS メッセージデータ保護の可用性の変更](https://docs.aws.amazon.com/sns/latest/dg/sns-message-data-protection-availability-change.html)」を参照してください。

以下は、機密データの監査および拒否に使用できるデータ保護ポリシーの例です。サンプルアプリケーションを含む完全なチュートリアルについては、「[Introducing message data protection for Amazon SNS](https://aws.amazon.com/blogs/compute/introducing-message-data-protection-for-amazon-sns/)」(Amazon SNS のメッセージデータ保護の実装) のブログ記事を参照してください。

## 監査ポリシーの例
<a name="sns-message-data-protection-audit-example"></a>

監査ポリシーを使うと、インバウンドメッセージの最大 99% を監査して、検出結果を [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html)、[https://docs.aws.amazon.com/firehose/latest/dev/what-is-this-service.html](https://docs.aws.amazon.com/firehose/latest/dev/what-is-this-service.html)、[Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) に送信できます。

例えば、監査ポリシーを作成して、システムのいずれかが誤って機密データを送受信していないかを評価できます。監査結果から、システムがクレジットカード情報を必要としないシステムにその情報を送信していることが明らかになった場合は、データ保護ポリシーを実装してデータの配信を防止できます。

次の例では、クレジットカード番号を検索し、その結果を CloudWatch Logs、Firehose、および Amazon S3 に送信することで、トピックを通過するメッセージの 99% を監査します。

**データ保護ポリシー**:

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Inbound",
      "Principal": ["*"],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Audit": {
          "SampleRate": "99",
          "FindingsDestination": {
            "CloudWatchLogs": {
              "LogGroup": "<example log name>"
            },
            "Firehose": {
              "DeliveryStream": "<example stream name>"
            },
            "S3": {
              "Bucket": "<example bucket name>"
            }
          }
        }
      }
    }
  ]
}
```

**監査結果の形式の例**:

```
{
    "messageId": "...",
    "callerPrincipal": "arn:aws:sts::123456789012:assumed-role/ExampleRole",
    "resourceArn": "arn:aws:sns:us-east-1:123456789012:ExampleArn", 
    "dataIdentifiers": [
        {
            "name": "CreditCardNumber",
            "count": 1,
            "detections": [
                { "start": 1, "end": 2 }
            ]
        }
    ],
    "timestamp": "2021-04-20T00:33:40.241Z"
}
```

## インバウンド識別解除マスキングステートメントを含むポリシーの例
<a name="sns-message-data-protection-inbound-deidentify-mask-example"></a>

次の例では、メッセージの内容から機密データをマスキングして、ユーザーがメッセージ内の `CreditCardNumber` をトピックに発行できないようにします。

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Inbound",
      "Principal": [
        "arn:aws:iam::123456789012:user/ExampleUser"
      ],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Deidentify": {
          "MaskConfig": {
            "MaskWithCharacter": "#"
          }
        }
      }
    }
  ]
}
```

**インバウンド識別解除マスキング結果の例:**

```
// original message
My credit card number is 4539894458086459

// delivered message
My credit card number is ################
```

## インバウンド識別解除の削除ステートメントを使用したポリシーの例
<a name="sns-message-data-protection-inbound-deidentify-redact-example"></a>

次の例では、メッセージ内の機密データを削除して、ユーザーがメッセージ内の `CreditCardNumber` をトピックに発行できないようにします。

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Inbound",
      "Principal": [
        "arn:aws:iam::123456789012:user/ExampleUser"
      ],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Deidentify": {
          "RedactConfig": {}
        }
      }
    }
  ]
}
```

**インバウンド識別解除の削除結果の例:**

```
// original message
My credit card number is 4539894458086459

// delivered message
My credit card number is
```

## アウトバウンド識別解除マスキングステートメントを使用したポリシーの例
<a name="sns-message-data-protection-outbound-deidentify-mask-example"></a>

次の例では、メッセージ内の機密データをマスキングして、ユーザーがメッセージ内の `CreditCardNumber` を受信できないようにします。

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Outbound",
      "Principal": [
        "arn:aws:iam::123456789012:user/ExampleUser"
      ],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Deidentify": {
          "MaskConfig": {
            "MaskWithCharacter": "-"
          }
        }
      }
    }
  ]
}
```

**アウトバウンド識別解除マスキング結果の例:**

```
// original message
My credit card number is 4539894458086459

// delivered message
My credit card number is ----------------
```

## アウトバウンド識別解除の削除ステートメントを使用したポリシーの例
<a name="sns-message-data-protection-outbound-deidentify-redact-example"></a>

次の例では、メッセージ内の機密データを削除して、ユーザーがメッセージ内の `CreditCardNumber` を受信できないようにします。

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Outbound",
      "Principal": [
        "arn:aws:iam::123456789012:user/ExampleUser"
      ],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Deidentify": {
          "RedactConfig": {}
        }
      }
    }
  ]
}
```

**アウトバウンド識別解除の削除結果の例:**

```
// original message
My credit card number is 4539894458086459

// delivered message
My credit card number is
```

## インバウンド拒否ステートメントを使用するポリシーの例
<a name="sns-message-data-protection-inbound-deny-example"></a>

次の例では、メッセージの内容に `CreditCardNumber` が含まれている場合、ユーザーがメッセージをトピックに発行するのをブロックします。API レスポンスで拒否されたペイロードのステータスコードは「403 AuthorizationError」です。

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Inbound",
      "Principal": [
        "arn:aws:iam::123456789012:user/ExampleUser"
      ],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Deny": {}
      }
    }
  ]
}
```

## アウトバウンド拒否ステートメントを使用するポリシーの例
<a name="sns-message-data-protection-outbound-deny-example"></a>

次の例では、 AWS アカウントが を含むメッセージの受信をブロックします`CreditCardNumber`。

```
{
  "Name": "__example_data_protection_policy",
  "Description": "Example data protection policy",
  "Version": "2021-06-01",
  "Statement": [
    {
      "DataDirection": "Outbound",
      "Principal": [
        "arn:aws:iam::123456789012:user/ExampleUser"
      ],
      "DataIdentifier": [
        "arn:aws:dataprotection::aws:data-identifier/CreditCardNumber"
      ],
      "Operation": {
        "Deny": {}
      }
    }
  ]
}
```

**Amazon CloudWatch にロギングされたアウトバウンド拒否結果の例:**

```
{
  "notification": {
    "messageMD5Sum": "2e8f58ff2eeed723b56b15493fbfb5a5",
    "messageId": "8747a956-ebf1-59da-b291-f2c2e4b87c9c",
    "topicArn": "arn:aws:sns:us-east-2:664555388960:test1",
    "timestamp": "2022-09-08 15:40:57.144"
  },
  "delivery": {
    "deliveryId": "6a422437-78cc-5171-ad64-7fa3778507aa",
    "destination": "arn:aws:sqs:us-east-2:664555388960:test",
    "providerResponse": "The topic's data protection policy prohibits this message from being delivered to <subscription arn>",
    "dwellTimeMs": 22,
    "attempts": 1,
    "statusCode": 403
  },
  "status": "FAILURE"
}
```