本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
ARC 中区域切换的基于身份的策略示例
默认情况下,用户和角色无权创建或修改 ARC 资源。他们也无法使用 Amazon Web Services Management Console、 Amazon Command Line Interface (Amazon CLI) 或 Amazon API 执行任务。要授予用户对所需资源执行操作的权限,IAM 管理员可以创建 IAM 策略。管理员随后可以向角色添加 IAM 策略,用户可以代入角色。
要了解如何使用这些示例 JSON 策略文档创建基于 IAM 身份的策略,请参阅《IAM 用户指南》中的创建 IAM 策略(控制台)。
有关 ARC 定义的操作和资源类型(包括每种资源类型的格式)的详细信息,请参阅《 ARNs 服务授权参考》中的 Amazon Application Recovery Controller (ARC) 的操作、资源和条件密钥。
策略最佳实践
基于身份的策略决定了某人是否可以在您的账户中创建、访问或删除 ARC 资源。这些操作可能会使 Amazon Web Services 账户产生成本。创建或编辑基于身份的策略时,请遵循以下指南和建议:
-
开始使用 Amazon 托管策略并转向最低权限权限 — 要开始向用户和工作负载授予权限,请使用为许多常见用例授予权限的Amazon 托管策略。它们在你的版本中可用 Amazon Web Services 账户。我们建议您通过定义针对您的用例的 Amazon 客户托管策略来进一步减少权限。有关更多信息,请参阅《IAM 用户指南》中的 Amazon 托管式策略或工作职能的Amazon 托管式策略。
-
应用最低权限:在使用 IAM 策略设置权限时,请仅授予执行任务所需的权限。为此,您可以定义在特定条件下可以对特定资源执行的操作,也称为最低权限许可。有关使用 IAM 应用权限的更多信息,请参阅《IAM 用户指南》中的 IAM 中的策略和权限。
-
使用 IAM 策略中的条件进一步限制访问权限:您可以向策略添加条件来限制对操作和资源的访问。例如,您可以编写策略条件来指定必须使用 SSL 发送所有请求。如果服务操作是通过特定的方式使用的,则也可以使用条件来授予对服务操作的访问权限 Amazon Web Services 服务,例如 Amazon CloudFormation。有关更多信息,请参阅《IAM 用户指南》中的 IAM JSON 策略元素:条件。
-
使用 IAM Access Analyzer 验证您的 IAM 策略,以确保权限的安全性和功能性 – IAM Access Analyzer 会验证新策略和现有策略,以确保策略符合 IAM 策略语言(JSON)和 IAM 最佳实践。IAM Access Analyzer 提供 100 多项策略检查和可操作的建议,以帮助您制定安全且功能性强的策略。有关更多信息,请参阅《IAM 用户指南》中的使用 IAM Access Analyzer 验证策略。
-
需要多重身份验证 (MFA)-如果 Amazon Web Services 账户您的场景需要 IAM 用户或根用户,请启用 MFA 以提高安全性。若要在调用 API 操作时需要 MFA,请将 MFA 条件添加到您的策略中。有关更多信息,请参阅《IAM 用户指南》中的使用 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 A EC2 uto Scaling 执行块
用于管理 EC2 Amazon A EC2 uto 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 访问进入权限。
亚马逊 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 ] }
请记住仅包含您在计划中使用的特定执行块所需的权限,以遵循最小权限原则。