我尝试连接的是负载均衡器 DNS 名称到 Route53。
让我们看看例子。
这是来自 Resource 模板的 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"} 没有用。有人可以建议或给我正确的方法来添加这个吗?
谢谢!
最佳答案
您很可能希望获取引用为 DNSName
的 LoadBalancer 的属性 RestELB
。所以你需要一些类似 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/