All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId

Last Updated:Nov 25, 2024

Template name

ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId

Execute Now

Template description

Converts the public IP address of a virtual IP address (VIP)-connected Elastic Compute Service (ECS) instance to an elastic IP (EIP).

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

instanceId

The ID of the ECS instance.

String

Yes

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Type

AllocationId

String

EipAddress

String

Permission policy that is required to execute the template

{
    "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"
        }
    ]
}

References

For more information, see ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId.yml at GitHub.

Template content

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: the description in Chinese
  name-en: ACS-ECS-ConvertsPublicIPToNewEIPByInstanceId
  name-zh-cn: the description in Chinese
  categories:
    - instance_manage
Parameters:
  instanceId:
    Label:
      en: InstanceId
      zh-cn: the description in Chinese
    Type: String
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    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: the description in Chinese
  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: the description in Chinese
  Properties:
    Service: ECS
    API: ConvertNatPublicIpToEip
    Parameters:
      InstanceId: '{{ instanceId }}'
- Name: getInstanceEIP
  Action: ACS::ExecuteApi
  Description:
    en: Gets ECS instance EIP
    zh-cn: the description in Chinese
  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: the description in Chinese
  Properties:
    Service: ECS
    API: UnassociateEipAddress
    Parameters:
      InstanceId: '{{ instanceId }}'
      AllocationId: '{{ getInstanceEIP.allocationId }}'
- Name: AllocateEipAddress
  Action: ACS::ExecuteAPI
  Description:
    en: Allocate an Eip address
    zh-cn: the description in Chinese
  Properties:
    Service: ECS
    API: AllocateEipAddress
    Parameters: Null
  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: the description in Chinese
  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: the description in Chinese
  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: the description in Chinese
            en: Select Ecs Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options