將服務連結角色用於 CloudWatch 應用程式深入 - Amazon CloudWatch

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

將服務連結角色用於 CloudWatch 應用程式深入

CloudWatch 應用程式深入解析使用 AWS Identity and Access Management (IAM) 服務連結角色。服務連結角色是直接連結至 CloudWatch 應用程式深入解析的唯一 IAM 角色類型。服務連結角色由 Ap CloudWatch plication Insights 預先定義,並包含服務代表您呼叫其他服 AWS 務所需的所有權限。

服務連結角色可讓您輕鬆設定 CloudWatch 應用程式深入解析,因為您不需要手動新增必要的權限。 CloudWatch 應用程式深入解析會定義其服務連結角色的權限,除非另有定義,否則只有 CloudWatch 應用程式深入解析可以擔任其角色。定義的許可包括信任政策和許可政策,並且該許可政策不能連接到任何其他 IAM 實體。

如需關於支援服務連結角色的其他服務的資訊,請參閱可搭配 IAM 運作的AWS 服務,並尋找 Service-Linked Role (服務連結角色) 欄顯示為 Yes (是) 的服務。選擇 Yes (是) 連結,檢視該服務的服務連結角色文件。

CloudWatch 應用程式見解的服務連結角色權限

CloudWatch 應用程式洞察會使用名為AWSServiceRoleForApplicationInsights的服務連結角色。Application Insights 使用此角色執行作業,例如分析客戶的資源群組、建立 CloudFormation 堆疊以在指標上建立警示,以及在 EC2 執行個體上設定 CloudWatch 代理程式。此服務連結角色連接了一個名為 CloudwatchApplicationInsightsServiceLinkedRolePolicy 的 IAM 政策。如需更新此政策,請參閱「AWS 受管政策的 Application Insights 更新」。

角色權限原則可讓 CloudWatch 應用程式深入解析在資源上完成下列動作。

{ "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", "cloudFormation:ListStacks" ], "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", "ssm:GetCommandInvocation" ], "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", "ec2:DescribeVpcs", "ec2:DescribeVpcAttribute", "ec2:DescribeNatGateways" ], "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", "fsx:DescribeVolumes" ], "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*" ] }, { "Effect": "Allow", "Action": [ "elasticfilesystem:DescribeFileSystems" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "route53:GetHostedZone", "route53:GetHealthCheck", "route53:ListHostedZones", "route53:ListHealthChecks", "route53:ListQueryLoggingConfigs" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "route53resolver:ListFirewallRuleGroupAssociations", "route53resolver:GetFirewallRuleGroup", "route53resolver:ListFirewallRuleGroups", "route53resolver:ListResolverEndpoints", "route53resolver:GetResolverQueryLogConfig", "route53resolver:ListResolverQueryLogConfigs", "route53resolver:ListResolverQueryLogConfigAssociations", "route53resolver:GetResolverEndpoint", "route53resolver:GetFirewallRuleGroupAssociation" ], "Resource": [ "*" ] } ] }

您必須設定許可,IAM 實體 (如使用者、群組或角色) 才可建立、編輯或刪除服務連結角色。如需詳細資訊,請參閱《IAM 使用者指南》中的服務連結角色許可

建立 CloudWatch 應用程式深入解析的服務連結角色

您不需要手動建立一個服務連結角色。當您在中建立新的應用程式見解應用程式時 AWS Management Console, CloudWatch 應用程式深入解析會為您建立服務連結角色。

如果您刪除此服務連結角色後,又想再次建立,您可以使用相同程序在帳戶中重新建立角色。當您建立新的應用程式見解應用程式時, CloudWatch 應用程式深入解析會再次為您建立服務連結角色。

編輯 CloudWatch 應用程式深入解析的服務連結角色

CloudWatch 應用程式深入解析不允許您編輯 AWSServiceRoleForApplicationInsights 服務連結角色。因為有各種實體可能會參考服務連結角色,所以您無法在建立角色之後變更角色名稱。然而,您可使用 IAM 來編輯角色描述。如需更多資訊,請參閱 IAM 使用者指南中的編輯服務連結角色

刪除 CloudWatch 應用程式深入解析的服務連結角色

若您不再使用需要服務連結角色的功能或服務,我們建議您刪除該角色。如此一來,就不會有未主動監控或維護的未使用實體。不過,您必須先刪除 Application Insights 中的所有應用程式,才可以手動刪除該角色。

注意

當您嘗試刪除資源時,如果 CloudWatch 應用程式深入解析服務正在使用該角色,則刪除可能會失敗。若此情況發生,請等待數分鐘後並再次嘗試操作。

若要刪除使用的 CloudWatch 應用程式見解資源 AWSServiceRoleForApplicationInsights
  • 刪除所有應用程式見解 CloudWatch 應用程式。如需詳細資訊,請參閱應用程式深入解析使用者指南中的「刪除 CloudWatch 應用程式」。

使用 IAM 手動刪除服務連結角色

使用 IAM 主控台或 AWS API 刪除 AWSServiceRoleForApplicationInsights 服務連結角色。 AWS CLI如需詳細資訊,請參閱《IAM 使用者指南》中的刪除服務連結角色

CloudWatch 應用程式洞察服務連結角色的支援區域

CloudWatch 應用程式深入解析支援在所有提供服務的 AWS 區域中使用服務連結角色。如需詳細資訊,請參閱CloudWatch 應用程式洞察區域和端點