【问题标题】:Cloudformation: Cannot create ELB and DNSRecord togetherCloudformation:无法同时创建 ELB 和 DNSRecord
【发布时间】:2017-02-23 16:49:06
【问题描述】:

我正在通过 CloudFormation 创建一整套服务。创建 ELB,然后创建 ELB DNSName 的 DNS 记录集。记录集依赖于 ELB。

"dns": {
  "Type": "AWS::Route53::RecordSetGroup",
  "Properties": {
    "HostedZoneName": "*******.com.",
    "RecordSets": [
      {
        "Name": {
          "Fn::Join": [
            "",
            [
              "\\052.",
              {
                "Ref": "EnvUrl"
              },
              ".******.com"
            ]
          ]
        },
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "Z3******O77V",
          "DNSName": {"Fn::GetAtt": [ "elb", "DNSName" ]}
        }
      }
    ]
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "c1513eaa-fdaa-4fef-b50c-bdd178dd0446"
    }
  },
  "DependsOn": [
    "elb"
  ]
}



"elb": {
      "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
      "Properties": {
        "Policies": [
          {
            "PolicyName": "AWSConsole-SSLNegotiationPolicy",
            "PolicyType": "SSLNegotiationPolicyType",
            "Attributes": [
              {
                "Name": "Reference-Security-Policy",
                .......

问题是 CloudFormation 无法创建记录集。错误:

Tried to create an alias that targets ctf21-elb-1huy2****pkn-727***38.eu-central-1.elb.amazonaws.com,
type A in zone Z3******O77V, but the alias target name does not lie within the target zone

我认为这可能是由于负载均衡器在创建后立即不可用。就像您手动创建它一样,它不会立即显示在 Route53 上的别名选择字段中,而是需要几分钟。

我还尝试使用Fn::Join 添加dualstack.-dnsname-,同样的输出。

我做错了什么吗?有没有比我能做的更好的方法来解决这个问题?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    您的 ELB 区域可能是错误的。

    在 AliasTarget 中试试这个。

    "AliasTarget": {
                "DNSName": { "Fn::GetAtt": [ "elb", "DNSName" ]},
                "HostedZoneId": { "Fn::GetAtt": [ "elb", "CanonicalHostedZoneNameID"]}
    }
    

    【讨论】:

    • Aaaaah 我以为我必须将我的 Route53 托管区域 ID 放在这里,我没有意识到 ELB 有另一个托管区域 ID。我现在就测试。
    • 工作得很好。谢谢。
    • 当你有一个“双堆栈”时,这似乎不起作用。
    猜你喜欢
    • 2020-10-20
    • 2017-03-01
    • 1970-01-01
    • 2018-07-11
    • 2014-02-02
    • 2020-03-11
    • 2020-03-27
    • 2019-09-10
    • 2019-12-13
    相关资源
    最近更新 更多