gpt4 book ai didi

json - 是否可以使用 AWS Cloudformation 模板将 Loadbalancers DNSname 连接到 Route53?

转载 作者:行者123 更新时间:2023-12-01 07:09:45 25 4
gpt4 key购买 nike

我尝试连接的是负载均衡器 DNS 名称到 Route53。让我们看一下例子。这是来自资源中模板的 Loadbabancer:

"RestELB" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"DependsOn": "AttachGateway",
"Properties": {
"LoadBalancerName": {"Fn::Join": ["",["Rest-ELB-", {"Ref": "VPC"}]]},
"CrossZone" : "true",
"Subnets": [{ "Ref": "PublicSubnet1" },{ "Ref": "PublicSubnet2" }],
"Listeners" : [
{"LoadBalancerPort" : "80", "InstancePort" : "80","Protocol" : "HTTP"},
{"LoadBalancerPort" : "6060", "InstancePort" : "6060","Protocol" : "HTTP"}
],
}
},

这是 Route53:

"ApiRecordSet" : {
"Type" : "AWS::Route53::RecordSet",
"Properties" : {
"AliasTarget" :{
"DNSName" : [
{"Fn::Join": ["", [{"ElasticLoadBalancer": "DNSName"},"."]]}
],
"EvaluateTargetHealth" : "Boolean",
"HostedZoneId" : "String"
},
"HostedZoneName" : "example.net.",
"Comment" : "A records for my frontends.",
"Name" : "api.example.net.",
"Type" : "A",
"TTL" : "900",
}
}

仅仅放置 {"ElasticLoadBalancer": "DNSName"} 不起作用。有人可以建议或给我正确的方法来添加这个吗?

谢谢!

最佳答案

您很可能想要获取引用为 RestELB 的 LoadBalancer 的属性 DNSName。所以你需要一些带有 Fn::GetAtt 的东西,比如(未经测试)

   "ApiRecordSet" : {
"Type" : "AWS::Route53::RecordSet",
"Properties" : {
"AliasTarget" :{
"DNSName" : { "Fn::GetAtt" : [ "RestELB", "DNSName" ]},
"EvaluateTargetHealth" : "Boolean",
"HostedZoneId" : "String"
},
"HostedZoneName" : "example.net.",
"Comment" : "A records for my frontends.",
"Name" : "api.example.net.",
"Type" : "A"
}
}

关于json - 是否可以使用 AWS Cloudformation 模板将 Loadbalancers DNSname 连接到 Route53?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34659918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com