简体   繁体   English

将现有的Elastic IP与CloudFormation脚本中的Ec2实例相关联?

[英]Associate an existing Elastic IP with an Ec2 Instance from inside a CloudFormation script?

I have a CloudFormation stack that is used to create multiple copies of an environment. 我有一个CloudFormation堆栈,用于创建环境的多个副本。 Some but not all of these environments will have elastic IPs associated. 这些环境中的一些(但不是全部)将具有关联的弹性IP。

Right now I: 现在我:

  1. Run the CF script 运行CF脚本
  2. Assign the Elastic IP where approprite 在适当的地方分配弹性IP
  3. On stack updates that don't touch the instance, Elastic IP is preserved to the instance which had it. 在不接触实例的堆栈更新中,Elastic IP被保留到拥有它的实例。
  4. On updates to the instance itself,the association is lost. 在更新实例本身时,关联将丢失。

    It kind of makes senses that when the underlying instance name is changed when updates are made from the CF stack itself, which causes the IP to become unassigned. 从某种意义上说,当从CF堆栈本身进行更新时,如果更改了基础实例名称,则会导致IP未分配。 So I would like to pass in the ID of the elastic IP as a parameter to the script and assign it manually. 因此,我想将弹性IP的ID作为参数传递给脚本并手动进行分配。

It seems there are two ways to do this , but I don't understand the difference. 看来有两种方法可以做到这一点 ,但我不明白其中的区别。 What is an allocation Id, and when would you need to use it? 什么是分配ID,您何时需要使用它?

"IPAssoc" : {
     "Type" : "AWS::EC2::EIPAssociation",
     "Properties" : {
         "InstanceId" : { "Ref" : "logical name of an AWS::EC2::Instance resource" },
         "EIP" : "existing Elastic IP address"
     }
 }

vs VS

"VpcIPAssoc" : {
     "Type" : "AWS::EC2::EIPAssociation",
     "Properties" : {
         "InstanceId" : { "Ref" : "logical name of an AWS::EC2::Instance resource" },
         "AllocationId" : "existing VPC Elastic IP allocation ID"
     }
 }

The difference is between VPC usage and EC2 Classic. VPC使用率和EC2 Classic之间的区别。

As per http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip-association.html , EIP is for use with EC2 Classic and AllocationId is for VPC's. 根据http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip-association.html,EIP适用于EC2 Classic,而AllocationId适用于VPC。

For the difference between VPC and EC2 Classic, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-vpc.html#differences-ec2-classic-vpc . 有关VPC和EC2 Classic之间的区别,请参阅http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-vpc.html#differences-ec2-classic-vpc

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将现有EIP与CloudFormation中的EC2实例相关联 - Associate an existing EIP to EC2 Instance in CloudFormation 将现有 IAM 角色与 CloudFormation 中的 EC2 实例相关联 - Associate existing IAM role with EC2 instance in CloudFormation 无法在Amazon EC2实例上关联弹性IP - Can't associate an Elastic IP on Amazon EC2 Instance 使用 cloudformation 将弹性 IP 添加到 ec2 实例 - Adding Elastic IP to ec2 instance using cloudformation 如果弹性ip与另一个正在运行的ec2实例相关联,是否可以在重启后重新关联弹性ip和ec2实例? - Is it possible to re-associate an elastic ip with an ec2 instance after reboot if the elastic ip is associated to another running ec2 instance? 将弹性IP地址分配给现有的/正在运行的Amazon EC2实例 - Allocating an Elastic IP address to an existing / running Amazon EC2 instance 将预先存在的 static(弹性)IP 分配给 EC2 实例 - Assign pre-existing static (elastic) IP to EC2 instance 如果我将弹性IP关联到运行中的EC2实例,是否会删除其当前的公共IP? - Will my running EC2 instance drop its current public IP if I associate an Elastic IP to it? 如何为同一Amazon EC2 ubuntu实例同时关联公共IP和弹性IP? - How Can we Associate both public IP and Elastic IP for an same Amazon EC2 ubuntu instance? 如何自动创建具有公共IP的Ec2实例**而不在**中声明弹性IP? - How do I create an Ec2 Instance with a Public IP automatically **without** declaring an Elastic IP in cloudformation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM