仅允许 IAM 访问 Route 53 上的特定子域

Allowing IAM access to only a specific subdomain on Route 53

我需要授予 IAM 用户 Route 53 访问权限以在子域下创建记录,比如 data.example.com。例如,用户应该能够为 server1.data.example.com 创建 CNAME。同时,我不希望用户能够 add/modify/delete 除了 *.data.example.com.

之外的任何记录

是否可以编写这样的策略?

您可以按托管区域进行限制,但不能按子域进行限制。如果您想限制到特定的子域,您的 Route53 托管区域应该按子域分开。你可以 create a hosted zone for a subdomain:

例如,如果您想要一个名为 test 的子域,您可以按照 的答案总结得很好:

Create a hosted zone for test.example.com.

Note the 4 name servers that Route 53 assigns to it the new hosted zone.

Back in the master zone, create a new resource record, with hostname "test" using record type NS, and enter the 4 name servers that Route 53 assigned, in the box below.

以上将该子域的控制权委托给这个新的托管区域,它有一个我们可以在 IAM 策略中使用的唯一区域 ID

然后您可以构建一个 IAM 策略来限制对该区域的操作:

{
   "Statement":[
      {
         "Action":[
            "route53:*"
         ],
         "Effect":"Allow",
         "Resource":[
            "arn:aws:route53:::hostedzone/<The new zone ID>"
         ]
      },
      {
         "Action":[
            "route53:ListHostedZones"
         ],
         "Effect":"Allow",
         "Resource":[
            "*"
         ]
      }
   ]
}

从这里您可以调整此策略以适合您希望用户能够在此区域中执行的操作。

来自AWS Documentation

在策略中,您可以通过对 ARN 使用 * 来授予或拒绝对以下资源的访问权限:

  • 健康检查
  • 托管区域
  • 可重复使用的委托集
  • 资源记录集更改批次的状态(仅限API)
  • 交通政策(交通流量)
  • 流量策略实例(流量)

并非所有 Route 53 资源都支持权限。您不能授予或拒绝对以下资源的访问权限:

  • 个人记录
  • 命名空间(服务发现)
  • 服务(服务发现)
  • 域标签
  • 健康检查标签
  • 托管区域的标签

这基本上意味着 IAM 最精细的控制是单独的托管区域(DNS 区域文件)。

您可以按照此 AWS Guide

仅为特定子域创建托管区域