首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >云的形成:一个网卡上2个弹性公网on,2个EIPs

云的形成:一个网卡上2个弹性公网on,2个EIPs
EN

Stack Overflow用户
提问于 2017-06-01 23:35:29
回答 1查看 598关注 0票数 0

收到“弹性公网EIP不稳定”错误。代码如下...可能是代码,也可能是cloudformation错误。

我想在接口上附加两个弹性公网IP,一个到主内网IP,一个到辅助内网IP。当我在控制台上操作时,它可以工作。

如果我注释掉'VIP‘或' EIP’代码,我还可以成功地添加两个内网IP和一个EIP连接到主内网IP或辅助内网IP。其中一个可以工作,但不能同时使用两个。

代码语言:javascript
运行
复制
  #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
EN

回答 1

Stack Overflow用户

发布于 2017-06-27 04:13:04

代码如下。

代码语言:javascript
运行
复制
---
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44311817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档