Amazon ec2 云信息:2个EIP,一个ENI上有2个IP

Amazon ec2 云信息:2个EIP,一个ENI上有2个IP,amazon-ec2,amazon-cloudformation,elastic-ip,Amazon Ec2,Amazon Cloudformation,Elastic Ip,获取“EIP不会稳定”错误。代码如下。。。可能是代码,也可能是云信息错误 我想将两个EIP连接到接口,一个连接到主专用IP,另一个连接到辅助专用IP。当我从控制台进行操作时,它会工作 如果我注释掉“VIP”或“EIP”代码,我还可以将2个专用IP和一个EIP成功连接到主或辅助专用IP。两者都有效,但不能同时起作用 #ServerOne. ServerOne: Type: AWS::EC2::Instance Properties: AvailabilityZo

获取“EIP不会稳定”错误。代码如下。。。可能是代码,也可能是云信息错误

我想将两个EIP连接到接口,一个连接到主专用IP,另一个连接到辅助专用IP。当我从控制台进行操作时,它会工作

如果我注释掉“VIP”或“EIP”代码,我还可以将2个专用IP和一个EIP成功连接到主或辅助专用IP。两者都有效,但不能同时起作用

  #ServerOne.
  ServerOne:
    Type: AWS::EC2::Instance
    Properties:
      AvailabilityZone: !Ref AvailabilityZoneA
      DisableApiTermination: !Ref disableInstanceDeletion
      ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", ServerOne ]
      InstanceType: !FindInMap [ InstanceSizingMap, !Ref StackSizing, ServerOne ]
      EbsOptimized: !FindInMap [ InstanceSizingMap, !Ref StackSizing, ebsOptimizedInstances ]
      BlockDeviceMappings: 
          - DeviceName: "/dev/sda1"
            Ebs: 
              DeleteOnTermination: !FindInMap [ InstanceSizingMap, !Ref StackSizing, DeleteOnTermination ]
      KeyName: !Ref SSHKeyName
      Monitoring: 'false'
      NetworkInterfaces:
        -
          NetworkInterfaceId: !Ref ServerOneInterface
          DeviceIndex: 0
      Tags:
      - Key: Name
        Value: ServerOne
      - Key: Role
        Value: Infrastructure

        # ServerOne Server Network.  2 Private IPs, 2 EIPs all on one interface.
          ServerOneEIP:
            Type: AWS::EC2::EIP
            DependsOn: IGW
            Properties:
              InstanceId: !Ref ServerOne
              Domain: vpc

          ServerOneVIP:
            Type: AWS::EC2::EIP
            DependsOn: IGW
            Properties:
              InstanceId: !Ref ServerOne
              Domain: vpc

          ServerOneEIPAssociation:
            Type: AWS::EC2::EIPAssociation
            DependsOn: ServerOneVIPAssociation
            Properties:
              AllocationId: !GetAtt ServerOneEIP.AllocationId
              NetworkInterfaceId: !Ref ServerOneInterface
              PrivateIpAddress: !GetAtt ServerOneInterface.PrimaryPrivateIpAddress

          ServerOneVIPAssociation:
            Type: AWS::EC2::EIPAssociation
            DependsOn: IGW
            Properties:
              AllocationId: !GetAtt ServerOneVIP.AllocationId
              NetworkInterfaceId: !Ref ServerOneInterface
              PrivateIpAddress: !Select [ 0, !GetAtt ServerOneInterface.SecondaryPrivateIpAddresses ]

          ServerOneInterface:
            Type: AWS::EC2::NetworkInterface
            Properties:
              SubnetId: !Ref PublicSubnetA
              SecondaryPrivateIpAddressCount: 1
              Description: ServerOne Network Interface
              GroupSet: [
                !Ref PuppetClientSG ]
        # ServerOne is doing NAT, so Source/Dest is false.
              SourceDestCheck: false
代码如下

---
Parameters:
Subnet:
Description: ID of the Subnet the instance should be launched in, this will 
link the instance to the same VPC.
Type: List<AWS::EC2::Subnet::Id>
Resources:
EIP1:
    Type: AWS::EC2::EIP
Properties:
  Domain: VPC
EIP2:
Type: AWS::EC2::EIP
Properties:
  Domain: VPC
Association1:
  Type: AWS::EC2::EIPAssociation
DependsOn:
- ENI
- EIP1
Properties:
  AllocationId:
    Fn::GetAtt:
    - EIP1
    - AllocationId
  NetworkInterfaceId:
    Ref: ENI
  PrivateIpAddress:
    Fn::GetAtt:
    - ENI
    - PrimaryPrivateIpAddress
Association2:
Type: AWS::EC2::EIPAssociation
DependsOn:
- ENI
- EIP2
Properties:
  AllocationId:
  Fn::GetAtt:
    - EIP2
    - AllocationId
  NetworkInterfaceId:
    Ref: ENI
  PrivateIpAddress:
    Fn::Select:
    - '0'
    - Fn::GetAtt:
      - ENI
      - SecondaryPrivateIpAddresses
ENI:
Type: AWS::EC2::NetworkInterface
Properties:
  SecondaryPrivateIpAddressCount: 1
  SourceDestCheck: false
  SubnetId:
    Fn::Select:
    - '0'
    - Ref: Subnet
OpenVPN:
    Type: AWS::EC2::Instance
    DependsOn:
    - ENI
    Properties:
    InstanceType: t2.micro
      AvailabilityZone: us-east-2a
      NetworkInterfaces:
      - NetworkInterfaceId:
          Ref: ENI
        DeviceIndex: '0'
    ImageId: ami-8a7859ef
    KeyName: jimkey
---
参数:
子网:
描述:应在其中启动实例的子网ID,这将
将实例链接到同一VPC。
类型:列表
资源:
EIP1:
类型:AWS::EC2::EIP
特性:
域名:专有网络
EIP2:
类型:AWS::EC2::EIP
特性:
域名:专有网络
联想1:
类型:AWS::EC2::EIPAssociation
德彭森:
-埃尼
-EIP1
特性:
分配ID:
Fn::GetAtt:
-EIP1
-分配ID
网络接口ID:
参考:埃尼
私人地址:
Fn::GetAtt:
-埃尼
-主私有地址
联想2:
类型:AWS::EC2::EIPAssociation
德彭森:
-埃尼
-EIP2
特性:
分配ID:
Fn::GetAtt:
-EIP2
-分配ID
网络接口ID:
参考:埃尼
私人地址:
Fn::选择:
- '0'
-Fn::GetAtt:
-埃尼
-第二私有地址
埃尼:
类型:AWS::EC2::NetworkInterface
特性:
Secondary PrivateIPAddressCount:1
SourceDestCheck:false
子网:
Fn::选择:
- '0'
-参考:子网
OpenVPN:
类型:AWS::EC2::实例
德彭森:
-埃尼
特性:
实例类型:t2.micro
可用区:us-east-2a
网络接口:
-网络接口ID:
参考:埃尼
DeviceIndex:“0”
图像ID:ami-8a7859ef
关键词:jimkey