AWS 网络负载均衡器 CloudFormation IP
AWS network Load Balancer CloudFormation IP
在我的 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
Listener 和 Target Groups 是单独创建的,并且也在没有弹性 IP 的情况下使用 LB。
现在我试图通过将子网更改为 SubnetMappings 属性 来将此弹性 IP 分配给负载均衡器,但它给我错误:"LoadBalancer CREATE_FAILED Property SubnetId cannot be empty."
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: network-loadbalancer
Scheme: internet-facing
SubnetMappings:
- AllocationId: !Ref LoadBalancerElasticIP
- SubnetId: !Ref Subnet1a
Type: network
一段时间以来,我一直在尝试不同的解决方案。看不出有什么问题。有任何想法吗?我应该创建网络接口吗?并将 eip 分配给接口,然后将接口分配给负载均衡器?
根据 AWS::ElasticLoadBalancingV2::LoadBalancer
的文档,SubnetMappings
的预期值为 List of SubnetMapping
,但您要传递两个列表。您应该将其更改为以下内容:
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: network-loadbalancer
Scheme: internet-facing
SubnetMappings:
- AllocationId: !Ref LoadBalancerElasticIP
SubnetId: !Ref Subnet1a
在我的 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
Listener 和 Target Groups 是单独创建的,并且也在没有弹性 IP 的情况下使用 LB。
现在我试图通过将子网更改为 SubnetMappings 属性 来将此弹性 IP 分配给负载均衡器,但它给我错误:"LoadBalancer CREATE_FAILED Property SubnetId cannot be empty."
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: network-loadbalancer
Scheme: internet-facing
SubnetMappings:
- AllocationId: !Ref LoadBalancerElasticIP
- SubnetId: !Ref Subnet1a
Type: network
一段时间以来,我一直在尝试不同的解决方案。看不出有什么问题。有任何想法吗?我应该创建网络接口吗?并将 eip 分配给接口,然后将接口分配给负载均衡器?
根据 AWS::ElasticLoadBalancingV2::LoadBalancer
的文档,SubnetMappings
的预期值为 List of SubnetMapping
,但您要传递两个列表。您应该将其更改为以下内容:
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
IpAddressType: ipv4
Name: network-loadbalancer
Scheme: internet-facing
SubnetMappings:
- AllocationId: !Ref LoadBalancerElasticIP
SubnetId: !Ref Subnet1a