Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Dernière mise à jour :Aug 11, 2026

Crée une interface réseau élastique (ENI) et une adresse IP élastique (EIP) via un hook de cycle de vie lors des événements de mise à l'échelle horizontale d'Auto Scaling, puis les associe à l'instance ECS.

Nom du modèle

Le modèle ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance utilise un hook de cycle de vie pour créer une interface réseau élastique (ENI) et une adresse IP élastique (EIP), puis attache l'ENI à l'instance.

Exécuter maintenant

Description du modèle

Ce modèle crée des ENI et des EIP via un hook de cycle de vie et les associe aux instances ECS. Si une instance n'utilise pas d'images CentOS 7.3 64 bits ou version ultérieure, CentOS 6.8 64 bits ou version ultérieure, ou Windows Server 2008 R2 ou version ultérieure, vous devez configurer manuellement les ENI. Pour plus d'informations, consultez la page https://www.alibabacloud.com/help/en/ecs/getting-started/eni. Ce modèle prend uniquement en charge les événements de mise à l'échelle horizontale.

Type de modèle

Automatisé

Propriétaire

Alibaba Cloud

Paramètres d'entrée

Paramètre

Description

Type

Obligatoire

Valeur par défaut

Limite

OOSAssumeRole

Rôle RAM assumé par Operation Orchestration Service (OOS).

String

Oui

internetChargeType

Méthode de facturation de l'EIP.

String

Non

PayByBandwidth

bandwidth

Bande passante de pointe de l'EIP.

Number

Non

5

regionId

ID de la région.

String

Non

${regionId}

instanceIds

Liste des ID d'instances ECS.

List

Non

['${instanceIds}']

lifecycleHookId

ID du hook de cycle de vie.

String

Non

${lifecycleHookId}

lifecycleActionToken

Jeton associé à une activité de mise à l'échelle spécifique liée à une instance.

String

Non

${lifecycleActionToken}

rateControl

Paramètres de contrôle de débit.

Json

Non

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

Paramètres de sortie

Aucun

Politique requise pour exécuter le modèle

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

Détails

ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance

Contenu du modèle

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