Amazon web services 如何在cloudformation脚本的输出部分引用记录集名称?

Amazon web services 如何在cloudformation脚本的输出部分引用记录集名称?,amazon-web-services,amazon-cloudformation,amazon-route53,Amazon Web Services,Amazon Cloudformation,Amazon Route53,我正在我的cloudformation中创建一些DNS条目。cfn脚本中传递了一个参数,这导致创建一个Route53条目,如hostname-test.example.com: "Host" : { "Type" : "AWS::Route53::RecordSetGroup", "Properties" : { "HostedZoneName" : "example.com.", "RecordSets" : [ { "Nam

我正在我的cloudformation中创建一些DNS条目。cfn脚本中传递了一个参数,这导致创建一个Route53条目,如hostname-test.example.com:

"Host" : {
  "Type" : "AWS::Route53::RecordSetGroup",
  "Properties" : {
      "HostedZoneName" : "example.com.",
      "RecordSets" : [
        {
          "Name" : { 
            "Fn::Join" : [ "-", [
                {"Ref" : "Hostname" },
                "test.example.com"
            ]]
          },
          "Type" : "A",
          "AliasTarget" : {
            "DNSName" : { "Fn::GetAtt" : [ "PublicWebLoadBalancer", "CanonicalHostedZoneName" ] },
            "HostedZoneId" : { "Fn::GetAtt" : [ "PublicWebLoadBalancer", "CanonicalHostedZoneNameID" ] }
          }
        }
      ]
  }
}
在我的输出中,我想从记录集中获取Name属性,但我不知道如何引用它。根据,不支持Route53对象


这可能吗?

不要将记录集嵌入记录集组,而是将其定义为一个单独的属性,与记录集组具有相同的HostedZoneName

然后可以使用“Ref”来获取Name属性的值


我赞成尝试记录集的建议

但是你的“名字”是确定的。如果堆栈完成,输出您已经拥有的将永远不会与您想要的有所不同:

          { 
            "Fn::Join" : [ "-", [
                {"Ref" : "Hostname" },
                "test.example.com"
            ]]
          }

如果这是面向对象的,我会说,在没有利用机会隐式测试函数的情况下回退一个参数是绝对错误的。

这个问题有点老了,但我只是遇到了同样的问题。 您需要输出整个记录集,即:

"Outputs" : {
  "MyDNSRecord" : {
    "Description": "The DNS Record of ...",
    "Value" : { "Ref": "MyRecordSet" }
  }
}

它(不是直观地)输出您正在查找的记录集名称的值。

我有同样的问题,并且正在寻找yaml中的明确答案

给定以下AWS::Route53::记录集

rPublicReverseProxyNLBDnsRecord:
  Type: AWS::Route53::RecordSet
  Properties:
    HostedZoneName: !Ref pPublicHostedZoneName
    Comment:  !Sub 'DNS record for the ${AWS::StackName} ELB front door.'
    Name: !Sub '${pDeploymentType}.${pPublicHostedZoneName}'
    Type: CNAME
    TTL: '30'
    ResourceRecords:
      - !GetAtt rPublicReverseProxyNLB.DNSName
我能够使用以下输出部分代码输出我想要的应用程序URL:

Outputs:

  ApplicationURL:
    Description: 'The public URL for the application'
    Value: !Sub 'https://${rPublicReverseProxyNLBDnsRecord}/'

这个答案是正确的,但最初我并不清楚。我为yaml添加了一个类似的答案。