ALIYUN::VPC::EIPAssociation is used to associate an Elastic IP address with a cloud service instance.

Statement

{
  "Type": "ALIYUN::VPC::EIPAssociation",
  "Properties": {
    "AllocationId": String,
    "InstanceId": String,
    "PrivateIpAddress": String,
    "Mode": String
  }
}         

Properties

Parameter Type Required Editable Description Constraint
AllocationId String No Yes The ID of the Elastic IP address. None
InstanceId String No Yes The ID of the cloud service instance. The following instance types are supported:
  • VPC-connected ECS instances
  • VPC-connected SLB instances
  • NAT gateways
  • HAVIP
  • Elastic network interfaces
PrivateIpAddress String Yes True The private IP address in the CIDR block of the VSwitch. None
Mode String Yes True The association mode. Valid values:
  • NAT
  • MULTI_BINDED

Response parameters

Fn::GetAtt

  • EipAddress: The allocated Elastic IP address.
  • AllocationId: The ID of the instance to which the Elastic IP address is allocated.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "Eip": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InternetChargeType": "PayByTraffic",
          "Bandwidth": 200
      }
    },
    "EipAssociation": {
      "Type": "ALIYUN::VPC::EIPAssociation", 
      "Properties": {
        "InstanceId": "<LoadBalancerId>", 
        "InstanceType": "EcsInstance", 
        "AllocationId": {
          "Fn::GetAtt": ["Eip", "AllocationId"]
        }
      }
    }
  },
  "Outputs": {
    "EipAddress": {
      "Value" : {"Fn::GetAtt": ["EipAssociation", "EipAddress"]}
    },
    "AllocationId": {
      "Value" : {"Fn::GetAtt": ["EipAssociation", "AllocationId"]}
    }
  }
}

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Eip:
    Type: ALIYUN::VPC::EIP
    Properties:
      InternetChargeType: PayByTraffic
      Bandwidth: 200
  EipAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId: "<LoadBalancerId>"
      InstanceType: EcsInstance
      AllocationId:
        Fn::GetAtt:
        - Eip
        - AllocationId
Outputs:
  EipAddress:
    Value:
      Fn::GetAtt:
      - EipAssociation
      - EipAddress
  AllocationId:
    Value:
      Fn::GetAtt:
      - EipAssociation
      - AllocationId