ARC 中區域切換的身分型政策範例 - Amazon Application Recovery Controller (ARC)

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

ARC 中區域切換的身分型政策範例

根據預設,使用者和角色沒有建立或修改 ARC 資源的許可。他們也無法使用 AWS Management Console、 AWS Command Line Interface (AWS CLI) 或 AWS API 來執行任務。若要授予使用者對其所需資源執行動作的許可,IAM 管理員可以建立 IAM 政策。然後,管理員可以將 IAM 政策新增至角色,使用者便能擔任這些角色。

如需了解如何使用這些範例 JSON 政策文件建立 IAM 身分型政策,請參閱《IAM 使用者指南》中的建立 IAM 政策 (主控台)

如需有關 ARC 定義的動作和資源類型的詳細資訊,包括每種資源類型的 ARNs 格式,請參閱《服務授權參考》中的 Amazon Application Recovery Controller (ARC) 的動作、資源和條件索引鍵

政策最佳實務

身分型政策會判斷您帳戶中的某個人員是否可以建立、存取或刪除 ARC 資源。這些動作可能會讓您的 AWS 帳戶產生費用。當您建立或編輯身分型政策時,請遵循下列準則及建議事項:

  • 開始使用 AWS 受管政策並轉向最低權限許可 – 若要開始將許可授予您的使用者和工作負載,請使用將許可授予許多常見使用案例的 AWS 受管政策。它們可在您的 中使用 AWS 帳戶。我們建議您定義特定於使用案例 AWS 的客戶受管政策,以進一步減少許可。如需更多資訊,請參閱 IAM 使用者指南中的 AWS 受管政策任務職能的AWS 受管政策

  • 套用最低權限許可 – 設定 IAM 政策的許可時,請僅授予執行任務所需的許可。為實現此目的,您可以定義在特定條件下可以對特定資源採取的動作,這也稱為最低權限許可。如需使用 IAM 套用許可的更多相關資訊,請參閱 IAM 使用者指南中的 IAM 中的政策和許可

  • 使用 IAM 政策中的條件進一步限制存取權 – 您可以將條件新增至政策,以限制動作和資源的存取。例如,您可以撰寫政策條件,指定必須使用 SSL 傳送所有請求。如果透過特定 例如 使用服務動作 AWS 服務,您也可以使用條件來授予其存取權 AWS CloudFormation。如需詳細資訊,請參閱 IAM 使用者指南中的 IAM JSON 政策元素:條件

  • 使用 IAM Access Analyzer 驗證 IAM 政策,確保許可安全且可正常運作 – IAM Access Analyzer 驗證新政策和現有政策,確保這些政策遵從 IAM 政策語言 (JSON) 和 IAM 最佳實務。IAM Access Analyzer 提供 100 多項政策檢查及切實可行的建議,可協助您撰寫安全且實用的政策。如需詳細資訊,請參閱《IAM 使用者指南》中的使用 IAM Access Analyzer 驗證政策

  • 需要多重要素驗證 (MFA) – 如果您的案例需要 IAM 使用者或 中的根使用者 AWS 帳戶,請開啟 MFA 以提高安全性。如需在呼叫 API 操作時請求 MFA,請將 MFA 條件新增至您的政策。如需詳細資訊,請參閱《IAM 使用者指南》https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html中的透過 MFA 的安全 API 存取

如需 IAM 中最佳實務的相關資訊,請參閱 IAM 使用者指南中的 IAM 安全最佳實務

規劃執行角色信任政策

這是計劃執行角色所需的信任政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "arc-region-switch.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

完整存取許可

下列 IAM 政策會授予所有區域交換器 APIs的完整存取權:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:PassRole", "Resource": "*", "Condition": { "StringEquals": { "iam:PassedToService": "arc-region-switch.amazonaws.com" } } }, { "Effect": "Allow", "Action": [ "arc-region-switch:CreatePlan", "arc-region-switch:UpdatePlan", "arc-region-switch:GetPlan", "arc-region-switch:ListPlans", "arc-region-switch:DeletePlan", "arc-region-switch:GetPlanInRegion", "arc-region-switch:ListPlansInRegion", "arc-region-switch:ApprovePlanExecutionStep", "arc-region-switch:GetPlanEvaluationStatus", "arc-region-switch:GetPlanExecution", "arc-region-switch:CancelPlanExecution", "arc-region-switch:ListRoute53HealthChecks", "arc-region-switch:ListPlanExecutions", "arc-region-switch:ListPlanExecutionEvents", "arc-region-switch:ListTagsForResource", "arc-region-switch:TagResource", "arc-region-switch:UntagResource", "arc-region-switch:UpdatePlanExecution", "arc-region-switch:UpdatePlanExecutionStep" ], "Resource": "*" } ] }

唯讀許可

下列 IAM 政策會授予區域切換的唯讀存取許可:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "arc-region-switch:GetPlan", "arc-region-switch:ListPlans", "arc-region-switch:GetPlanInRegion", "arc-region-switch:ListPlansInRegion", "arc-region-switch:GetPlanEvaluationStatus", "arc-region-switch:GetPlanExecution", "arc-region-switch:ListRoute53HealthChecks", "arc-region-switch:ListPlanExecutions", "arc-region-switch:ListPlanExecutionEvents", "arc-region-switch:ListTagsForResource" ], "Resource": "*" } ] }

執行區塊許可

下列各節針對您新增至區域切換計畫的特定執行區塊提供 IAM 政策。

EC2 Amazon EC2 Auto Scaling 執行區塊

計劃執行角色管理 EC2 Amazon EC2 Auto Scaling 群組的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "autoscaling:DescribeAutoScalingGroups" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "autoscaling:UpdateAutoScalingGroup" ], "Resource": [ "arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:123d456e-123e-1111-abcd-EXAMPLE22222:autoScalingGroupName/app-asg-primary", "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:1234a321-123e-1234-aabb-EXAMPLE33333:autoScalingGroupName/app-asg-secondary" ] }, { "Effect": "Allow", "Action": [ "cloudwatch:GetMetricStatistics" ], "Resource": "*", "Condition": { "StringEquals": { "cloudwatch:namespace": "AWS/AutoScaling" } } } ] }

Amazon EKS 資源擴展執行區塊

計劃執行角色管理 Amazon EKS 叢集的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "eks:DescribeCluster" ], "Resource": [ "arn:aws:eks:us-east-1:123456789012:cluster/app-eks-primary", "arn:aws:eks:us-west-2:123456789012:cluster/app-eks-secondary" ] }, { "Effect": "Allow", "Action": [ "eks:ListAssociatedAccessPolicies" ], "Resource": [ "arn:aws:eks:us-east-1:123456789012:access-entry/app-eks-primary/*", "arn:aws:eks:us-west-2:123456789012:access-entry/app-eks-secondary/*" ] } ] }

注意:除了此 IAM 政策之外,還需要使用 存取政策將計劃執行角色新增至 Amazon EKS 叢集的AmazonArcRegionSwitchScalingPolicy存取項目。如需詳細資訊,請參閱設定 EKS 存取項目許可

Amazon ECS 服務擴展執行區塊

計劃執行角色管理 Amazon ECS 服務的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecs:DescribeServices", "ecs:UpdateService" ], "Resource": [ "arn:aws:ecs:us-east-1:123456789012:service/app-cluster-primary/app-service", "arn:aws:ecs:us-west-2:123456789012:service/app-cluster-secondary/app-service" ] }, { "Effect": "Allow", "Action": [ "ecs:DescribeClusters" ], "Resource": [ "arn:aws:ecs:us-east-1:123456789012:cluster/app-cluster-primary", "arn:aws:ecs:us-west-2:123456789012:cluster/app-cluster-secondary" ] }, { "Effect": "Allow", "Action": [ "ecs:ListServices" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "application-autoscaling:DescribeScalableTargets", "application-autoscaling:RegisterScalableTarget" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "cloudwatch:GetMetricStatistics" ], "Resource": "*", "Condition": { "StringEquals": { "cloudwatch:namespace": "ECS/ContainerInsights" } } } ] }

ARC 路由控制執行區塊

注意:Amazon ARC 路由控制執行區塊需要套用至計劃執行角色的任何服務控制政策 (SCPs) 允許存取這些服務的下列區域:

  • route53-recovery-control-config: us-west-2

  • route53-recovery-cluster: us-west-2, us-east-1, eu-west-1, ap-southeast-2, ap-northeast-1

計劃執行角色管理 ARC 路由控制的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "route53-recovery-control-config:DescribeControlPanel", "route53-recovery-control-config:DescribeCluster" ], "Resource": [ "arn:aws:route53-recovery-control::123456789012:controlpanel/abcd1234abcd1234abcd1234abcd1234", "arn:aws:route53-recovery-control::123456789012:cluster/4b325d3b-0e28-4dcf-ba4a-EXAMPLE11111" ] }, { "Effect": "Allow", "Action": [ "route53-recovery-cluster:GetRoutingControlState", "route53-recovery-cluster:UpdateRoutingControlStates" ], "Resource": [ "arn:aws:route53-recovery-control::123456789012:controlpanel/1234567890abcdef1234567890abcdef/routingcontrol/abcdef1234567890", "arn:aws:route53-recovery-control::123456789012:controlpanel/1234567890abcdef1234567890abcdef/routingcontrol/1234567890abcdef" ] } ] }

您可以使用 CLI 擷取路由控制面板 ID 和叢集 ID。如需詳細資訊,請參閱 設定路由控制元件

Aurora 全域資料庫執行區塊

計劃執行角色管理 Aurora 全域資料庫的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "rds:DescribeGlobalClusters", "rds:DescribeDBClusters" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "rds:FailoverGlobalCluster", "rds:SwitchoverGlobalCluster" ], "Resource": [ "arn:aws:rds:us-east-1:123456789012:global-cluster:app-global-db", "arn:aws:rds:us-east-1:123456789012:cluster:app-db-primary", "arn:aws:rds:us-west-2:123456789012:cluster:app-db-secondary" ] } ] }

手動核准執行區塊

可核准手動步驟之角色的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "arc-region-switch:ApprovePlanExecutionStep" ], "Resource": "arn:aws:arc-region-switch::123456789012:plan/sample-plan:0fba5e" } ] }

自訂動作 Lambda 執行區塊

計劃執行角色叫用 Lambda 函數的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "lambda:GetFunction", "lambda:InvokeFunction" ], "Resource": [ "arn:aws:lambda:us-east-1:123456789012:function:app-recovery-primary", "arn:aws:lambda:us-west-2:123456789012:function:app-recovery-secondary" ] } ] }

Route 53 運作狀態檢查執行區塊

計劃執行角色使用 Route 53 運作狀態檢查的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "route53:ListResourceRecordSets" ], "Resource": [ "arn:aws:route53:::hostedzone/Z1234567890ABCDEFGHIJ" ] } ] }

區域切換計畫執行區塊

計劃執行角色執行子計劃的政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "arc-region-switch:StartPlanExecution", "arc-region-switch:GetPlanExecution", "arc-region-switch:CancelPlanExecution", "arc-region-switch:UpdatePlanExecution", "arc-region-switch:ListPlanExecutions" ], "Resource": [ "arn:aws:arc-region-switch::123456789012:plan/child-plan-1:50c1a1", "arn:aws:arc-region-switch::123456789012:plan/child-plan-2:d1e5e1" ] } ] }

應用程式運作狀態的 CloudWatch 警示

計劃執行角色的政策,用於存取應用程式運作狀態的 CloudWatch 警示,以協助判斷實際復原時間:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cloudwatch:DescribeAlarmHistory", "cloudwatch:DescribeAlarms" ], "Resource": [ "arn:aws:cloudwatch:us-east-1:123456789012:alarm:app-health-primary", "arn:aws:cloudwatch:us-west-2:123456789012:alarm:app-health-secondary" ] } ] }

跨帳戶資源存取

如果資源位於不同的帳戶中,您將需要跨帳戶角色。以下是跨帳戶角色的信任政策範例:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/RegionSwitchExecutionRole" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:ExternalId": "UniqueExternalId123" } } } ] }

以及計劃執行角色擔任此跨帳戶角色的許可:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::987654321098:role/RegionSwitchCrossAccountRole", "Condition": { "StringEquals": { "sts:ExternalId": "UniqueExternalId123" } } } ] }

完成計劃執行角色政策

包含所有執行區塊許可的完整政策將會相當大。實際上,您應該只包含您在特定計劃中使用的執行區塊的許可。以下是一個範例 政策:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iam:SimulatePrincipalPolicy", "Resource": "arn:aws:iam::123456789012:role/RegionSwitchExecutionRole" }, { "Effect": "Allow", "Action": [ "arc-region-switch:GetPlan", "arc-region-switch:GetPlanExecution", "arc-region-switch:ListPlanExecutions" ], "Resource": "*" }, // Include additional statements for specific execution blocks here ] }

請記得只包含您在計劃中使用的特定執行區塊所需的許可,以遵循最低權限原則。