在 CloudWatch Application Insights 中使用服务相关角色 - Amazon CloudWatch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

在 CloudWatch Application Insights 中使用服务相关角色

CloudWatch Application Insights 使用 Amazon Identity and Access Management (IAM) 服务相关角色。服务相关角色是一种独特类型的 IAM 角色,它与 CloudWatch Application Insights 直接相关。服务相关角色由 CloudWatch Application Insights 预定义,并包含该服务代表您调用其他 Amazon 服务所需的一切权限。

服务相关角色更方便设置 CloudWatch Application Insights,因为无需手动添加必要权限。CloudWatch Application Insights 定义其服务相关角色的权限,除非另外定义,否则只有 CloudWatch Application Insights 可以代入其角色。定义的权限包括信任策略和权限策略,以及不能附加到任何其它 IAM 实体的权限策略。

有关支持服务链接角色的其他服务的信息,请参阅使用 IAM 的 Amazon 服务,并在服务链接角色列中查找 Yes(是)的服务。选择链接,查看该服务的服务相关角色文档。

CloudWatch Application Insights 的服务相关角色权限

CloudWatch Application Insights 使用名为 AWSServiceRoleForApplicationInsights 的服务相关角色。Application Insights 使用此角色执行操作,例如分析客户的资源组、创建 CloudFormation 堆栈以创建有关指标的告警,以及在 EC2 实例上配置 CloudWatch 代理。此服务相关角色附加到以下托管策略上:CloudwatchApplicationInsightsServiceLinkedRolePolicy。有关此策略的更新,请参阅 对 Amazon 托管式策略的 Application Insights 更新

角色权限策略允许 CloudWatch Application Insights 对资源完成以下操作。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cloudwatch:DescribeAlarmHistory", "cloudwatch:DescribeAlarms", "cloudwatch:GetMetricData", "cloudwatch:ListMetrics", "cloudwatch:PutMetricAlarm", "cloudwatch:DeleteAlarms", "cloudwatch:PutAnomalyDetector", "cloudwatch:DeleteAnomalyDetector", "cloudwatch:DescribeAnomalyDetectors" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "logs:FilterLogEvents", "logs:GetLogEvents", "logs:DescribeLogStreams", "logs:DescribeLogGroups" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "events:DescribeRule" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "cloudFormation:CreateStack", "cloudFormation:UpdateStack", "cloudFormation:DeleteStack", "cloudFormation:DescribeStackResources" ], "Resource": [ "arn:aws:cloudformation:*:*:stack/ApplicationInsights-*" ] }, { "Effect": "Allow", "Action": [ "cloudFormation:DescribeStacks", "cloudFormation:ListStackResources" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "tag:GetResources" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "resource-groups:ListGroupResources", "resource-groups:GetGroupQuery", "resource-groups:GetGroup" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "resource-groups:CreateGroup", "resource-groups:DeleteGroup" ], "Resource": [ "arn:aws:resource-groups:*:*:group/ApplicationInsights-*" ] }, { "Effect": "Allow", "Action": [ "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:DescribeTargetHealth" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "autoscaling:DescribeAutoScalingGroups" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "ssm:PutParameter", "ssm:DeleteParameter", "ssm:AddTagsToResource", "ssm:RemoveTagsFromResource", "ssm:GetParameters" ], "Resource": "arn:aws:ssm:*:*:parameter/AmazonCloudWatch-ApplicationInsights-*" }, { "Effect": "Allow", "Action": [ "ssm:CreateAssociation", "ssm:UpdateAssociation", "ssm:DeleteAssociation", "ssm:DescribeAssociation" ], "Resource": [ "arn:aws:ec2:*:*:instance/*", "arn:aws:ssm:*:*:association/*", "arn:aws:ssm:*:*:managed-instance/*", "arn:aws:ssm:*:*:document/AWSEC2-ApplicationInsightsCloudwatchAgentInstallAndConfigure", "arn:aws:ssm:*:*:document/AWS-ConfigureAWSPackage", "arn:aws:ssm:*:*:document/AmazonCloudWatch-ManageAgent" ] }, { "Effect": "Allow", "Action": [ "ssm:GetOpsItem", "ssm:CreateOpsItem", "ssm:DescribeOpsItems", "ssm:UpdateOpsItem", "ssm:DescribeInstanceInformation" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "ssm:AddTagsToResource" ], "Resource": "arn:aws:ssm:*:*:opsitem/*" }, { "Effect": "Allow", "Action": [ "ssm:ListCommandInvocations" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": "ssm:SendCommand", "Resource": [ "arn:aws:ec2:*:*:instance/*", "arn:aws:ssm:*:*:document/AWSEC2-CheckPerformanceCounterSets", "arn:aws:ssm:*:*:document/AWS-ConfigureAWSPackage", "arn:aws:ssm:*:*:document/AWSEC2-DetectWorkload", "arn:aws:ssm:*:*:document/AmazonCloudWatch-ManageAgent" ] }, { "Effect": "Allow", "Action": [ "ec2:DescribeInstances", "ec2:DescribeVolumes", "ec2:DescribeVolumeStatus" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "rds:DescribeDBInstances", "rds:DescribeDBClusters" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "lambda:ListFunctions", "lambda:GetFunctionConfiguration", "lambda:ListEventSourceMappings" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "events:PutRule", "events:PutTargets", "events:RemoveTargets", "events:DeleteRule" ], "Resource": [ "arn:aws:events:*:*:rule/AmazonCloudWatch-ApplicationInsights-*" ] }, { "Effect": "Allow", "Action": [ "xray:GetServiceGraph", "xray:GetTraceSummaries", "xray:GetTimeSeriesServiceStatistics", "xray:GetTraceGraph" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "dynamodb:ListTables", "dynamodb:DescribeTable", "dynamodb:DescribeContributorInsights", "dynamodb:DescribeTimeToLive" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "application-autoscaling:DescribeScalableTargets" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "s3:ListAllMyBuckets", "s3:GetMetricsConfiguration", "s3:GetReplicationConfiguration" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "states:ListStateMachines", "states:DescribeExecution", "states:DescribeStateMachine", "states:GetExecutionHistory" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "apigateway:GET" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "ecs:DescribeClusters", "ecs:DescribeContainerInstances", "ecs:DescribeServices", "ecs:DescribeTaskDefinition", "ecs:DescribeTasks", "ecs:DescribeTaskSets", "ecs:ListClusters", "ecs:ListContainerInstances", "ecs:ListServices", "ecs:ListTasks" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "ecs:UpdateClusterSettings" ], "Resource": [ "arn:aws:ecs:*:*:cluster/*" ] }, { "Effect": "Allow", "Action": [ "eks:DescribeCluster", "eks:DescribeFargateProfile", "eks:DescribeNodegroup", "eks:ListClusters", "eks:ListFargateProfiles", "eks:ListNodegroups", "fsx:DescribeFileSystems" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "sns:GetSubscriptionAttributes", "sns:GetTopicAttributes", "sns:GetSMSAttributes", "sns:ListSubscriptionsByTopic", "sns:ListTopics" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "sqs:ListQueues" ], "Resource": "*" } { "Effect": "Allow", "Action": [ "logs:DeleteSubscriptionFilter" ], "Resource": [ "arn:aws:logs:*:*:log-group:*" ] }, { "Effect": "Allow", "Action": [ "logs:PutSubscriptionFilter" ], "Resource": [ "arn:aws:logs:*:*:log-group:*", "arn:aws:logs:*:*:destination:AmazonCloudWatch-ApplicationInsights-LogIngestionDestination*" ] } ] }

必须配置权限,允许 IAM 实体(如用户、组或角色)创建、编辑或删除服务相关角色。有关更多信息,请参阅 IAM 用户指南中的服务相关角色权限

为 CloudWatch Application Insights 创建服务相关角色

无需手动创建服务相关角色。当您在 Amazon Web Services Management Console 中创建新的 Application Insights 应用程序时,CloudWatch Application Insights 将为您创建服务相关角色。

如果删除该服务相关角色,然后希望再次创建该角色,您可以使用相同的过程在您的账户中重新创建该角色。当您创建新的 Application Insights 应用程序时,CloudWatch Application Insights 将为您再次创建服务相关角色。

为 CloudWatch Application Insights 编辑服务相关角色

CloudWatch Application Insights 不允许您编辑 AWSServiceRoleForApplicationInsights 服务相关角色。创建服务相关角色后,将无法更改角色名称,因为可能有多个实体引用该角色。但是可以使用 IAM 编辑角色说明。有关更多信息,请参见《IAM 用户指南》中的编辑服务相关角色

为 CloudWatch Application Insights 删除服务相关角色

如果您不再需要使用某个需要服务相关角色的功能或服务,我们建议您删除该角色。这样,您就可以避免使用当前未监控或维护的未使用实体。不过,您必须先删除 Application Insights 中的所有应用程序,然后才能手动删除该角色。

注意

在尝试删除资源时,如果 CloudWatch Application Insights 服务正在使用该角色,删除可能会失败。如果发生这种情况,请等待几分钟后重试。

若要删除 AWSServiceRoleForApplicationInsights 使用的 CloudWatch Application Insights 资源

  • 删除所有 CloudWatch Application Insights 应用程序。有关更多信息,请参阅《CloudWatch Application Insights 用户指南》中的“删除应用程序”。

使用 IAM 手动删除服务相关角色

使用 IAM 控制台、Amazon CLI 或 Amazon API 删除 AWSServiceRoleForApplicationInsights 服务相关角色。有关更多信息,请参见 IAM 用户指南中的删除服务相关角色

CloudWatch Application Insights 服务相关角色支持的区域

CloudWatch Application Insights 支持在服务可用的所有 Amazon 区域中使用服务相关角色。有关更多信息,请参阅 CloudWatch Application Insights 区域和端点