amazon-web-services - EIP : AddressLimitExceeded

标签 amazon-web-services amazon-ec2 ip

我有一个 CloudFormation 模板,它为 RStudio Server 启动了一个 EC2 实例。

AWSTemplateFormatVersion: 2010-09-09

Description: Sets up an RStudio and Shiny environment on AWS

Parameters:
  InstanceType:
    Type: String
    Description: Instance type for RStudio. Default is t2.micro.
    AllowedValues:
      - t2.micro
      - t2.small
      - t2.medium
      - t2.large
      - t2.xlarge
      - t2.2xlarge
      - m4.large
      - m4.xlarge
      - m4.2xlarge
      - m4.4xlarge
      - m4.10xlarge
      - m4.16xlarge
      - c4.large
      - c4.xlarge
      - c4.2xlarge
      - c4.4xlarge
      - c4.8xlarge
      - r4.large
      - r4.xlarge
      - r4.2xlarge
      - r4.4xlarge
      - r4.8xlarge
      - r4.16xlarge
      - g2.2xlarge
      - g2.8xlarge
      - p2.xlarge
      - p2.8xlarge
      - p2.16xlarge
      - g3.4xlarge
      - g3.8xlarge
      - g3.16xlarge
    ConstraintDescription: Valid instance type in the t2, m4, c4, r4, g2, p2, and g3 families
    Default: t2.micro
  ImageId:
    Type: AWS::EC2::Image::Id
    Description: Amazon Linux Image ID. Default is for 2017.03.01 (HVM). N.B. If you want more storage then you should update your image
    Default: ami-4fffc834
  VpcId:
    Type: AWS::EC2::VPC::Id
    Description: VPC this server will reside in
  InitialUser:
    Type: String
    Description: User Name for RStudio
  InitialPassword:
    Type: String
    Description: Password for RStudio. Please keep in your records as this will not be echoed in the CloudFormation Console
    NoEcho: True
  RStatsS3Bucket:
    Type: String
    Description: Name of the S3 bucket
  KeyPair:
    Type: "AWS::EC2::KeyPair::KeyName"
    Description: Amazon EC2 Key Pair
  SubnetId:
    Type: "AWS::EC2::Subnet::Id"
    Description: Subnet ID your instance will launch in. Should be Internet accessible for the purposes of this demo.

Resources:
  RStatsS3ReadPolicy:
    Type: AWS::IAM::Policy
    Properties:
      PolicyName: RStatsS3ReadPolicy
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action:
            - "s3:ListBucket"
            Resource:
            - !Sub "arn:aws:s3:::${RStatsS3Bucket}"
          - Effect: Allow
            Action:
            - "s3:PutObject"
            - "s3:GetObject"
            - "s3:DeleteObject"
            Resource:
            - !Sub "arn:aws:s3:::${RStatsS3Bucket}/*"
      Roles:
      - !Ref RStatsS3ReadRole

  RStatsS3ReadRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - "ec2.amazonaws.com"
            Action:
              - "sts:AssumeRole"


  RstatsEC2SecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      SecurityGroupIngress:
        - CidrIp: "0.0.0.0/0"
          FromPort: 22
          ToPort: 22
          IpProtocol: tcp
        - CidrIp: "0.0.0.0/0"
          FromPort: 8787
          ToPort: 8787
          IpProtocol: tcp
        - CidrIp: "0.0.0.0/0"
          FromPort: 3838
          ToPort: 3838
          IpProtocol: tcp
      GroupDescription: RStudio and Shiny Security Group
      VpcId: !Ref VpcId

  RStatsEIP:
    Type: AWS::EC2::EIP
    Properties:
      Domain: !Ref VpcId

  RStatsEIPAssociation:
    Type: AWS::EC2::EIPAssociation
    Properties:
      AllocationId: !GetAtt RStatsEIP.AllocationId
      NetworkInterfaceId: !Ref RStatsNetworkInterface

  RStatsNetworkInterface:
    Type: AWS::EC2::NetworkInterface
    Properties:
      SubnetId: !Ref SubnetId
      Description: Interface for RStudio Connection
      GroupSet:
      - !Ref RstatsEC2SecurityGroup
      SourceDestCheck: true

  RStatsEC2Instance:
    Type: AWS::EC2::Instance
    DependsOn: RStatsEIPAssociation
    Properties:
      ImageId: !Ref ImageId
      InstanceType: !Ref InstanceType
      KeyName: !Ref KeyPair
      NetworkInterfaces:
        - NetworkInterfaceId: !Ref RStatsNetworkInterface
          DeviceIndex: 0
      Tags:
      - Key: Name
        Value: RStudio
      UserData:
        Fn::Base64: !Sub |
          #!/bin/bash
          #install R
          yum install -y R
          #install RStudio-Server 1.0.153 (2017-07-20)
          wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.2.1335-x86_64.rpm
          yum install -y --nogpgcheck rstudio-server-rhel-1.2.1335-x86_64.rpm
          rm rstudio-server-rhel-1.2.1335-x86_64.rpm
          #install shiny and shiny-server (2017-08-25)
          R -e "install.packages('shiny', repos='http://cran.rstudio.com/')"
          wget https://download3.rstudio.org/centos6.3/x86_64/shiny-server-1.5.9.923-x86_64.rpm
          yum install -y --nogpgcheck shiny-server-1.5.9.923-x86_64.rpm
          #add user(s)
          useradd ${InitialUser}
          echo ${InitialUser}:${InitialPassword} | chpasswd
          # install curl
          yum install -y curl-devel
          # Use Shiny server
          /opt/shiny-server/bin/deploy-example user-dirs
          mkdir /home/${InitialUser}/ShinyApps
          # copy in some test data
          cp -R /opt/shiny-server/samples/sample-apps/hello /home/${InitialUser}/ShinyApps/

Outputs:
  RStudioURL:
    Value: !Join [":", [!GetAtt RStatsEC2Instance.PublicDnsName, "8787"]]
  ShinyStudioURL:
    Value: !Join [":", [!GetAtt RStatsEC2Instance.PublicDnsName, !Sub "3838/${InitialUser}/MyApp"]]
  PublicIp:
    Value: !GetAtt RStatsEC2Instance.PublicIp

我用这个模板创建了五个实例。我想再启动几个,但我遇到了这个错误。
The maximum number of addresses has been reached. (Service: AmazonEC2; Status Code: 400; Error Code: AddressLimitExceeded; Request ID: 6c8acda5-b399-4239-aa30-265a4371bc6d)

我试图从 Amazon 池中创建更多 IP 地址,但我遇到了这个错误。
The maximum number of addresses has been reached.

我可以重复使用已有的地址吗?

最佳答案

弹性 IP 的主要用例是在实例失败的情况下将 IP 从一个实例移动到另一个实例,作为一种 HA 解决方案。

如果您只需要可公开访问 RStudio 实例,则在启动时启用公共(public) IP(不是弹性 IP)。使用 AssociatePublicIpAddress 执行此操作关于相关 AWS::EC2::NetworkInterface .

关于amazon-web-services - EIP : AddressLimitExceeded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55639533/

相关文章:

node.js - 在 EC2 上安装 node-canvas - fontconfig.h 构建错误

java - 如何获取远程机器的mac地址java

amazon-web-services - 我们如何为我们的 AWS 应用程序提供对客户资源的访问,而无需他们的 key ?

amazon-web-services - AWS API 网关 WebSocket 连接错误

php - Aws S3 CompleteMultipartUpload 错误

ssl - 在 AWS Load Balancer 中将 HTTP 请求路由到 HTTPS

amazon-web-services - 没有这样的文件或目录加载 libssl.so.1.0.0

ubuntu - 有没有办法在 EC2 上运行 Ubuntu 的 UI?

iphone - 在 VPN 上时返回本地 iPhone IP 地址

ip - 多个 IP + KVM 桥接器