我正在使用 python 模块对流层来创建我的云形成模板。其中大部分是完整的,但我似乎对如何使用 RecordSets 方法/函数为负载均衡器创建我的 DNS 条目感到困惑。本节的输出应该如下所示:
"devdevopsdemoELBDNSARecord0": {
"Type": "AWS::Route53::RecordSetGroup",
"Properties": {
"HostedZoneName": "FOO.net.",
"Comment": "Alias targeted to devdevopsdemoELB ELB.",
"RecordSets": [
{
"Name": "devopsdemo.dev.FOO.net.",
"Type": "A",
"AliasTarget": {
"HostedZoneId": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneNameID"
]
},
"DNSName": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneName"
]
}
}
},
{
"Name": "devopsdemo-dev.FOO.net.",
"Type": "A",
"AliasTarget": {
"HostedZoneId": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneNameID"
]
},
"DNSName": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneName"
]
}
}
}
我开始了:
hostedzone = "FOO.net"
myRecordSet = RecordSetType("devdevopsdemoELBDNSARecord0")
myRecordSet.HostedZoneName=Join("", hostedzone, "."])
myRecordSet.Comment="Alias targeted to devdevopsdemoELB ELB."
但是我不清楚应该如何输入 RecordSets 值。
我想我可以直接用
myRecordSet.RecordSets =
只需将 json 放在适当的位置,但这似乎有点像滥用对流层的最初目的。
更新:放入 json 会导致此错误
AttributeError:AWS::Route53::RecordSet 对象不支持属性 RecordSets
myRecordSet.RecordSets = [
{
"Name": "devopsdemo.dev.FOO.net.",
"Type": "A",
"AliasTarget": {
"HostedZoneId": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneNameID"
]
},
"DNSName": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneName"
]
}
}
},
{
"Name": "devopsdemo-dev.FOO.net.",
"Type": "A",
"AliasTarget": {
"HostedZoneId": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneNameID"
]
},
"DNSName": {
"Fn::GetAtt": [
"devdevopsdemoELB",
"CanonicalHostedZoneName"
]
}
}
}
]
然后我尝试了这个:
myDNSRecord = t.add_resource(RecordSetGroup(
"devdevopsdemoELBDNSARecord0",
HostedZoneName=Join("", ["inpwrd.net", "."]),
Comment="DNS Entry to point to the ELB for devopsdemo",
RecordSets=[
RecordSet(
Name="devopsdemo.dev.inpwrd.net.",
Type="A",
AliasTarget=[HostedZoneId(GetAtt("devdevopsdemoELB", "CanonicalHostedZoneNameID")),
DNSName(GetAtt("devdevopsdemoELB", "CanonicalHostedZoneName"))],
),
RecordSet(
Name="devopsdemo-dev.inpwrd.net.",
Type="A",
AliasTarget=[HostedZoneId(GetAtt("devdevopsdemoELB", "CanonicalHostedZoneNameID")),
DNSName(GetAtt("devdevopsdemoELB", "CanonicalHostedZoneName"))],
),
],
)
)
未找到 HostedZoneId