Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Última atualização: Sep 12, 2026

Crie uma ENI e um EIP por meio de um lifecycle hook durante eventos de scale-out do Auto Scaling e os anexa à instância ECS.

Nome do modelo

O modelo ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance usa um lifecycle hook para criar uma elastic network interface (ENI) e um Elastic IP address (EIP) e anexar a ENI à instância.

Executar agora

Descrição do modelo

Este modelo cria ENIs e EIPs por meio de um lifecycle hook e os associa a instâncias ECS. Se a instância não usar imagens CentOS 7.3 64 bits ou posterior, CentOS 6.8 64 bits ou posterior, ou Windows Server 2008 R2 ou posterior, configure as ENIs manualmente. Para mais informações, consulte Elastic Network Interfaces. Este modelo oferece suporte apenas a eventos de scale-out.

Tipo de modelo

Automatizado

Proprietário

Alibaba Cloud

Parâmetros de entrada

Parâmetro

Descrição

Tipo

Obrigatório

Valor padrão

Limite

OOSAssumeRole

A função RAM assumida pelo Operation Orchestration Service (OOS).

String

Sim

internetChargeType

O método de faturamento do EIP.

String

Não

PayByBandwidth

bandwidth

A largura de banda máxima do EIP.

Number

Não

5

regionId

O ID da região.

String

Não

${regionId}

instanceIds

A lista de IDs das instâncias ECS.

List

Não

['${instanceIds}']

lifecycleHookId

O ID do lifecycle hook.

String

Não

${lifecycleHookId}

lifecycleActionToken

O token de uma atividade de dimensionamento específica associada a uma instância.

String

Não

${lifecycleActionToken}

rateControl

As configurações de controle de taxa.

Json

Não

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

Parâmetros de saída

Nenhum

Política necessária para executar o modelo

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

Detalhes

ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Conteúdo do modelo

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