如何疑難排解 CloudWatch 中跨帳戶儀表板共用的錯誤?
我想要使用跨帳戶儀表板共用以與另一個 AWS 帳戶共用 Amazon CloudWatch 儀表板。
簡短描述
您可以建立跨帳戶或跨區域儀表板,與多個 AWS 帳戶和多個 AWS 區域共用 CloudWatch 資料。當您使用帳戶或組織 ID 與另一個帳戶共用來自某個 AWS 帳戶的儀表板時,可能會遇到以下幾個問題:
- 監控帳戶使用者無法檢視或選取共用帳戶中的帳戶 ID 以檢視儀表板。
- 存取儀表板時,因為共用帳戶中的權限問題,監控使用者會收到錯誤訊息。這些錯誤訊息包括下列範例:
無法擷取警示錯誤
無法擷取資源群組錯誤
未經授權的使用者錯誤
解決方法
在這些範例中,一個帳戶使用帳戶 ID 或組織 ID 與另一個帳戶共用儀表板。共用帳戶 ID 為 111111111111。監控帳戶 ID 為 999999999999。
查看帳號 ID 以查看監控儀表板時發生的問題
若要檢視和選取共用儀表板,請為監控帳戶中的每個 AWS 身份和存取管理 (IAM) 使用者開啟帳戶選擇器。只有在 CloudWatch 設定中開啟帳戶選擇器的 IAM 使用者才能看到帳戶 ID 選擇器。如需詳細資訊,請參閱在 CloudWatch中啟用跨帳戶功能。
從監控帳戶存取自訂儀表板時收到錯誤
當您嘗試從監控帳戶存取自訂儀表板時,可能會遇到下列錯誤:
-
在 CloudWatch 主控臺中存取概述頁面時:
「無法擷取警示;您沒有執行下列作業的權限: CloudWatch:DescribeAlarms。如果您需要協助,請聯絡您的管理員。如果您是管理員,則可以透過建立 IAM 政策為使用者或群組提供權限。」
-
從共用帳戶存取跨服務儀表板時:
「無法在「依資源群組篩選」下拉式清單中選取任何資源群組。出錯: 「無法擷取資源群組」
-
從共享帳戶打開自訂儀表板時:
「User: "arn:aws:sts::999999999999:assumed-role/AWSServiceRoleForCloudWatchCrossAccount/CloudWatchConsole 未授權執行: sts:AssumeRole on resource: arn:aws:iam::111111111111:role/CloudWatch-CrossAccountSharingRole」
-或-
「User: arn:aws:sts::999999999999:assumed-role/CloudWatch-CrossAccountSharingRole/CloudWatchConsole 未授權執行: cloudwatch:ListDashboards on resource: arn:aws:cloudwatch::111111111111:dashboard/* because no identity-based policy allows the cloudwatch:ListDashboards action」
之所以發生這些錯誤,是因為共用帳戶角色存在權限問題。請確定共用帳戶符合下列條件:
- CloudWatch-CrossAccountSharingRole 已存在。
- 共用帳戶具有正確的信任政策。
- CloudWatch-CrossAccountSharing角色已附加下列政策: CloudWatchReadOnlyAccess CloudWatchAutomaticDashboardsAccess:如果您在儀表板共用期間清除包含 CloudWatch 自動儀表板選項,則會遺失此政策。AWSXrayReadOnlyAccess: 如果您在儀表板共用期間清除包含 ServiceLens 的 X-Ray 只讀存取選項,則會遺失此政策。
限制 CloudWatch-CrossAccountSharingRole 僅與所有監控帳戶共用特定儀表板
若要列出跨帳戶儀表板中的所有儀表板,請使用ListDashboards API 呼叫。ListDashboards 不支援資源特有的權限,但** GetDashboard API 呼叫會支援。因此,若要限制跨帳戶描述或開啟的儀表板,請在來源共用帳戶中編輯 IAM 角色 CloudWatch-CrossAccountSharingRole**:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": "cloudwatch:GetDashboard", "Resource": "arn:aws:cloudwatch::111111111111:dashboard/dashboard-name" }, { "Sid": "VisualEditor1", "Effect": "Allow", "Action": [ "autoscaling:Describe*", "cloudwatch:Describe*", "cloudwatch:GetMetricData", "cloudwatch:GetMetricStatistics", "cloudwatch:GetInsightRuleReport", "cloudwatch:GetMetricWidgetImage", "cloudwatch:ListMetrics", "cloudwatch:ListTagsForResource", "cloudwatch:ListDashboards", "logs:Get*", "logs:List*", "logs:StartQuery", "logs:StopQuery", "logs:Describe*", "logs:TestMetricFilter", "logs:FilterLogEvents", "sns:Get*", "sns:List*" ], "Resource": "*" } ] }
執行此命令後,您可以列出所有儀表板。不過,如果您嘗試開啟此政策中未提及的儀表板,您會看到錯誤訊息:
User: arn:aws:sts::111111111111:assumed-role/CloudWatch-CrossAccountSharingRole/CloudWatchConsole is not authorized to perform: cloudwatch:GetDashboard on resource: arn:aws:cloudwatch::111111111111:dashboard/test
啟動 CloudFormationStack 以在共用帳戶建立所需要的 CloudWatch-CrossAccountSharingRole 時發生的問題
使用跨帳戶儀表板共用時,請確定您的這些政策與共用帳戶中的 IAM 角色相關聯:
- AWSCloudFormationFullAccess
- IAMFullAccess
這些權限可讓您啟動所需的 CloudFormationStack API,以建立跨帳戶儀表板共用所需的 IAM 角色。
使用 Terraform/CloudFormation/AWS CLI 建立跨帳戶儀表板共用設定
當您設定共用帳戶以使用跨帳戶功能時,CloudWatch 會部署 AWS CloudFormation 範本。將此 CloudFormation 範本轉換為對應的 Terraform 範本。這使您可以激活跨帳戶資料共享。
若要允許您的監控帳戶在 CloudWatch 中檢視跨帳戶資料,請使用主控臺啟用帳戶選擇器。這是個別使用者的設定,不會在帳戶層級管理。如需有關設定的詳細資訊,請參閱在 CloudWatch ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Cross-Account-Cross-Region.html#enable-cross-account-cross-Region)中[啟用跨帳戶功能。
相關資訊

相關內容
- 已提問 2 個月前lg...
- 已提問 4 個月前lg...
- 已提問 3 個月前lg...
- AWS 官方已更新 5 個月前
- AWS 官方已更新 6 個月前
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前