在我的CloudFormation模板中,我创建了弹性IP和网络负载均衡器。创建过程中没有任何问题。
Subnet1a:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
AvailabilityZone: 'eu-west-1a'
CidrBlock:
Ref: 042SubnetCidr
MapPublicIpOnLaunch: true
LoadBalancerElasticIP:
Type: AWS::EC2::EIP
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: network-loadbalancer
Scheme: internet-facing
Subnets:
- Ref: Subnet1a
Type: network
监听器和目标组是分开创建的,在没有弹性IP的情况下也可以使用LB。
现在我正在尝试将此弹性IP分配给负载均衡器,通过更改子网到SubnetMappings属性,但是出现了错误:“LoadBalancer CREATE_FAILED 属性SubnetId不能为空。”
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: network-loadbalancer
Scheme: internet-facing
SubnetMappings:
- AllocationId: !Ref LoadBalancerElasticIP
- SubnetId: !Ref Subnet1a
Type: network
我已经尝试了不同的解决方案一段时间了,但还是不知道哪里出了问题。您有什么想法吗?我是否应该创建网络接口?并将弹性IP分配给接口,然后将接口分配给负载均衡器?