【问题标题】:Is there a way to fetch HostedZoneId from DNS name in CFT?有没有办法从 CFT 中的 DNS 名称中获取 HostedZoneId?
【发布时间】:2021-03-04 07:04:09
【问题描述】:

在 CloudFormation 模板中,我们可以从 DNS 名称中获取 HostedZoneId 吗?一种方法是我们检查资源并查找 HostedZoneId 并将其插入。我们是否也可以使用 GetAtt 或任何其他函数来获取 id。

我想在 HostedZoneId 上做这样的事情,但这是不正确的。有没有其他方法可以做到这一点?

Parameter:
  VPCEDNS:
  Description: VPCe DNS target 
  Type: String

Resources:
  PrimaryRecord:
    Type: AWS::Route53::RecordSet
    Properties: 
      AliasTarget: 
        HostedZoneId: !GetAtt (!Ref "VPCEDNS").HostedZoneId
        DNSName: !Ref "VPCEDNS"
        EvaluateTargetHealth: true
      Failover: PRIMARY
      HostedZoneName: example.com
      Name: service.example.com
      Type: A

【问题讨论】:

    标签: amazon-web-services yaml amazon-cloudformation amazon-route53


    【解决方案1】:

    遗憾的是,在普通的 CFN 中没有这样的方法。如果你真的需要这样的功能,你必须使用custom resource

    资源将采用 lambda 函数的形式,它将您的 DNS 名称作为输入参数。然后使用 AWS SDK(例如 boto3),它会找到并匹配相应的托管区域,并将其 ID 返回到您的 CFN 堆栈中以供进一步使用。

    【讨论】:

      猜你喜欢
      • 2021-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-29
      • 2013-01-08
      • 2022-01-26
      • 1970-01-01
      相关资源
      最近更新 更多