gpt4 book ai didi

amazon-web-services - EIP : AddressLimitExceeded

转载 作者:行者123 更新时间:2023-12-03 23:52:20 24 4
gpt4 key购买 nike

我有一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com