为 Performance Insights 配置访问策略
要访问 Performance Insights,主体必须拥有 Amazon Identity and Access Management (IAM) 的相应权限。您可以通过以下方式授予访问权限:
-
将
AmazonRDSPerformanceInsightsReadOnly
托管式策略附加到权限集或角色。 -
创建自定义 IAM policy 并将其附加到权限集或角色。
如果您在打开 Performance Insights 时指定了客户托管密钥,请确保账户中的用户对 KMS 密钥具有 kms:Decrypt
和 kms:GenerateDataKey
权限。
将 AmazonRDSPerformanceInsightsReadOnly 策略附加到 IAM 主体
AmazonRDSPerformanceInsightsReadOnly
是 Amazon 托管式策略,可以授予对 Amazon RDS Performance Insights API 的所有只读操作的访问权限。目前,此 API 中的所有操作均为只读。
如果将 AmazonRDSPerformanceInsightsReadOnly
附加到权限集或角色,接收人可以使用性能详情以及其他控制台功能。
为 Performance Insights 创建自定义 IAM 策略
对于没有 AmazonRDSPerformanceInsightsReadOnly
策略的用户,您可以通过创建或修改用户托管 IAM 策略来授予对 Performance Insights 的访问权限。当您将策略附加到 IAM 权限集或角色时,接收人可以使用性能详情。
创建自定义策略
通过以下网址打开 IAM 控制台:https://console.aws.amazon.com/iam/
。 -
在导航窗格中,选择 Policies (策略)。
-
选择 Create policy (创建策略)。
-
在创建策略页面上,选择“JSON”选项卡。
-
复制并粘贴以下文本,将
us-east-1
替换为您的 Amazon Web Services 区域的名称,并将111122223333
替换为您的客户账号。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "rds:DescribeDBInstances", "Resource": "*" }, { "Effect": "Allow", "Action": "rds:DescribeDBClusters", "Resource": "*" }, { "Effect": "Allow", "Action": "pi:DescribeDimensionKeys", "Resource": "arn:aws:pi:
us-east-1
:111122223333
:metrics/rds/*" }, { "Effect": "Allow", "Action": "pi:GetDimensionKeyDetails", "Resource": "arn:aws:pi:us-east-1
:111122223333
:metrics/rds/*" }, { "Effect": "Allow", "Action": "pi:GetResourceMetadata", "Resource": "arn:aws:pi:us-east-1
:111122223333
:metrics/rds/*" }, { "Effect": "Allow", "Action": "pi:GetResourceMetrics", "Resource": "arn:aws:pi:us-east-1
:111122223333
:metrics/rds/*" }, { "Effect": "Allow", "Action": "pi:ListAvailableResourceDimensions", "Resource": "arn:aws:pi:us-east-1
:111122223333
:metrics/rds/*" }, { "Effect": "Allow", "Action": "pi:ListAvailableResourceMetrics", "Resource": "arn:aws:pi:us-east-1
:111122223333
:metrics/rds/*" } ] } -
选择Review policy(查看策略)。
-
为策略提供名称并可以选择提供描述,然后选择创建策略。
现在,可以将策略附加到权限集或角色。以下过程假设您已经有一个可用于此目的的用户。
将策略附加到用户
打开 IAM 控制台:https://console.aws.amazon.com/iam/
。 -
在导航窗格中,选择 Users。
-
从列表中选择现有用户。
重要
要使用 Performance Insights,请确保除了自定义策略之外,您还有权访问 Amazon RDS。例如,
AmazonRDSPerformanceInsightsReadOnly
预定义策略提供了对 Amazon RDS 的只读访问权限。有关更多信息,请参阅“使用策略管理访问”。 -
在 Summary (摘要) 页上,选择 Add permissions (添加权限)。
-
选择直接附加现有策略。对于 Search,键入策略名称的前几个字符,如下所示。
-
选择策略,然后选择 Next: Review。
-
选择 Add permissions (添加权限)。
为 Performance Insights 配置 Amazon KMS 策略
Performance Insights 使用 Amazon KMS key 加密敏感数据。通过 API 或控制台启用 Performance Insights 时,您可以执行以下任一操作:
-
选择原定设置 Amazon 托管式密钥。
Amazon RDS 为新的数据库实例使用 Amazon 托管式密钥。Amazon RDS 将为您的 Amazon Web Services 账户创建 Amazon 托管式密钥。您的 Amazon Web Services 账户在每个 Amazon Web Services 区域都有用于 Amazon RDS 的不同 Amazon 托管式密钥。
-
选择客户托管密钥。
如果您指定一个客户托管密钥,则您账户中调用 Performance Insights API 的用户需要在 KMS 密钥具有
kms:Decrypt
和kms:GenerateDataKey
权限。您可以通过 IAM 策略配置这些权限。但是,我们建议您通过 KMS 密钥策略来管理这些权限。有关更多信息,请参阅在 Amazon KMS 中使用密钥策略。
以下示例显示了如何将语句添加到 KMS 密钥策略。这些语句可以访问 Performance Insights。您可能需要更改一些限制,这取决于您使用 KMS 密钥的方式。在将语句添加到您的策略之前,请删除所有注释。
{ "Version" : "2012-10-17", "Id" : "your-policy", "Statement" : [ { //This represents a statement that currently exists in your policy. } ...., //Starting here, add new statement to your policy for Performance Insights. //We recommend that you add one new statement for every RDS instance { "Sid" : "Allow viewing RDS Performance Insights", "Effect": "Allow", "Principal": { "AWS": [ //One or more principals allowed to access Performance Insights "arn:aws:iam::
444455556666
:role/Role1
" ] }, "Action": [ "kms:Decrypt", "kms:GenerateDataKey" ], "Resource": "*", "Condition" : { "StringEquals" : { //Restrict access to only RDS APIs (including Performance Insights). //Replaceregion
with your Amazon Region. //For example, specify us-west-2. "kms:ViaService" : "rds.region
.amazonaws.com" }, "ForAnyValue:StringEquals": { //Restrict access to only data encrypted by Performance Insights. "kms:EncryptionContext:aws:pi:service": "rds", "kms:EncryptionContext:service": "pi", //Restrict access to a specific RDS instance. //The value is a DbiResourceId. "kms:EncryptionContext:aws:rds:db-id": "db-AAAAABBBBBCCCCDDDDDEEEEE
" } } }