3

我想爲子域名創建Route53託管區域,併爲父域創建NS記錄。如何使用Cloud Formation創建子域名託管區域

比方說,我有:

example.com 

,我想子站點託管區:

build.example.com 

託管區的創建工作:

ClusterHostedZone: 
    Type: "AWS::Route53::HostedZone" 
    Properties: 
    Name: !Ref DomainName 
    HostedZoneConfig: 
     Comment: Managed by Cloud Formation 
    HostedZoneTags: 
     - Key: KubernetesCluster 
     Value: !Ref KubernetesCluster 

爲子域唐委派責任't:

ParentHostedZoneClusterRecord: 
    Type: "AWS::Route53::RecordSet" 
    Properties: 
    Name: !Ref DomainName 
    Comment: Managed by Cloud Formation 
    HostedZoneId: !Ref ParentHostedZoneID 
    TTL: 30 
    Type: NS 
    ResourceRecords: !GetAtt ClusterHostedZone.NameServers 

這沒有實現,我不知道如何得到這個信息

ResourceRecords: !GetAtt ClusterHostedZone.NameServers 

這是簡單的功能,只是在雲的形成缺少什麼?

+0

RecordSetGroup會是一個解決方案嗎? http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-recordsetgroup.html – masterforker

+0

對不起,但我沒有看到如何幫助。你能詳細說明一下嗎? –

+0

我正確理解你想在你的託管區域下關聯一堆別名? – masterforker

回答

2

我與AWS工作人員證實,這是不可能的一月左右2017年

即使有一個自定義的拉姆達it was not possible until April由於:

在AWS CloudFormation中,您無法創建NS或SOA類型的記錄。

現在它看起來像behavior is different

具體來說,您不能創建或託管區域的根域刪除NS和SOA記錄,但你可以爲子域創建它們代表。

從託管區獲得的域名服務器是[現在可以], 我測試過它。(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53-hostedzone.html#w2ab2c21c10d825c11

唯一的限制,我無法克服了跨賬戶託管區域關係/修改,但它應該是足夠的CF/Lambda魔術。

+0

這是錯誤的。上面的鏈接並沒有說你不能創建NS記錄,它特別說你可以爲子域創建它們:「在AWS CloudFormation中,你不能修改Amazon Route 53自動創建的託管區域的NS和SOA記錄。具體來說,您不能爲託管區域的根域創建或刪除NS或SOA記錄,但可以爲子域名創建它們以供委派。例如,對於託管區域mydomain.net,您無法爲mydomain.net創建NS記錄但是您可以爲nnnn.mydomain.net創建一個NS記錄以供委派。「 –

+0

如果你能提供一個示例堆棧,將不勝感激 –

+0

看看這個堆棧:https://github.com/ConradIrwin/aws-name-server/blob/master/cloudformation-template.json –

0

要爲子域添加託管區域,您應該可以創建類似於現有託管區域的描述,只需將Name屬性更改爲子域。

但是,基於你的問題,它聽起來像你實際上試圖爲一個子域添加一個記錄集(所以build.[DomainName]解析爲你的集羣),而不是一個單獨的託管區域。

添加一條記錄集的一個子域,要指定'build.[DomainName]'爲您的子域的記錄集的名稱,並使用A record指定目標IP地址的子域(或CNAME指定「規範」域名) ,而不是NS record

ParentHostedZoneClusterRecord: 
    Type: "AWS::Route53::RecordSet" 
    Properties: 
    Name: 
     Fn::Join: [".", ["build", !Ref DomainName]] 
    Comment: Managed by Cloud Formation 
    HostedZoneId: !Ref ParentHostedZoneID 
    TTL: 30 
    Type: A 
    ResourceRecords: [!Ref KubernetesClusterIp] 
+0

我想將NS記錄添加到父域,Hosted Zone創建很簡單,它是父項我不能使用CF –

2

這是爲我的工作,也許你的模板不工作,因爲你沒有指定DependsOn和資源不按順序創建。

stagingHostedZone: 
    Type: 'AWS::Route53::HostedZone' 
    Properties: 
     HostedZoneConfig: 
      Comment: Hosted zone for staging environment 
     Name: staging.example.com 

nsRootHostedZoneRecordSet: 
    Type: 'AWS::Route53::RecordSet' 
    Properties: 
     HostedZoneId: Z25********* 
     Name: staging.example.com. 
     Type: NS 
     TTL: '900' 
     ResourceRecords: !GetAtt stagingHostedZone.NameServers 
    DependsOn: 
     stagingHostedZone 
+0

看起來像AWS自1月份以來添加功能 –