All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance

Last Updated:Dec 30, 2024

Template name

ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance

Execute Now

Template description

Uses a lifecycle hook to create elastic IP addresses (EIPs) and associate the EIPs with Elastic Compute Service (ECS) instances. This template supports only scale-out events.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

internetChargeType

The billing method of the EIPs.

String

No

PayByBandwidth

bandwidth

The peak bandwidth of the EIPs.

Number

No

5

regionId

The region ID.

String

No

${regionId}

instanceIds

The IDs of the ECS instances.

List

No

['${instanceIds}']

eipTags

The tags of the EIPs.

Json

No

[{'Key': 'oos_generate', 'Value': '{{ACS::ExecutionId}}'}]

lifecycleHookId

The lifecycle hook ID.

String

No

${lifecycleHookId}

lifecycleActionToken

The token of a specific scaling activity that is associated with the instances.

String

No

${lifecycleActionToken}

rateControl

The rate control settings.

Json

No

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

OOSAssumeRole

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

String

No

OOSServiceRole

Output parameters

None

Policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:AllocateEipAddress",
                "ecs:AssociateEipAddress",
                "ecs:DescribeEipAddresses",
                "ecs:DescribeInstances",
                "ecs:ReleaseEipAddress",
                "ecs:UnassociateEipAddress"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "vpc:TagResources"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

References

ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Use lifecycleHook to create EIP and attach them to the instance(only supports elastic expansion activities)
  name-en: ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance
  categories:
    - elastic_manage
Parameters:
  internetChargeType:
    Label:
      en: InternetChargeType
    Description:
      en: EIP measurement method
    Type: String
    AllowedValues:
      - PayByBandwidth
      - PayByTraffic
    Default: PayByBandwidth
  bandwidth:
    Label:
      en: Bandwidth
    Description:
      en: Peak bandwidth of eip, unit: Mbps
    Type: Number
    Default: 5
  regionId:
    Label:
      en: RegionId
    Description:
      en: The ID of region
    Type: String
    Default: '${regionId}'
  instanceIds:
    Label:
      en: InstanceIds
    Description:
      en: The ID list of the ECS instance.
    Type: List
    Default:
      - '${instanceIds}'
  eipTags:
    Label:
      en: EipTags
    Description:
      en: The tags for EIP(format:[{"Key":"test1","Value":"test1"},{"Key":"test2","Value":"test2"}....]).
    Type: Json
    Default: [{"Key":"oos_generate","Value":"{{ACS::ExecutionId}}"}]
  lifecycleHookId:
    Label:
      en: LifecycleHookId
    Description:
      en: The ID of the lifecycle hook.
    Type: String
    Default: '${lifecycleHookId}'
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken
    Description:
      en: The token that indicates a specific scaling activity associated with an instance.
    Type: String
    Default: '${lifecycleActionToken}'
  rateControl:
    Label:
      en: RateControl
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 5
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: createEipAndAttachToInstance
    Action: 'ACS::ECS::AllocateEipAddressAndAttachToInstance'
    OnSuccess: CompleteLifecycleActionForContinue
    OnError: CompleteLifecycleActionForAbandon
    Description:
      en: Create the eip and attach to instace
    Properties:
      regionId: '{{ regionId }}'
      internetChargeType: '{{ internetChargeType }}'
      bandwidth: '{{ bandwidth }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      tags: '{{ eipTags }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ instanceIds }}'
  - Name: CompleteLifecycleActionForContinue
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Modify lifecycle action for 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: Complete lifecycle action for Abandon
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: ABANDON