

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Contoh kebijakan perlindungan data Amazon SNS
<a name="sns-message-data-protection-examples"></a>

**penting**  
Perlindungan data pesan Amazon SNS tidak lagi tersedia untuk pelanggan baru. Untuk informasi selengkapnya dan panduan tentang alternatif, lihat [perubahan ketersediaan perlindungan data pesan Amazon SNS](https://docs.aws.amazon.com/sns/latest/dg/sns-message-data-protection-availability-change.html).

Contoh berikut adalah kebijakan perlindungan data yang dapat Anda gunakan untuk mengaudit dan menolak data sensitif. Untuk tutorial lengkap yang menyertakan aplikasi contoh, lihat [Memperkenalkan perlindungan data pesan untuk posting blog Amazon SNS](https://aws.amazon.com/blogs/compute/introducing-message-data-protection-for-amazon-sns/).

## Contoh kebijakan untuk audit
<a name="sns-message-data-protection-audit-example"></a>

Kebijakan audit memungkinkan Anda mengaudit hingga 99% pesan masuk dan mengirim temuan ke [Amazon CloudWatch,[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), dan [Amazon](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) S3.

Misalnya, Anda dapat membuat kebijakan audit untuk mengevaluasi apakah ada sistem Anda yang secara tidak sengaja mengirim atau menerima data sensitif. Jika hasil audit Anda menunjukkan bahwa sistem mengirimkan informasi kartu kredit ke sistem yang tidak memerlukannya, Anda dapat menerapkan kebijakan perlindungan data untuk memblokir pengiriman data.

Contoh berikut mengaudit 99% pesan yang mengalir melalui topik dengan mencari nomor kartu kredit dan mengirimkan temuan ke CloudWatch Log, Firehose, dan Amazon S3.

**Kebijakan perlindungan data**:

```
{
  "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>"
            }
          }
        }
      }
    }
  ]
}
```

**Contoh format hasil audit**:

```
{
    "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"
}
```

## Contoh kebijakan dengan pernyataan topeng de-identifikasi inbound
<a name="sns-message-data-protection-inbound-deidentify-mask-example"></a>

Contoh berikut mencegah pengguna memublikasikan pesan ke topik `CreditCardNumber` dengan menyembunyikan data sensitif dari konten pesan.

```
{
  "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": "#"
          }
        }
      }
    }
  ]
}
```

**Contoh hasil topeng de-identifikasi masuk:**

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

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

## Contoh kebijakan dengan pernyataan redact de-identifikasi-inbound
<a name="sns-message-data-protection-inbound-deidentify-redact-example"></a>

Contoh berikut mencegah pengguna memublikasikan pesan ke topik `CreditCardNumber` dengan menyunting data sensitif dari konten pesan.

```
{
  "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": {}
        }
      }
    }
  ]
}
```

**Contoh hasil penyuntingan de-identifikasi masuk:**

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

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

## Contoh kebijakan dengan pernyataan topeng de-identifikasi keluar
<a name="sns-message-data-protection-outbound-deidentify-mask-example"></a>

Contoh berikut mencegah pengguna menerima pesan `CreditCardNumber` dengan menyembunyikan data sensitif dari konten pesan.

```
{
  "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": "-"
          }
        }
      }
    }
  ]
}
```

**Contoh hasil topeng de-identifikasi keluar:**

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

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

## Contoh kebijakan dengan pernyataan redact de-identifikasi keluar
<a name="sns-message-data-protection-outbound-deidentify-redact-example"></a>

Contoh berikut mencegah pengguna menerima pesan `CreditCardNumber` dengan menyunting data sensitif dari konten pesan.

```
{
  "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": {}
        }
      }
    }
  ]
}
```

**Contoh hasil penyuntingan de-identifikasi keluar:**

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

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

## Contoh kebijakan dengan pernyataan penolakan masuk
<a name="sns-message-data-protection-inbound-deny-example"></a>

Contoh berikut memblokir pengguna untuk memublikasikan pesan ke topik `CreditCardNumber` dengan konten pesan. Payload yang ditolak dalam respons API memiliki kode status "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": {}
      }
    }
  ]
}
```

## Contoh kebijakan dengan pernyataan penolakan keluar
<a name="sns-message-data-protection-outbound-deny-example"></a>

Contoh berikut memblokir AWS akun agar tidak menerima pesan yang berisi`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": {}
      }
    }
  ]
}
```

**Contoh hasil penolakan keluar, masuk ke 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"
}
```