All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Last Updated:Dec 23, 2025

Template name

ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance uses a lifecycle hook to create an elastic network interface (ENI) and an Elastic IP address (EIP), and attach the ENI to the instance.

Execute Now

Template description

Uses a lifecycle hook to create elastic network interfaces (ENIs) and elastic IP addresses (EIPs) and associate the ENIs and EIPs with Elastic Compute Service (ECS) instances. After the ENIs are associated with the ECS instances, you must manually configure the ENIs for instances that do not use one of the following images: CentOS 7.3 64-bit and later, CentOS 6.8 64-bit and later, and Windows Server 2008 R2 and later. For more information, visit https://www.alibabacloud.com/help/document_detail/56955.html. This template supports only scale-out events.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

OOSAssumeRole

The RAM role that is assumed by Operation Orchestration Service (OOS).

String

Yes

internetChargeType

The billing method for the EIP.

String

No

PayByBandwidth

bandwidth

The peak bandwidth of the EIP.

Number

No

5

regionId

The region ID.

String

No

${regionId}

instanceIds

The list of ECS instance IDs.

List

No

['${instanceIds}']

lifecycleHookId

The lifecycle hook ID.

String

No

${lifecycleHookId}

lifecycleActionToken

The token for a specific scaling activity that is associated with an instance.

String

No

${lifecycleActionToken}

rateControl

The rate control settings.

Json

No

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 5}

Output parameters

None

Policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:AllocateEipAddress",
                "ecs:AssociateEipAddress",
                "ecs:AttachNetworkInterface",
                "ecs:CreateNetworkInterface",
                "ecs:DeleteNetworkInterface",
                "ecs:DescribeEipAddresses",
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:DescribeNetworkInterfaces",
                "ecs:DetachNetworkInterface",
                "ecs:ReleaseEipAddress",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Details

ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Use a lifecycle hook to create an Elastic Network Interface (ENI) and an Elastic IP Address (EIP) and attach them to an ECS instance. The ENI requires no configuration for instances that use CentOS 7.3 64-bit, CentOS 6.8 64-bit, or Windows Server 2008 R2 and later images. For other images, configure the ENI by following the instructions in the official documentation at https://www.alibabacloud.com/help/document_detail/56955.html. This template supports only scale-out activities.
  zh-cn: Use a lifecycle hook to create an ENI and an EIP in batches and attach them to an instance. The ENI requires no configuration for instances that use CentOS 7.3 64-bit, CentOS 6.8 64-bit, or Windows Server 2008 R2 and later images. For other images, configure the ENI by referring to the official documentation at https://www.alibabacloud.com/help/document_detail/56955.html. This template supports only scale-out activities.
  name-en: ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance
  name-zh-cn: Use a lifecycle hook to create an ENI and an EIP and attach them to an instance
  categories:
    - elastic_manage
Parameters:
  internetChargeType:
    Label:
      en: InternetChargeType
      zh-cn: EIP billing method
    Description:
      en: The billing method for the EIP. Valid values: PayByBandwidth and PayByTraffic.
      zh-cn: The billing method for the EIP. Valid values: PayByBandwidth (pay-by-bandwidth) and PayByTraffic (pay-by-data-transfer).
    Type: String
    AllowedValues:
      - PayByBandwidth
      - PayByTraffic
    Default: PayByBandwidth
  bandwidth:
    Label:
      en: Bandwidth
      zh-cn: Peak bandwidth of the EIP
    Description:
      en: The peak bandwidth of the EIP. Unit: Mbps.
      zh-cn: The peak bandwidth of the EIP. Unit: Mbps.
    Type: Number
    Default: 5
  regionId:
    Label:
      en: RegionId
      zh-cn: Region ID
    Description:
      en: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
      zh-cn: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
    Type: String
    Default: '${regionId}'
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: List of ECS instance IDs
    Description:
      en: The list of ECS instance IDs. Use the default value ["${instanceIds}"] provided by Auto Scaling.
      zh-cn: The list of ECS instance IDs. Use the default value ["${instanceId}"] provided by Auto Scaling.
    Type: List
    Default:
      - '${instanceIds}'
  lifecycleHookId:
    Label:
      en: LifecycleHookId
      zh-cn: Lifecycle hook ID
    Description:
      en: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
      zh-cn: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
    Type: String
    Default: '${lifecycleHookId}'
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken
      zh-cn: Token for the scaling activity
    Description:
      en: The token for the scaling activity. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
      zh-cn: The token for the scaling activity. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
    Type: String
    Default: '${lifecycleActionToken}'
  rateControl:
    Label:
      en: RateControl
      zh-cn: Rate control
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 5
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role to be assumed by OOS
    Type: String
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: createNetWorkInterfaceAndEipAndAttachToInstance
    Action: 'ACS::ECS::CreateNetworkInterfaceAndEipAndAttachToInstance'
    OnSuccess: CompleteLifecycleActionForContinue
    OnError: CompleteLifecycleActionForAbandon
    Description:
      en: Create an ENI and an EIP and attach them to the instance.
      zh-cn: Create an ENI and an EIP and attach them to the instance.
    Properties:
      regionId: '{{ regionId }}'
      internetChargeType: '{{ internetChargeType }}'
      bandwidth: '{{ bandwidth }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ instanceIds }}'
  - Name: CompleteLifecycleActionForContinue
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Set the lifecycle action to CONTINUE.
      zh-cn: Set the wait state of the scaling activity to Continue.
    OnSuccess: 'ACS::END'
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: CONTINUE
  - Name: CompleteLifecycleActionForAbandon
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Set the lifecycle action to ABANDON.
      zh-cn: Set the wait state of the scaling activity to Abandon.
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: ABANDON