針對 CloudWatch Application Insights 使用服務連結角色 - Amazon CloudWatch

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

針對 CloudWatch Application Insights 使用服務連結角色

CloudWatch Application Insights 使用 AWS Identity and Access Management (IAM) 服務連結角色。服務連結角色是一種獨特的 IAM 角色,可直接連結至 CloudWatch Application Insights。服務連結角色是由 CloudWatch Application Insights 預先定義,並包含該服務代表您呼叫其他 AWS 服務所需的所有許可。

服務連結角色可讓設定 CloudWatch Application Insights 更為簡單,因為您不必手動新增必要的許可。CloudWatch Application Insights 定義其服務連結角色的許可,除非另有定義,否則只有 CloudWatch Application Insights 可以擔任這些角色。定義的許可包括信任政策和許可政策,並且該許可政策不能連接到任何其他 IAM 實體。

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

CloudWatch Application Insights 的服務連結角色許可

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

此角色許可政策允許 CloudWatch Application Insights 對資源完成下列動作。

JSON
{ "Version": "2012-10-17", "Statement": [ { "Sid": "CloudWatch", "Effect": "Allow", "Action": [ "cloudwatch:DescribeAlarmHistory", "cloudwatch:DescribeAlarms", "cloudwatch:GetMetricData", "cloudwatch:ListMetrics", "cloudwatch:PutMetricAlarm", "cloudwatch:DeleteAlarms", "cloudwatch:PutAnomalyDetector", "cloudwatch:DeleteAnomalyDetector", "cloudwatch:DescribeAnomalyDetectors" ], "Resource": [ "*" ] }, { "Sid": "CloudWatchLogs", "Effect": "Allow", "Action": [ "logs:FilterLogEvents", "logs:GetLogEvents", "logs:DescribeLogStreams", "logs:DescribeLogGroups" ], "Resource": [ "*" ] }, { "Sid": "EventBridge", "Effect": "Allow", "Action": [ "events:DescribeRule" ], "Resource": [ "*" ] }, { "Sid": "CloudFormation", "Effect": "Allow", "Action": [ "cloudFormation:CreateStack", "cloudFormation:UpdateStack", "cloudFormation:DeleteStack", "cloudFormation:DescribeStackResources", "cloudFormation:UpdateTerminationProtection" ], "Resource": [ "arn:aws:cloudformation:*:*:stack/ApplicationInsights-*" ] }, { "Sid": "CloudFormationStacks", "Effect": "Allow", "Action": [ "cloudFormation:DescribeStacks", "cloudFormation:ListStackResources", "cloudFormation:ListStacks" ], "Resource": [ "*" ] }, { "Sid": "Tag", "Effect": "Allow", "Action": [ "tag:GetResources" ], "Resource": [ "*" ] }, { "Sid": "ResourceGroups", "Effect": "Allow", "Action": [ "resource-groups:ListGroupResources", "resource-groups:GetGroupQuery", "resource-groups:GetGroup" ], "Resource": [ "*" ] }, { "Sid": "ApplicationInsightsResourceGroup", "Effect": "Allow", "Action": [ "resource-groups:CreateGroup", "resource-groups:DeleteGroup" ], "Resource": [ "arn:aws:resource-groups:*:*:group/ApplicationInsights-*" ] }, { "Sid": "ElasticLoadBalancing", "Effect": "Allow", "Action": [ "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:DescribeTargetHealth" ], "Resource": [ "*" ] }, { "Sid": "AutoScaling", "Effect": "Allow", "Action": [ "autoscaling:DescribeAutoScalingGroups" ], "Resource": [ "*" ] }, { "Sid": "SSMParameter", "Effect": "Allow", "Action": [ "ssm:PutParameter", "ssm:DeleteParameter", "ssm:AddTagsToResource", "ssm:RemoveTagsFromResource", "ssm:GetParameters" ], "Resource": "arn:aws:ssm:*:*:parameter/AmazonCloudWatch-ApplicationInsights-*" }, { "Sid": "SSMAssociation", "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" ] }, { "Sid": "SSMOpsItem", "Effect": "Allow", "Action": [ "ssm:GetOpsItem", "ssm:CreateOpsItem", "ssm:DescribeOpsItems", "ssm:UpdateOpsItem", "ssm:DescribeInstanceInformation" ], "Resource": [ "*" ] }, { "Sid": "SSMTags", "Effect": "Allow", "Action": [ "ssm:AddTagsToResource" ], "Resource": "arn:aws:ssm:*:*:opsitem/*" }, { "Sid": "SSMGetCommandInvocation", "Effect": "Allow", "Action": [ "ssm:ListCommandInvocations", "ssm:GetCommandInvocation" ], "Resource": [ "*" ] }, { "Sid": "SSMSendCommand", "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" ] }, { "Sid": "EC2", "Effect": "Allow", "Action": [ "ec2:DescribeInstances", "ec2:DescribeVolumes", "ec2:DescribeVolumeStatus", "ec2:DescribeVpcs", "ec2:DescribeVpcAttribute", "ec2:DescribeNatGateways" ], "Resource": [ "*" ] }, { "Sid": "RDS", "Effect": "Allow", "Action": [ "rds:DescribeDBInstances", "rds:DescribeDBClusters" ], "Resource": [ "*" ] }, { "Sid": "Lambda", "Effect": "Allow", "Action": [ "lambda:ListFunctions", "lambda:GetFunctionConfiguration", "lambda:ListEventSourceMappings" ], "Resource": [ "*" ] }, { "Sid": "EventBridgeManagedRule", "Effect": "Allow", "Action": [ "events:PutRule", "events:PutTargets", "events:RemoveTargets", "events:DeleteRule" ], "Resource": [ "arn:aws:events:*:*:rule/AmazonCloudWatch-ApplicationInsights-*" ] }, { "Sid": "XRay", "Effect": "Allow", "Action": [ "xray:GetServiceGraph", "xray:GetTraceSummaries", "xray:GetTimeSeriesServiceStatistics", "xray:GetTraceGraph" ], "Resource": [ "*" ] }, { "Sid": "DynamoDB", "Effect": "Allow", "Action": [ "dynamodb:ListTables", "dynamodb:DescribeTable", "dynamodb:DescribeContributorInsights", "dynamodb:DescribeTimeToLive" ], "Resource": [ "*" ] }, { "Sid": "ApplicationAutoscaling", "Effect": "Allow", "Action": [ "application-autoscaling:DescribeScalableTargets" ], "Resource": [ "*" ] }, { "Sid": "S3", "Effect": "Allow", "Action": [ "s3:ListAllMyBuckets", "s3:GetMetricsConfiguration", "s3:GetReplicationConfiguration" ], "Resource": [ "*" ] }, { "Sid": "States", "Effect": "Allow", "Action": [ "states:ListStateMachines", "states:DescribeExecution", "states:DescribeStateMachine", "states:GetExecutionHistory" ], "Resource": [ "*" ] }, { "Sid": "APIGateway", "Effect": "Allow", "Action": [ "apigateway:GET" ], "Resource": [ "*" ] }, { "Sid": "ECS", "Effect": "Allow", "Action": [ "ecs:DescribeClusters", "ecs:DescribeContainerInstances", "ecs:DescribeServices", "ecs:DescribeTaskDefinition", "ecs:DescribeTasks", "ecs:DescribeTaskSets", "ecs:ListClusters", "ecs:ListContainerInstances", "ecs:ListServices", "ecs:ListTasks" ], "Resource": [ "*" ] }, { "Sid": "ECSCluster", "Effect": "Allow", "Action": [ "ecs:UpdateClusterSettings" ], "Resource": [ "arn:aws:ecs:*:*:cluster/*" ] }, { "Sid": "EKS", "Effect": "Allow", "Action": [ "eks:DescribeCluster", "eks:DescribeFargateProfile", "eks:DescribeNodegroup", "eks:ListClusters", "eks:ListFargateProfiles", "eks:ListNodegroups", "fsx:DescribeFileSystems", "fsx:DescribeVolumes" ], "Resource": [ "*" ] }, { "Sid": "SNS", "Effect": "Allow", "Action": [ "sns:GetSubscriptionAttributes", "sns:GetTopicAttributes", "sns:GetSMSAttributes", "sns:ListSubscriptionsByTopic", "sns:ListTopics" ], "Resource": [ "*" ] }, { "Sid": "SQS", "Effect": "Allow", "Action": [ "sqs:ListQueues" ], "Resource": "*" }, { "Sid": "CloudWatchLogsDeleteSubscriptionFilter", "Effect": "Allow", "Action": [ "logs:DeleteSubscriptionFilter" ], "Resource": [ "arn:aws:logs:*:*:log-group:*" ] }, { "Sid": "CloudWatchLogsCreateSubscriptionFilter", "Effect": "Allow", "Action": [ "logs:PutSubscriptionFilter" ], "Resource": [ "arn:aws:logs:*:*:log-group:*", "arn:aws:logs:*:*:destination:AmazonCloudWatch-ApplicationInsights-LogIngestionDestination*" ] }, { "Sid": "EFS", "Effect": "Allow", "Action": [ "elasticfilesystem:DescribeFileSystems" ], "Resource": [ "*" ] }, { "Sid": "Route53", "Effect": "Allow", "Action": [ "route53:GetHostedZone", "route53:GetHealthCheck", "route53:ListHostedZones", "route53:ListHealthChecks", "route53:ListQueryLoggingConfigs" ], "Resource": [ "*" ] }, { "Sid": "Route53Resolver", "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 Application Insights 建立服務連結角色

您不需要手動建立一個服務連結角色。當您在 中建立新的 Application Insights 應用程式時 AWS Management Console,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 主控台 AWS CLI、 或 AWS API 來刪除 AWSServiceRoleForApplicationInsights 服務連結角色。如需詳細資訊,請參閱《IAM 使用者指南》中的刪除服務連結角色

CloudWatch Application Insights 服務連結角色支援的區域

CloudWatch Application Insights 支援在提供服務的所有 AWS 區域中使用服務連結角色。如需詳細資訊,請參閱 CloudWatch Application Insights 區域和端點