ALIYUN::VPC::EIP类型用于申请弹性公网IP(Elastic IP Address,简称EIP)。
语法
{
"Type": "ALIYUN::VPC::EIP",
"Properties": {
"DeletionProtection": Boolean,
"Name": String,
"Tags": List,
"Isp": String,
"Netmode": String,
"Period": Number,
"ResourceGroupId": String,
"AutoPay": Boolean,
"InstanceChargeType": String,
"PricingCycle": String,
"Bandwidth": Number,
"InternetChargeType": String,
"Description": String,
"SecurityProtectionTypes": List,
"PublicIpAddressPoolId": String,
"Zone": String
}
}属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
DeletionProtection | Boolean | 否 | 是 | 是否开启删除保护功能。 | 取值:
|
Name | String | 否 | 是 | EIP的名称。 | 长度为2~128个字符。以英文字母开头,不能以 |
ResourceGroupId | String | 否 | 是 | 资源组ID。 | 无 |
Netmode | String | 否 | 否 | 网络类型。 | 取值:public,表示公网。 |
Bandwidth | Number | 否 | 是 | EIP的带宽值。 | 如果不指定,则取默认值5 Mbps。 |
InternetChargeType | String | 否 | 否 | EIP的计费方式。 | 取值:
|
InstanceChargeType | String | 否 | 否 | EIP的付费方式。 | 取值:
|
PricingCycle | String | 否 | 否 | 预付费的计费周期。 | 取值:
说明 InstanceChargeType取值为Prepaid时,PricingCycle必选。 |
Period | Number | 否 | 否 | 购买时长。 | 取值:
默认值:1。 说明 InstanceChargeType取值为Prepaid时,Period必选。 |
AutoPay | Boolean | 否 | 否 | 是否开启自动付费。 | 取值:
说明 InstanceChargeType取值为Prepaid时,AutoPay必选。 |
Isp | String | 否 | 否 | 线路类型。 | 取值:
目前,全部地域都支持BGP(多线)线路EIP,仅中国香港地域支持BGP(多线)精品线路EIP。 |
Description | String | 否 | 是 | EIP的描述信息。 | 长度为2~256个字符。以英文字母开头,不能以 |
Tags | List | 否 | 是 | 标签。 | 最多设置20个标签,每个标签由键值对组成。标签值可以为空。 |
SecurityProtectionTypes | List | 否 | 否 | 安全防护级别。 | 取值:
说明 您最多可以设置10个安全防护级别。 |
PublicIpAddressPoolId | String | 否 | 否 | IP地址池ID。 | EIP将从该IP地址池中分配,IP地址池仅对通过试用申请的用户可见。如需使用,请提交工单。 |
Zone | String | 否 | 否 | 弹性公网IP可用分区。 | 无 |
Tags语法
"Tags": [
{
"Key": String,
"Value": String
}
] Tags属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Key | String | 是 | 否 | 标签键。 | 长度为1~128个字符,不能以 |
Value | String | 否 | 否 | 标签值。 | 长度为0~128个字符,不能以 |
返回值
Fn::GetAtt
EipAddress:分配的EIP。
AllocationId:EIP的实例ID。
OrderId:订单号,仅InstanceChargeType取值为Prepaid时返回。
Isp:线路类型。
示例
场景 1 :创建一个按带宽计费的EIP实例。
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
ElasticIp:
Type: ALIYUN::VPC::EIP
Properties:
InstanceChargeType: Postpaid
Name: TestEIP
InternetChargeType: PayByBandwidth
Netmode: public
Bandwidth: 5
Outputs:
Isp:
Description: The line type.
Value:
Fn::GetAtt:
- ElasticIp
- Isp
AllocationId:
Description: ID that Aliyun assigns to represent the allocation of the address for use with VPC. Returned only for VPC elastic IP addresses.
Value:
Fn::GetAtt:
- ElasticIp
- AllocationId
EipAddress:
Description: IP address of created EIP.
Value:
Fn::GetAtt:
- ElasticIp
- EipAddress
OrderId:
Description: Order ID of prepaid EIP instance.
Value:
Fn::GetAtt:
- ElasticIp
- OrderId{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
},
"Resources": {
"ElasticIp": {
"Type": "ALIYUN::VPC::EIP",
"Properties": {
"InstanceChargeType": "Postpaid",
"Name": "TestEIP",
"InternetChargeType": "PayByBandwidth",
"Netmode": "public",
"Bandwidth": 5
}
}
},
"Outputs": {
"Isp": {
"Description": "The line type.",
"Value": {
"Fn::GetAtt": [
"ElasticIp",
"Isp"
]
}
},
"AllocationId": {
"Description": "ID that Aliyun assigns to represent the allocation of the address for use with VPC. Returned only for VPC elastic IP addresses.",
"Value": {
"Fn::GetAtt": [
"ElasticIp",
"AllocationId"
]
}
},
"EipAddress": {
"Description": "IP address of created EIP.",
"Value": {
"Fn::GetAtt": [
"ElasticIp",
"EipAddress"
]
}
},
"OrderId": {
"Description": "Order ID of prepaid EIP instance.",
"Value": {
"Fn::GetAtt": [
"ElasticIp",
"OrderId"
]
}
}
}
}场景 2 :创建一个按带宽计费的EIP实例并绑定到 NAT 网关。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
ZoneId:
Type: String
AssociationProperty: ZoneId
VpcId:
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
VSwitchId:
Type: String
AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: ${VpcId}
ZoneId: ${ZoneId}
Resources:
NatGateway:
Type: ALIYUN::VPC::NatGateway
Properties:
NatGatewayName: example-ngw
VSwitchId:
Ref: VSwitchId
NatType: Enhanced
VpcId:
Ref: VpcId
ZoneId:
Ref: ZoneId
Eip:
Type: ALIYUN::VPC::EIP
Properties:
DeletionProtection: false
Isp: BGP
Bandwidth: 200
InternetChargeType: PayByTraffic
EipAssociation:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Ref: NatGateway
AllocationId:
Ref: Eip
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"ZoneId": {
"Type": "String",
"AssociationProperty": "ZoneId"
},
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"VSwitchId": {
"Type": "String",
"AssociationProperty": "ALIYUN::VPC::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"VpcId": "${VpcId}",
"ZoneId": "${ZoneId}"
}
}
},
"Resources": {
"NatGateway": {
"Type": "ALIYUN::VPC::NatGateway",
"Properties": {
"NatGatewayName": "example-ngw",
"VSwitchId": {
"Ref": "VSwitchId"
},
"NatType": "Enhanced",
"VpcId": {
"Ref": "VpcId"
},
"ZoneId": {
"Ref": "ZoneId"
}
}
},
"Eip": {
"Type": "ALIYUN::VPC::EIP",
"Properties": {
"DeletionProtection": false,
"Isp": "BGP",
"Bandwidth": 200,
"InternetChargeType": "PayByTraffic"
}
},
"EipAssociation": {
"Type": "ALIYUN::VPC::EIPAssociation",
"Properties": {
"InstanceId": {
"Ref": "NatGateway"
},
"AllocationId": {
"Ref": "Eip"
}
}
}
}
}场景 3 :部署公网 NAT 网关实现统一的云上公网访问出口。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建VPC环境,配置双可用区ECS实例,部署公网NAT网关实现统一的云上公网访问出口。
en: Create a Virtual Private Cloud (VPC) environment, configure dual-Availability
Zone Elastic Compute Service (ECS) instances, and deploy a public-facing NAT Gateway
to establish a unified cloud Internet access gateway.
Parameters:
CommonName:
Type: String
Default: unified-egress
ZoneId1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId2
Label:
en: Availability Zone
zh-cn: 可用区1
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: 可用区2
InstanceType1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: ECS Instance Type
zh-cn: ECS 实例规格1
InstanceType2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
ZoneId: ${ZoneId}
Label:
en: ECS Instance Type
zh-cn: ECS 实例规格2
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符号)
Label:
en: Instance Password
zh-cn: 实例密码
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: '长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符号)'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
Default: null
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
CidrBlock: 192.168.0.0/16
VpcName:
Fn::Sub: ${CommonName}-vpc
VSwitch1:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.1.0/24
ZoneId:
Ref: ZoneId1
VSwitchName:
Fn::Sub: ${CommonName}-app1-vsw
VSwitch2:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.2.0/24
ZoneId:
Ref: ZoneId2
VSwitchName:
Fn::Sub: ${CommonName}-app2-vsw
VSwitch3:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.3.0/24
ZoneId:
Ref: ZoneId1
VSwitchName:
Fn::Sub: ${CommonName}-pub-vsw
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: ${CommonName}-sg
SecurityGroupIngress:
- PortRange: 443/443
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
EcsInstance1:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId1
VSwitchId:
Ref: VSwitch1
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
InstanceName:
Fn::Sub: ${CommonName}-ecs-1
InstanceType:
Ref: InstanceType1
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 0
Password:
Ref: InstancePassword
EcsInstance2:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId2
VSwitchId:
Ref: VSwitch2
SecurityGroupId:
Ref: SecurityGroup
ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
InstanceName:
Fn::Sub: ${CommonName}-ecs-2
InstanceType:
Ref: InstanceType2
SystemDiskCategory: cloud_essd
MaxAmount: 1
InternetMaxBandwidthOut: 0
Password:
Ref: InstancePassword
NatGateway:
Type: 'ALIYUN::VPC::NatGateway'
Properties:
NatGatewayName:
Fn::Sub: ${CommonName}-ngw
VSwitchId:
Ref: VSwitch3
NatType: Enhanced
VpcId:
Ref: Vpc
ZoneId:
Ref: ZoneId1
Eip:
Type: 'ALIYUN::VPC::EIP'
Properties:
DeletionProtection: false
Isp: BGP
Bandwidth: 200
InternetChargeType: PayByTraffic
EipAssociation:
Type: 'ALIYUN::VPC::EIPAssociation'
Properties:
InstanceId:
Ref: NatGateway
AllocationId:
Ref: Eip
SNat:
Type: 'ALIYUN::VPC::SnatEntry'
DependsOn: EipAssociation
Properties:
SnatTableId:
Fn::GetAtt:
- NatGateway
- SNatTableId
SnatEntryName:
Fn::Sub: ${CommonName}-snat
SourceVSwitchIds:
- Ref: VSwitch1
- Ref: VSwitch2
SnatIp:
Fn::GetAtt:
- Eip
- EipAddress
Outputs:
EcsLoginAddress1:
Description:
en: Ecs1 login address.
zh-cn: ECS1 登录地址。
Value:
Fn::Sub: >-
https://ecs-workbench.aliyun.com/?from=EcsConsole
&instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${EcsInstance1}
EcsLoginAddress2:
Description:
en: Ecs2 login address.
zh-cn: ECS2 登录地址。
Value:
Fn::Sub: >-
https://ecs-workbench.aliyun.com/?from=EcsConsole
&instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${EcsInstance2}
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ZoneId1
- ZoneId2
Label:
default:
en: ZoneID
zh-cn: 交换机可用区配置
- Parameters:
- InstanceType1
- InstanceType2
- InstancePassword
Label:
default:
en: ECS Instance Configuration
zh-cn: ECS实例配置
TemplateTags:
- acs:technical-solution:network:通过公网NAT网关实现云上统一公网出口-tech_solu_134
Hidden:
- CommonName{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建VPC环境,配置双可用区ECS实例,部署公网NAT网关实现统一的云上公网访问出口。",
"en": "Create a Virtual Private Cloud (VPC) environment, configure dual-Availability Zone Elastic Compute Service (ECS) instances, and deploy a public-facing NAT Gateway to establish a unified cloud Internet access gateway."
},
"Parameters": {
"CommonName": {
"Type": "String",
"Default": "unified-egress"
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "可用区1"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "可用区2"
}
},
"InstanceType1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "ECS Instance Type",
"zh-cn": "ECS 实例规格1"
}
},
"InstanceType2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"ZoneId": "${ZoneId}"
},
"Label": {
"en": "ECS Instance Type",
"zh-cn": "ECS 实例规格2"
}
},
"InstancePassword": {
"NoEcho": true,
"Type": "String",
"Description": {
"en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)"
},
"Label": {
"en": "Instance Password",
"zh-cn": "实例密码"
},
"ConstraintDescription": {
"en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)"
},
"AssociationProperty": "ALIYUN::ECS::Instance::Password",
"Default": null
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16",
"VpcName": {
"Fn::Sub": "${CommonName}-vpc"
}
}
},
"VSwitch1": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.1.0/24",
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-app1-vsw"
}
}
},
"VSwitch2": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.2.0/24",
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-app2-vsw"
}
}
},
"VSwitch3": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.3.0/24",
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-pub-vsw"
}
}
},
"SecurityGroup": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupName": {
"Fn::Sub": "${CommonName}-sg"
},
"SecurityGroupIngress": [
{
"PortRange": "443/443",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
},
{
"PortRange": "80/80",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
}
]
}
},
"EcsInstance1": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchId": {
"Ref": "VSwitch1"
},
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs-1"
},
"InstanceType": {
"Ref": "InstanceType1"
},
"SystemDiskCategory": "cloud_essd",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 0,
"Password": {
"Ref": "InstancePassword"
}
}
},
"EcsInstance2": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchId": {
"Ref": "VSwitch2"
},
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
"InstanceName": {
"Fn::Sub": "${CommonName}-ecs-2"
},
"InstanceType": {
"Ref": "InstanceType2"
},
"SystemDiskCategory": "cloud_essd",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 0,
"Password": {
"Ref": "InstancePassword"
}
}
},
"NatGateway": {
"Type": "ALIYUN::VPC::NatGateway",
"Properties": {
"NatGatewayName": {
"Fn::Sub": "${CommonName}-ngw"
},
"VSwitchId": {
"Ref": "VSwitch3"
},
"NatType": "Enhanced",
"VpcId": {
"Ref": "Vpc"
},
"ZoneId": {
"Ref": "ZoneId1"
}
}
},
"Eip": {
"Type": "ALIYUN::VPC::EIP",
"Properties": {
"DeletionProtection": false,
"Isp": "BGP",
"Bandwidth": 200,
"InternetChargeType": "PayByTraffic"
}
},
"EipAssociation": {
"Type": "ALIYUN::VPC::EIPAssociation",
"Properties": {
"InstanceId": {
"Ref": "NatGateway"
},
"AllocationId": {
"Ref": "Eip"
}
}
},
"SNat": {
"Type": "ALIYUN::VPC::SnatEntry",
"DependsOn": "EipAssociation",
"Properties": {
"SnatTableId": {
"Fn::GetAtt": [
"NatGateway",
"SNatTableId"
]
},
"SnatEntryName": {
"Fn::Sub": "${CommonName}-snat"
},
"SourceVSwitchIds": [
{
"Ref": "VSwitch1"
},
{
"Ref": "VSwitch2"
}
],
"SnatIp": {
"Fn::GetAtt": [
"Eip",
"EipAddress"
]
}
}
}
},
"Outputs": {
"EcsLoginAddress1": {
"Description": {
"en": "Ecs1 login address.",
"zh-cn": "ECS1 登录地址。"
},
"Value": {
"Fn::Sub": "https://ecs-workbench.aliyun.com/?from=EcsConsole &instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${EcsInstance1}"
}
},
"EcsLoginAddress2": {
"Description": {
"en": "Ecs2 login address.",
"zh-cn": "ECS2 登录地址。"
},
"Value": {
"Fn::Sub": "https://ecs-workbench.aliyun.com/?from=EcsConsole &instanceType=ecs®ionId=${ALIYUN::Region}&instanceId=${EcsInstance2}"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId1",
"ZoneId2"
],
"Label": {
"default": {
"en": "ZoneID",
"zh-cn": "交换机可用区配置"
}
}
},
{
"Parameters": [
"InstanceType1",
"InstanceType2",
"InstancePassword"
],
"Label": {
"default": {
"en": "ECS Instance Configuration",
"zh-cn": "ECS实例配置"
}
}
}
],
"TemplateTags": [
"acs:technical-solution:network:通过公网NAT网关实现云上统一公网出口-tech_solu_134"
],
"Hidden": [
"CommonName"
]
}
}
}