簡體   English   中英

在 CloudFormation 模板中使用現有的 Elastic IP 而不是生成新的?

[英]Use an existing Elastic IP in CloudFormation template instead of generating a new one?

我目前在這里有我的模板,用於為我的實例分配一個 EIP。 (最后部分)

但是,我希望使用我的固定 EIP,而不是依賴 CloudFormation 每次都隨機生成一個新的 EIP。

Resources:
  EC2Example:
    Type: "AWS::EC2::Instance"
    Metadata:
      AWS::CloudFormation::Init:
        services:
          sysvint:
            codedeploy-agent:
              enabled: 'true'
              ensureRunning: 'true'
    Properties:
      ImageId: !Ref ImageId
      InstanceType: !Ref InstanceType
      KeyName: !Ref SSHKeyName
      IamInstanceProfile: "EC2CodeDeploy"
      NetworkInterfaces: 
        - AssociatePublicIpAddress: "true"
          DeviceIndex: "0"
          GroupSet: 
            - Ref: "SecurityGroupIds"
          SubnetId: 
            Ref: "PrivateSubnet"
      BlockDeviceMappings:
        -
          DeviceName: /dev/sda1
          Ebs:
            VolumeType: io1
            Iops: !Ref IOPS
            DeleteOnTermination: false
            VolumeSize: !Ref VolumeSize
  ElasticIP:
    Type: AWS::EC2::EIP
    Properties:
      Domain: vpc
      InstanceId: !Ref EC2Example 

您必須使用AWS::EC2::EIPAssociation 在你的情況下:

  AssociateControlPort:
    Type: AWS::EC2::EIPAssociation
    Properties:
      AllocationId: !GetAtt ElasticIP.AllocationId
      InstanceId: !Ref EC2Example

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM