将 IAM 与 CloudWatch Contributor Insights for DynamoDB 结合使用
首次启用 Amazon CloudWatch Contributor Insights for Amazon DynamoDB 时,DynamoDB 将自动创建一个 Amazon Identity and Access Management (IAM) 服务相关角色。该角色 AWSServiceRoleForDynamoDBCloudWatchContributorInsights
允许 DynamoDB 代表您管理 CloudWatch Contributor Insights 规则。不要删除该服务相关角色。如果删除,则删除表或全局二级索引时,将不再清理所有托管规则。
有关服务相关角色的更多信息,请参见 IAM 用户指南中的使用服务相关角色。
需要以下权限:
-
要启用或禁用 CloudWatch Contributor Insights for DynamoDB,必须具备表或索引的
dynamodb:UpdateContributorInsights
权限。 -
要查看 CloudWatch Contributor Insights for DynamoDB 图表,必须具备
cloudwatch:GetInsightRuleReport
权限。 -
要为给定 DynamoDB 表或索引描述 CloudWatch Contributor Insights for DynamoDB,必须具备
dynamodb:DescribeContributorInsights
权限。 -
要列出每个表和全局二级索引的 CloudWatch Contributor Insights for DynamoDB 状态,必须具备
dynamodb:ListContributorInsights
权限。
示例:启用或禁用 CloudWatch Contributor Insights for DynamoDB
下面的 IAM 策略授予启用或禁用 CloudWatch Contributor Insights for DynamoDB 的权限。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "arn:aws:iam::*:role/aws-service-role/contributorinsights.dynamodb.amazonaws.com/AWSServiceRoleForDynamoDBCloudWatchContributorInsights", "Condition": {"StringLike": {"iam:AWSServiceName": "contributorinsights.dynamodb.amazonaws.com"}} }, { "Effect": "Allow", "Action": [ "dynamodb:UpdateContributorInsights" ], "Resource": "arn:aws:dynamodb:*:*:table/*" } ] }
对于由 KMS 密钥加密的表,用户需要拥有 kms:Decrypt 权限才能更新 Contributor Insights。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "arn:aws:iam::*:role/aws-service-role/contributorinsights.dynamodb.amazonaws.com/AWSServiceRoleForDynamoDBCloudWatchContributorInsights", "Condition": {"StringLike": {"iam:AWSServiceName": "contributorinsights.dynamodb.amazonaws.com"}} }, { "Effect": "Allow", "Action": [ "dynamodb:UpdateContributorInsights" ], "Resource": "arn:aws:dynamodb:*:*:table/*" }, { "Effect": "Allow", "Resource": "arn:aws:kms:*:*:key/*", "Action": [ "kms:Decrypt" ], } ] }
示例:检索 CloudWatch Contributor Insights 规则报告
下面的 IAM 策略授予检索 CloudWatch Contributor Insights 规则报告的权限。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cloudwatch:GetInsightRuleReport" ], "Resource": "arn:aws:cloudwatch:*:*:insight-rule/DynamoDBContributorInsights*" } ] }
示例:根据资源有选择地应用 CloudWatch Contributor Insights for DynamoDB 权限。
下面的 IAM 策略授予权限,允许 ListContributorInsights
和 DescribeContributorInsights
操作,拒绝针对特定全局二级索引的 UpdateContributorInsights
操作。
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "dynamodb:ListContributorInsights", "dynamodb:DescribeContributorInsights" ], "Resource": "*" }, { "Effect": "Deny", "Action": [ "dynamodb:UpdateContributorInsights" ], "Resource": "arn:aws:dynamodb:us-west-2:123456789012:table/Books/index/Author-index" } ] }
使用 CloudWatch Contributor Insights for DynamoDB 的服务相关角色
CloudWatch Contributor Insights for DynamoDB 使用 Amazon Identity and Access Management (IAM) 服务相关角色。服务相关角色是一种独特 IAM 角色,与 CloudWatch Contributor Insights for DynamoDB 直接相关。服务相关角色由 CloudWatch Contributor Insights for DynamoDB 预定义,包含该服务代表您调用其他 Amazon 服务所需的所有权限。
服务相关角色更方便设置 CloudWatch Contributor Insights for DynamoDB,因为无需手动添加必要权限。CloudWatch Contributor Insights for DynamoDB 定义服务相关角色的权限,除非另有定义,否则只有 CloudWatch Contributor Insights for DynamoDB 可以代入该角色。定义的权限包括信任策略和权限策略,而且权限策略不能附加到任何其它 IAM 实体。
有关支持服务相关角色的其它服务的信息,请参阅使用 IAM 的 Amazon 服务并查找服务相关角色列中显示为是的服务。选择是和链接,查看该服务的服务相关角色文档。
CloudWatch Contributor Insights for DynamoDB 的服务相关角色权限
CloudWatch Contributor Insights for DynamoDB 使用名为 AWSServiceRoleForDynamoDBCloudWatchContributorInsights 的服务相关角色。服务相关角色允许 Amazon DynamoDB 代表您管理为 DynamoDB 表和全局二级索引创建的 Amazon CloudWatch Contributor Insights 规则。
AWSServiceRoleForDynamoDBCloudWatchContributorInsights
服务相关角色信任以下服务代入该角色:
-
contributorinsights.dynamodb.amazonaws.com
角色权限策略允许 CloudWatch Contributor Insights for DynamoDB 对指定资源完成以下操作:
-
操作:
DynamoDBContributorInsights
上的Create and manage Insight Rules
必须配置权限,允许 IAM 实体(如用户、组或角色)创建、编辑或删除服务相关角色。有关更多信息,请参见 IAM 用户指南中的服务相关角色权限。
创建 CloudWatch Contributor Insights for DynamoDB 的服务相关角色
无需手动创建服务相关角色。在 Amazon Web Services Management Console、Amazon CLI 或 Amazon API 中启用 Contributor Insights 后,CloudWatch Contributor Insights for DynamoDB 自动创建服务相关角色。
如果删除此服务相关角色,然后需要再次创建,可以使用相同流程在账户中重新创建此角色。启用 Contributor Insights 后,CloudWatch Contributor Insights for DynamoDB 再次创建服务相关角色。
编辑 CloudWatch Contributor Insights for DynamoDB 的服务相关角色
CloudWatch Contributor Insights for DynamoDB 不允许编辑 AWSServiceRoleForDynamoDBCloudWatchContributorInsights
服务相关角色。创建服务相关角色后,将无法更改角色名称,因为可能有多个实体引用该角色。但是可以使用 IAM 编辑角色描述。有关更多信息,请参阅《IAM 用户指南》中的编辑服务相关角色。
删除 CloudWatch Contributor Insights for DynamoDB 的服务相关角色
无需手动删除 AWSServiceRoleForDynamoDBCloudWatchContributorInsights
角色。在 Amazon Web Services Management Console、Amazon CLI 或 Amazon API 中禁用 Contributor Insights 后,CloudWatch Contributor Insights for DynamoDB 清理资源。
还可以使用 IAM 控制台、Amazon CLI 或 Amazon API 手动删除服务相关角色。为此,必须先手动清除服务相关角色的资源,然后才能手动删除。
注意
如果尝试删除资源时 CloudWatch Contributor Insights for DynamoDB 服务正在使用该角色,则删除操作可能失败。如果发生这种情况,请等待几分钟后重试。
使用 IAM 手动删除服务相关角色
使用 IAM 控制台,即 Amazon CLI 或 Amazon API 来删除 AWSServiceRoleForDynamoDBCloudWatchContributorInsights
服务相关角色。有关更多信息,请参阅《IAM 用户指南》中的删除服务相关角色。