

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 基于资源的策略示例 AWS Audit Manager
<a name="security_iam_resource-based-policy-examples"></a>

## Amazon S3 存储桶策略
<a name="s3-resource-policy"></a>

以下策略允许 CloudTrail 将证据查找器查询结果传送到指定的 S3 存储桶。作为安全最佳实践，IAM 全局条件密钥`aws:SourceArn`有助于确保仅针对事件数据存储 CloudTrail 写入 S3 存储桶。

**重要**  
您必须为 La CloudTrail ke 查询结果的交付指定 S3 存储桶。有关更多信息，请参阅[为 CloudTrail Lake 查询结果指定现有存储桶](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/s3-bucket-policy-lake-query-results.html#specify-an-existing-bucket-for-cloudtrail-query-results-delivery)。

*placeholder text*用您自己的信息替换，如下所示：
+ *amzn-s3-demo-destination-bucket*替换为您用作导出目标的 S3 存储桶。
+ *myQueryRunningRegion*替换 AWS 区域 为适合您的配置的。
+ *myAccountID*替换为所用的 AWS 账户 ID CloudTrail。这可能与 S3 存储桶的 AWS 账户 ID 不同。如果这是组织事件数据存储，则您必须使用管理账户的 AWS 账户 。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "cloudtrail.amazonaws.com"
            },
            "Action": [
                "s3:PutObject*",
                "s3:Abort*"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-destination-bucket",
                "arn:aws:s3:::amzn-s3-demo-destination-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:SourceArn": "arn:aws:cloudtrail:myQueryRunningRegion:myAccountID:eventdatastore/*"
                }
            }
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "cloudtrail.amazonaws.com"
            },
            "Action": "s3:GetBucketAcl",
            "Resource": "arn:aws:s3:::amzn-s3-demo-destination-bucket",
            "Condition": {
                "StringEquals": {
                    "aws:SourceArn": "arn:aws:cloudtrail:myQueryRunningRegion:myAccountID:eventdatastore/*"
                }
            }
        }
    ]
    }
```

------

## AWS Key Management Service 政策
<a name="kms-resource-policy"></a>

如果您的 S3 存储桶的默认加密设置为`SSE-KMS`，请在 AWS Key Management Service 密钥的资源策略 CloudTrail 中授予访问权限，以便它可以使用该密钥。在这种情况下，请将以下资源策略添加到 AWS KMS 密钥中。

------
#### [ JSON ]

****  

```
{
 "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "cloudtrail.amazonaws.com"
            },
            "Action": [
                "kms:Decrypt*",
                "kms:GenerateDataKey*"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "s3.amazonaws.com"
            },
            "Action": [
                "kms:Decrypt*",
                "kms:GenerateDataKey*"
            ],
            "Resource": "*"
        }
    ]
}
```

------