Cloudformation:无法同时创建 ELB 和 DNSRecord
Cloudformation: Cannot create ELB and DNSRecord together
我正在通过 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-
,相同的输出。
我做错了什么吗?有什么比我能做的更好的来解决这个问题吗?
你的ELB区可能是错误的。
在 AliasTarget 中试试这个。
"AliasTarget": {
"DNSName": { "Fn::GetAtt": [ "elb", "DNSName" ]},
"HostedZoneId": { "Fn::GetAtt": [ "elb", "CanonicalHostedZoneNameID"]}
}
我正在通过 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-
,相同的输出。
我做错了什么吗?有什么比我能做的更好的来解决这个问题吗?
你的ELB区可能是错误的。
在 AliasTarget 中试试这个。
"AliasTarget": {
"DNSName": { "Fn::GetAtt": [ "elb", "DNSName" ]},
"HostedZoneId": { "Fn::GetAtt": [ "elb", "CanonicalHostedZoneNameID"]}
}