全部产品
Search
文档中心

系统运维管理:ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId

更新时间:Dec 25, 2025

模板名称

ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId 将一台实例的公网IP转化为其它弹性公网IP

立即执行

模板描述

将一台网络类型为专有网络VPC的ECS实例的公网IP转化为其它弹性公网IP

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

instanceId

ECS实例ID

String

是

OOSAssumeRole

OOS扮演的RAM角色

String

否

""

输出参数

参数名称

描述

类型

AllocationId

String

EipAddress

String

执行此模板需要的权限策略

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:AllocateEipAddress",
                "ecs:AssociateEipAddress",
                "ecs:ConvertNatPublicIpToEip",
                "ecs:DescribeInstances",
                "ecs:ModifyInstanceNetworkSpec",
                "ecs:UnassociateEipAddress"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "vpc:DescribeEipAddresses"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

详情

ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId详情

模板内容

FormatVersion: OOS-2019-06-01
Description:
  en: Converts the public IP address of a VPC-connected ECS instance with another Elastic IP (EIP) address
  zh-cn: 将一台网络类型为专有网络VPC的ECS实例的公网IP转化为其它弹性公网IP
  name-en: ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId
  name-zh-cn: 将一台实例的公网IP转化为其它弹性公网IP
  categories:
    - instance_manage
Parameters:
  instanceId:
    Label:
      en: InstanceId
      zh-cn: ECS实例ID
    Type: String
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: modifyInstanceNetworkSpec
  Action: ACS::ExecuteAPI
  Description:
    en: Modifies the network charge type of the ECS instance with the specified parameters
    zh-cn: 转换ECS实例网络付费方式
  Properties:
    Service: ECS
    API: ModifyInstanceNetworkSpec
    Parameters:
      InstanceId: '{{ instanceId }}'
      NetworkChargeType: PayByTraffic
- Name: convertNatPublicIpToEip
  Action: ACS::ExecuteApi
  Description:
    en: Converts the public IP address of a VPC-connected ECS instance to an Elastic IP (EIP) address
    zh-cn: 将一台网络类型为专有网络VPC的ECS实例的公网IP转化为弹性公网IP
  Properties:
    Service: ECS
    API: ConvertNatPublicIpToEip
    Parameters:
      InstanceId: '{{ instanceId }}'
- Name: getInstanceEIP
  Action: ACS::ExecuteApi
  Description:
    en: Gets ECS instance EIP
    zh-cn: 获取实例弹性公网IP
  Properties:
    Service: ECS
    API: DescribeInstances
    Parameters:
      InstanceId:
      - '{{ instanceId }}'
  Outputs:
    allocationId:
      Type: String
      ValueSelector: Instances.Instance[].EipAddress.AllocationId
- Name: unassociateEipAddress
  Action: ACS::ExecuteApi
  Description:
    en: Elastic public network IP (EIP) is unbound from an ECS instacne
    zh-cn: 弹性公网IP(EIP)从绑定的ECS实例上解绑
  Properties:
    Service: ECS
    API: UnassociateEipAddress
    Parameters:
      InstanceId: '{{ instanceId }}'
      AllocationId: '{{ getInstanceEIP.allocationId }}'
- Name: AllocateEipAddress
  Action: ACS::ExecuteAPI
  Description:
    en: Allocate an Eip address
    zh-cn: 申请一个弹性公网IP
  Properties:
    Service: ECS
    API: AllocateEipAddress
    Parameters: {}
  Outputs:
    AllocationId:
      Type: String
      ValueSelector: AllocationId
    EipAddress:
      Type: String
      ValueSelector: EipAddress
- Name: DescribeEipAddresses
  Action: ACS::WaitFor
  Description:
    en: Waits for the Eip to enter Available status
    zh-cn: 等待EIP可用
  Properties:
    Service: VPC
    API: DescribeEipAddresses
    Parameters:
      AllocationId: '{{ AllocateEipAddress.AllocationId }}'
    DesiredValues:
      - Available
    PropertySelector: EipAddresses.EipAddress[].Status
- Name: AssociateEipAddress
  Action: ACS::ExecuteAPI
  Description:
    en: Bind the new EIP to the ECS instance in the same region
    zh-cn: 绑定新EIP到同地域的ECS实例上
  Properties:
    Service: ECS
    API: AssociateEipAddress
    Parameters:
      InstanceId: '{{ InstanceId }}'
      AllocationId: '{{ AllocateEipAddress.AllocationId }}'
Outputs:
  AllocationId:
    Type: String
    Value: '{{ AllocateEipAddress.AllocationId }}'
  EipAddress:
    Type: String
    Value: '{{ AllocateEipAddress.EipAddress }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - instanceId
        Label:
          default:
            zh-cn: 选择实例
            en: Select Ecs Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options